[PATCH v1] test: Allow simple glob pattern in the test name
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Wed Feb 3 16:32:34 CET 2021
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 at linux.intel.com>
---
test/dm/test-main.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/test/dm/test-main.c b/test/dm/test-main.c
index 69458d62c869..f15527e13d7b 100644
--- a/test/dm/test-main.c
+++ b/test/dm/test-main.c
@@ -129,17 +129,23 @@ static bool dm_test_run_on_flattree(struct unit_test *test)
static bool test_matches(const char *test_name, const char *find_name)
{
- if (!find_name)
+ size_t len = find_name ? strlen(find_name) : 0;
+
+ /* Allow glob expansion in the test name */
+ if (len && find_name[len - 1] == '*')
+ len--;
+
+ if (!len)
return true;
- if (!strcmp(test_name, find_name))
+ if (!strncmp(test_name, find_name, len))
return true;
/* All tests have this prefix */
if (!strncmp(test_name, "dm_test_", 8))
test_name += 8;
- if (!strcmp(test_name, find_name))
+ if (!strncmp(test_name, find_name, len))
return true;
return false;
--
2.30.0
More information about the U-Boot
mailing list