]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
test: Move stat-printing into its own function
authorSimon Glass <sjg@chromium.org>
Mon, 20 Jan 2025 21:26:01 +0000 (14:26 -0700)
committerTom Rini <trini@konsulko.com>
Fri, 24 Jan 2025 20:34:41 +0000 (14:34 -0600)
Add a function to show the stats, so we can decide when to print it.

This slightly adjusts the output, so that any 'test not found' message
appears on its own line after all other output.

The 'failures' message now appears in lower case so update pytest
accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/spl.c
include/test/ut.h
test/py/tests/test_spl.py
test/py/tests/test_upl.py
test/py/tests/test_ut.py
test/py/tests/test_vbe.py
test/py/tests/test_vpl.py
test/test-main.c

index 0ad23e4ba95b3aa17e940a8b426fb6cb989255e1..ecc03785463eb589e03e7099e238c416c07f924b 100644 (file)
@@ -153,6 +153,7 @@ void spl_board_init(void)
                ut_init_state(&uts);
                ret = ut_run_list(&uts, "spl", NULL, tests, count,
                                  state->select_unittests, 1, false, NULL);
+               ut_report(&uts.cur, 1);
                ut_uninit_state(&uts);
                /* continue execution into U-Boot */
        }
index a51defc3b90333c7ad39cebd60688e9b8b2f3f0d..be5502e03a19cf2c2f5072cc7d91ca40608aabd3 100644 (file)
@@ -530,4 +530,12 @@ int ut_run_list(struct unit_test_state *uts, const char *category,
                const char *select_name, int runs_per_test, bool force_run,
                const char *test_insert);
 
+/**
+ * ut_report() - Report stats on a test run
+ *
+ * @stats: Stats to show
+ * @run_count: Number of suites that were run
+ */
+void ut_report(struct ut_stats *stats, int run_count);
+
 #endif
index 42e4c4342b23c4fc7c5b3b3897e70fb8f3f6058f..474f430a344f84df299c07dca011a16946bedd2d 100644 (file)
@@ -36,7 +36,7 @@ def test_spl(u_boot_console, ut_spl_subtest):
         cons = u_boot_console
         cons.restart_uboot_with_flags(['-u', '-k', ut_spl_subtest.split()[1]])
         output = cons.get_spawn_output().replace('\r', '')
-        assert 'Failures: 0' in output
+        assert 'failures: 0' in output
     finally:
         # Restart afterward in case a non-SPL test is run next. This should not
         # happen since SPL tests are run in their own invocation of test.py, but
index 3164bda6b717b7fea682df7898e9e07e2d207d8c..d94359d8b9bdec6a2e3ed5155058c03833cc441d 100644 (file)
@@ -35,4 +35,4 @@ def test_upl_handoff(u_boot_console):
 
     # Check the FIT offsets look correct
     output = cons.run_command('ut upl -f upl_test_info_norun')
-    assert 'Failures: 0' in output
+    assert 'failures: 0' in output
index cacf11f7c0a111ce7bc822f16529152e75cc453a..d2d8ce10755b992d52d39dbd7bafda3b795be992 100644 (file)
@@ -607,4 +607,4 @@ def test_ut(u_boot_console, ut_subtest):
         assert 'Unknown command \'quux\' - try \'help\'' in output
     else:
         output = u_boot_console.run_command('ut ' + ut_subtest)
-    assert output.endswith('Failures: 0')
+    assert output.endswith('failures: 0')
index 50b6c1cd9112067d88b6ab93a60e557e43a62b25..861df3f8266443da4134d4275e3d88393fcdd7c2 100644 (file)
@@ -117,4 +117,4 @@ def test_vbe(u_boot_console):
     with cons.log.section('Kernel load'):
         output = cons.run_command_list(cmd.splitlines())
 
-    assert 'Failures: 0' in output[-1]
+    assert 'failures: 0' in output[-1]
index 4af578b91732181c29d67b2521737b2b879073a0..8c472ca7a922fdd7d8d1ba9b4433dfe4328036d3 100644 (file)
@@ -26,7 +26,7 @@ def test_vpl(u_boot_console, ut_vpl_subtest):
         cons = u_boot_console
         cons.restart_uboot_with_flags(['-u', '-k', ut_vpl_subtest.split()[1]])
         output = cons.get_spawn_output().replace('\r', '')
-        assert 'Failures: 0' in output
+        assert 'failures: 0' in output
     finally:
         # Restart afterward in case a non-VPL test is run next. This should not
         # happen since VPL tests are run in their own invocation of test.py, but
index e36bc37d29eb608bb5aa87f07bd8fc13c9ec31d3..d02ab791b5aed07c3143e09f500403c52a6aa6e9 100644 (file)
@@ -673,6 +673,18 @@ static int ut_run_tests(struct unit_test_state *uts, const char *prefix,
        return uts->cur.fail_count ? -EBADF : 0;
 }
 
+void ut_report(struct ut_stats *stats, int run_count)
+{
+       if (run_count > 1)
+               printf("Suites run: %d, total tests", run_count);
+       else
+               printf("Tests");
+       printf(" run: %d, ", stats->test_count);
+       if (stats->skip_count)
+               printf("skipped: %d, ", stats->skip_count);
+       printf("failures: %d\n", stats->fail_count);
+}
+
 int ut_run_list(struct unit_test_state *uts, const char *category,
                const char *prefix, struct unit_test *tests, int count,
                const char *select_name, int runs_per_test, bool force_run,
@@ -718,13 +730,9 @@ int ut_run_list(struct unit_test_state *uts, const char *category,
        if (has_dm_tests)
                dm_test_restore(uts->of_root);
 
-       printf("Tests run: %d, ", uts->cur.test_count);
-       if (uts->cur.skip_count)
-               printf("Skipped: %d, ", uts->cur.skip_count);
+       ut_report(&uts->cur, 1);
        if (ret == -ENOENT)
                printf("Test '%s' not found\n", select_name);
-       else
-               printf("Failures: %d\n", uts->cur.fail_count);
 
        return ret;
 }