[Xenomai-git] Philippe Gerum : lib/smokey: enable test filtering with --list[=expr]
Module: xenomai-3 Branch: next Commit: d404b2c060ddc3300856c4491b36e5fe083410a9 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=d404b2c060ddc3300856c4491b36e5fe083410a9 Author: Philippe Gerum Date: Sat May 19 12:01:49 2018 +0200 lib/smokey: enable test filtering with --list[=expr] --- lib/smokey/init.c | 91 +++-- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/lib/smokey/init.c b/lib/smokey/init.c index 9df9a55..e1a133e 100644 --- a/lib/smokey/init.c +++ b/lib/smokey/init.c @@ -143,11 +143,13 @@ * Any program linked against the Smokey API implicitly recognizes the * following options: * - * - --list dumps the list of tests implemented in the program to - * stdout. The information given includes the description strings - * provided in the plugin declarators (smokey_test_plugin()). The - * position and symbolic name of each test is also issued, which may - * be used in id specifications with the --run option (see below). + * - --list[=] dumps the list of tests implemented in the + * program to stdout. This list may be restricted to the tests + * matching the optional regular expression (see --run). The + * information given includes the description strings provided in + * the plugin declarators (smokey_test_plugin()). The position and + * symbolic name of each test is also issued, which may be used in + * id specifications with the --run option (see below). * * @note Test positions may vary depending on changes to the host * program like adding or removing other tests, the symbolic name @@ -297,7 +299,7 @@ static const struct option smokey_options[] = { { #define list_opt 2 .name = "list", - .has_arg = no_argument, + .has_arg = optional_argument, .flag = &do_list, .val = 1, }, @@ -319,13 +321,13 @@ static const struct option smokey_options[] = { static void smokey_help(void) { fprintf(stderr, "--keep-going don't stop upon test error\n"); - fprintf(stderr, "--list list all tests\n"); + fprintf(stderr, "--list[=]] list [matching] tests\n"); fprintf(stderr, "--run[=]] run [portion of] the test list\n"); fprintf(stderr, "--exclude=]exclude test(s) from the run list\n"); fprintf(stderr, "--vm hint about running in a virtual environment\n"); } -static void pick_test_range(int start, int end) +static void pick_test_range(struct pvlistobj *dst, int start, int end) { struct smokey_test *t, *tmp; @@ -336,7 +338,7 @@ static void pick_test_range(int start, int end) if (t->__reserved.id >= start && t->__reserved.id <= end) { pvlist_remove(&t->__reserved.next); - pvlist_append(&t->__reserved.next, &smokey_test_list); + pvlist_append(&t->__reserved.next, dst); } } } else { @@ -344,13 +346,13 @@ static void pick_test_range(int start, int end) if (t->__reserved.id >= end && t->__reserved.id <= start) { pvlist_remove(&t->__reserved.next); - pvlist_append(&t->__reserved.next, &smokey_test_list); + pvlist_append(&t->__reserved.next, dst); } } } } -static void drop_test_range(int start, int end) +static void drop_test_range(struct pvlistobj *dst, int start, int end) { struct smokey_test *t, *tmp; @@ -363,7 +365,7 @@ static void drop_test_range(int start, int end) if (t->__reserved.id >= start && t->__reserved.id <= end) { pvlist_remove(&t->__reserved.next); - pvlist_append(&t->__reserved.next, &exclude_list); + pvlist_append(&t->__reserved.next, dst); } } } @@ -376,8 +378,8 @@ static int resolve_id(const char *s) return atoi(s); /* -* CAUTION: as we transfer items from register_list to -* smokey_test_list, we may end up with an empty source list, +* CAUTION: as we transfer items from register_list to a +* destination list, we may end up with an empty source list, * which is a perfectly valid situation. Unlike having an * empty registration list at startup, which would mean that * no test is available from the current program. @@ -392,7 +394,7 @@ static int resolve_id(const char *s) return -1; } -static int do_glob_match(const char *s, struct pvlistobj *list) +static int glob_match(struct pvlistobj *dst, const char *s) { struct smokey_t
[Xenomai-git] Philippe Gerum : lib/smokey: enable test filtering with --list[=expr]
Module: xenomai-3 Branch: next Commit: 4b1e411395a44840fdbc2cfeb90a09bfe19e5026 URL: http://git.xenomai.org/?p=xenomai-3.git;a=commit;h=4b1e411395a44840fdbc2cfeb90a09bfe19e5026 Author: Philippe Gerum Date: Sat May 19 12:01:49 2018 +0200 lib/smokey: enable test filtering with --list[=expr] --- lib/smokey/init.c | 91 +++-- 1 file changed, 47 insertions(+), 44 deletions(-) diff --git a/lib/smokey/init.c b/lib/smokey/init.c index 9df9a55..e1a133e 100644 --- a/lib/smokey/init.c +++ b/lib/smokey/init.c @@ -143,11 +143,13 @@ * Any program linked against the Smokey API implicitly recognizes the * following options: * - * - --list dumps the list of tests implemented in the program to - * stdout. The information given includes the description strings - * provided in the plugin declarators (smokey_test_plugin()). The - * position and symbolic name of each test is also issued, which may - * be used in id specifications with the --run option (see below). + * - --list[=] dumps the list of tests implemented in the + * program to stdout. This list may be restricted to the tests + * matching the optional regular expression (see --run). The + * information given includes the description strings provided in + * the plugin declarators (smokey_test_plugin()). The position and + * symbolic name of each test is also issued, which may be used in + * id specifications with the --run option (see below). * * @note Test positions may vary depending on changes to the host * program like adding or removing other tests, the symbolic name @@ -297,7 +299,7 @@ static const struct option smokey_options[] = { { #define list_opt 2 .name = "list", - .has_arg = no_argument, + .has_arg = optional_argument, .flag = &do_list, .val = 1, }, @@ -319,13 +321,13 @@ static const struct option smokey_options[] = { static void smokey_help(void) { fprintf(stderr, "--keep-going don't stop upon test error\n"); - fprintf(stderr, "--list list all tests\n"); + fprintf(stderr, "--list[=]] list [matching] tests\n"); fprintf(stderr, "--run[=]] run [portion of] the test list\n"); fprintf(stderr, "--exclude=]exclude test(s) from the run list\n"); fprintf(stderr, "--vm hint about running in a virtual environment\n"); } -static void pick_test_range(int start, int end) +static void pick_test_range(struct pvlistobj *dst, int start, int end) { struct smokey_test *t, *tmp; @@ -336,7 +338,7 @@ static void pick_test_range(int start, int end) if (t->__reserved.id >= start && t->__reserved.id <= end) { pvlist_remove(&t->__reserved.next); - pvlist_append(&t->__reserved.next, &smokey_test_list); + pvlist_append(&t->__reserved.next, dst); } } } else { @@ -344,13 +346,13 @@ static void pick_test_range(int start, int end) if (t->__reserved.id >= end && t->__reserved.id <= start) { pvlist_remove(&t->__reserved.next); - pvlist_append(&t->__reserved.next, &smokey_test_list); + pvlist_append(&t->__reserved.next, dst); } } } } -static void drop_test_range(int start, int end) +static void drop_test_range(struct pvlistobj *dst, int start, int end) { struct smokey_test *t, *tmp; @@ -363,7 +365,7 @@ static void drop_test_range(int start, int end) if (t->__reserved.id >= start && t->__reserved.id <= end) { pvlist_remove(&t->__reserved.next); - pvlist_append(&t->__reserved.next, &exclude_list); + pvlist_append(&t->__reserved.next, dst); } } } @@ -376,8 +378,8 @@ static int resolve_id(const char *s) return atoi(s); /* -* CAUTION: as we transfer items from register_list to -* smokey_test_list, we may end up with an empty source list, +* CAUTION: as we transfer items from register_list to a +* destination list, we may end up with an empty source list, * which is a perfectly valid situation. Unlike having an * empty registration list at startup, which would mean that * no test is available from the current program. @@ -392,7 +394,7 @@ static int resolve_id(const char *s) return -1; } -static int do_glob_match(const char *s, struct pvlistobj *list) +static int glob_match(struct pvlistobj *dst, const char *s) { struct smokey_t