aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-02-11 16:40:10 +0200
committerSimon Glass <sjg@chromium.org>2021-04-29 03:23:39 -0700
commitff232a72969567cd0339d4f96fa0b1840bef500e (patch)
treecce0d119eba70306668877a132b7eba168dcc820 /test
parent170732523bad74cd3a19c3993ba06c789c843ccf (diff)
downloadu-boot-ff232a72969567cd0339d4f96fa0b1840bef500e.zip
u-boot-ff232a72969567cd0339d4f96fa0b1840bef500e.tar.gz
u-boot-ff232a72969567cd0339d4f96fa0b1840bef500e.tar.bz2
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>
Diffstat (limited to 'test')
-rw-r--r--test/test-main.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/test/test-main.c b/test/test-main.c
index 8c852d7..1824cce 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;