test: Allow simple glob pattern in the test name
When run `ut dm [test name]` allow to use simple pattern to run all tests started with given prefix. For example, to run all ACPI test cases: ut dm acpi* Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
committed by
Simon Glass
parent
170732523b
commit
ff232a7296
@@ -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,
|
static bool test_matches(const char *prefix, const char *test_name,
|
||||||
const char *select_name)
|
const char *select_name)
|
||||||
{
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
if (!select_name)
|
if (!select_name)
|
||||||
return true;
|
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;
|
return true;
|
||||||
|
|
||||||
if (!prefix) {
|
if (!prefix) {
|
||||||
@@ -153,7 +160,7 @@ static bool test_matches(const char *prefix, const char *test_name,
|
|||||||
test_name += strlen(prefix);
|
test_name += strlen(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcmp(test_name, select_name))
|
if (!strncmp(test_name, select_name, len))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user