diff --git a/test/test-main.c b/test/test-main.c index 8c852d72f4..1824cce2a6 100644 --- a/test/test-main.c +++ b/test/test-main.c @@ -135,10 +135,17 @@ static bool ut_test_run_on_flattree(struct unit_test *test) static bool test_matches(const char *prefix, const char *test_name, const char *select_name) { + size_t len; + if (!select_name) return true; - if (!strcmp(test_name, select_name)) + /* Allow glob expansion in the test name */ + len = select_name[strlen(select_name) - 1] == '*' ? strlen(select_name) : 0; + if (len-- == 1) + return true; + + if (!strncmp(test_name, select_name, len)) return true; if (!prefix) { @@ -153,7 +160,7 @@ static bool test_matches(const char *prefix, const char *test_name, test_name += strlen(prefix); } - if (!strcmp(test_name, select_name)) + if (!strncmp(test_name, select_name, len)) return true; return false;