aboutsummaryrefslogtreecommitdiffstats
path: root/test/test-main.c
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-03-07 17:35:12 -0700
committerTom Rini <trini@konsulko.com>2021-03-12 09:57:31 -0500
commit8482356f48c96eb49f1bd9efd53c887d09a1cf64 (patch)
tree901aeec297da03af8910e0790edf48d060d4807d /test/test-main.c
parent2a2814d5f2714a7b0aef9ea7f9d8d67a34875d55 (diff)
downloadu-boot-8482356f48c96eb49f1bd9efd53c887d09a1cf64.tar.gz
test: Allow SPL to run any available test
At present SPL only runs driver model tests. Update it to run all available tests, i.e. in any test suite. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'test/test-main.c')
-rw-r--r--test/test-main.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/test/test-main.c b/test/test-main.c
index 6edd49f0b61..e1b49e091ab 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -119,7 +119,8 @@ static bool ut_test_run_on_flattree(struct unit_test *test)
*
* @prefix: String prefix for the tests. Any tests that have this prefix will be
* printed without the prefix, so that it is easier to see the unique part
- * of the test name. If NULL, no prefix processing is done
+ * of the test name. If NULL, any suite name (xxx_test) is considered to be
+ * a prefix.
* @test_name: Name of current test
* @select_name: Name of test to run (or NULL for all)
* @return true to run this test, false to skip it
@@ -133,9 +134,17 @@ static bool test_matches(const char *prefix, const char *test_name,
if (!strcmp(test_name, select_name))
return true;
- /* All tests have this prefix */
- if (prefix && !strncmp(test_name, prefix, strlen(prefix)))
- test_name += strlen(prefix);
+ if (!prefix) {
+ const char *p = strstr(test_name, "_test_");
+
+ /* convert xxx_test_yyy to yyy, i.e. remove the suite name */
+ if (p)
+ test_name = p + 6;
+ } else {
+ /* All tests have this prefix */
+ if (!strncmp(test_name, prefix, strlen(prefix)))
+ test_name += strlen(prefix);
+ }
if (!strcmp(test_name, select_name))
return true;