test: Leave out the prefix when printing test names
When tests are all in the same suite it is annoying to have to read all
the common text after each name. Skip this to help the user.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/test/cmd_ut.c b/test/cmd_ut.c
index c96277d..0b923ee 100644
--- a/test/cmd_ut.c
+++ b/test/cmd_ut.c
@@ -184,7 +184,7 @@
char prefix[30];
/* use a standard prefix */
- snprintf(prefix, sizeof(prefix), "%s_test", ste->name);
+ snprintf(prefix, sizeof(prefix), "%s_test_", ste->name);
ret = cmd_ut_category(uts, ste->name, prefix, ste->start,
n_ents, argc, argv);
}
diff --git a/test/py/tests/test_suite.py b/test/py/tests/test_suite.py
index 73c1853..ae12730 100644
--- a/test/py/tests/test_suite.py
+++ b/test/py/tests/test_suite.py
@@ -66,11 +66,12 @@
msg = m.group(3)
if DEBUG_ME:
cons.log.info(f"test_name {test_name} msg '{msg}'")
- if msg == ' (flat tree)' and test_name not in tests:
- tests.add(test_name)
+ full_name = f'{cur_suite}.{test_name}'
+ if msg == ' (flat tree)' and full_name not in tests:
+ tests.add(full_name)
test_count += 1
if not msg or 'skipped as it is manual' in msg:
- tests.add(test_name)
+ tests.add(full_name)
test_count += 1
if DEBUG_ME:
cons.log.info(f'test_count {test_count}')
diff --git a/test/test-main.c b/test/test-main.c
index 597afa2..8c0d820 100644
--- a/test/test-main.c
+++ b/test/test-main.c
@@ -514,11 +514,12 @@
* the first call to this function. On exit, @uts->cur.fail_count is
* incremented by the number of failures (0, one hopes)
* @test: Test to run
+ * @leaf: Part of the name to show, or NULL to use test->name
* Return: 0 if all tests passed, -EAGAIN if the test should be skipped, -1 if
* any failed
*/
static int ut_run_test_live_flat(struct unit_test_state *uts,
- struct unit_test *test)
+ struct unit_test *test, const char *leaf)
{
int runs, ret;
@@ -530,7 +531,7 @@
if (CONFIG_IS_ENABLED(OF_LIVE)) {
if (!(test->flags & UTF_FLAT_TREE)) {
uts->of_live = true;
- ret = ut_run_test(uts, test, test->name);
+ ret = ut_run_test(uts, test, leaf ?: test->name);
if (ret != -EAGAIN) {
ut_assertok(ret);
runs++;
@@ -558,7 +559,7 @@
(!runs || ut_test_run_on_flattree(test)) &&
!(gd->flags & GD_FLG_FDT_CHANGED)) {
uts->of_live = false;
- ret = ut_run_test(uts, test, test->name);
+ ret = ut_run_test(uts, test, leaf ?: test->name);
if (ret != -EAGAIN) {
ut_assertok(ret);
runs++;
@@ -594,6 +595,7 @@
struct unit_test *tests, int count,
const char *select_name, const char *test_insert)
{
+ int prefix_len = prefix ? strlen(prefix) : 0;
struct unit_test *test, *one;
int found = 0;
int pos = 0;
@@ -646,7 +648,7 @@
uts->cur.test_count++;
if (one && upto == pos) {
- ret = ut_run_test_live_flat(uts, one);
+ ret = ut_run_test_live_flat(uts, one, NULL);
if (uts->cur.fail_count != old_fail_count) {
printf("Test '%s' failed %d times (position %d)\n",
one->name,
@@ -656,8 +658,11 @@
return -EBADF;
}
+ if (prefix_len && !strncmp(test_name, prefix, prefix_len))
+ test_name = test_name + prefix_len;
+
for (i = 0; i < uts->runs_per_test; i++)
- ret = ut_run_test_live_flat(uts, test);
+ ret = ut_run_test_live_flat(uts, test, test_name);
if (uts->cur.fail_count != old_fail_count) {
printf("Test '%s' failed %d times\n", test_name,
uts->cur.fail_count - old_fail_count);