From 4a68bcfd8b0d206d5d5e5c18d5fcc8e55d1732b5 Mon Sep 17 00:00:00 2001 From: Patrick Farrell Date: Mon, 15 Jul 2019 13:44:14 -0400 Subject: [PATCH] LU-10070 test: llapi_layout_test enhancements This patch improves the interactive behavior of llapi_layout_test, by adding the ability to specify a run list, rather than just a skip list. Test-Parameters: trivial Signed-off-by: Patrick Farrell Change-Id: I2ec9de94c228f309c157a3d4e75615ab8581330a Reviewed-on: https://review.whamcloud.com/33779 Tested-by: jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Wei Liu Reviewed-by: James Simmons --- lustre/tests/llapi_layout_test.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/lustre/tests/llapi_layout_test.c b/lustre/tests/llapi_layout_test.c index 0bae91f..f875f91 100644 --- a/lustre/tests/llapi_layout_test.c +++ b/lustre/tests/llapi_layout_test.c @@ -70,12 +70,14 @@ do { \ static char *lustre_dir; static char *poolname; +static bool run_list_provided; static int num_osts = -1; void usage(char *prog) { printf("Usage: %s [-d lustre_dir] [-p pool_name] [-o num_osts] " - "[-s $n,$m,..]\n", prog); + "[-s $n,$m,... (skip tests)] [-t $n,$m,... (run tests)]\n", + prog); exit(0); } @@ -1802,7 +1804,8 @@ int test(void (*test_fn)(), const char *test_desc, bool test_skip, int test_num) char status_buf[128]; if (test_skip) { - print_test_desc(test_num, test_desc, "skip"); + if (!run_list_provided) + print_test_desc(test_num, test_desc, "skip"); return 0; } @@ -1857,11 +1860,34 @@ static void set_tests_skipped(char *str_tests) } } +static void set_tests_to_run(char *str_tests) +{ + char *ptr = str_tests; + int tstno; + int i = 0; + + if (ptr == NULL || strlen(ptr) == 0) + return; + + for (i = 0; i < NUM_TESTS ; i++) + test_tbl[i].tte_skip = true; + + while (*ptr != '\0') { + tstno = strtoul(ptr, &ptr, 0); + if (tstno >= 0 && tstno < NUM_TESTS) + test_tbl[tstno].tte_skip = false; + if (*ptr == ',') + ptr++; + else + break; + } +} + static void process_args(int argc, char *argv[]) { int c; - while ((c = getopt(argc, argv, "d:p:o:s:")) != -1) { + while ((c = getopt(argc, argv, "d:p:o:s:t:")) != -1) { switch (c) { case 'd': lustre_dir = optarg; @@ -1875,6 +1901,10 @@ static void process_args(int argc, char *argv[]) case 's': set_tests_skipped(optarg); break; + case 't': + run_list_provided = true; + set_tests_to_run(optarg); + break; case '?': fprintf(stderr, "Unknown option '%c'\n", optopt); usage(argv[0]); -- 1.8.3.1