"Das U-Boot" Source Tree

test: Move stat-printing into its own function

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>

authored by

Simon Glass and committed by
Tom Rini
15c39587 561320be

+27 -10
+1
arch/sandbox/cpu/spl.c
··· 153 153 ut_init_state(&uts); 154 154 ret = ut_run_list(&uts, "spl", NULL, tests, count, 155 155 state->select_unittests, 1, false, NULL); 156 + ut_report(&uts.cur, 1); 156 157 ut_uninit_state(&uts); 157 158 /* continue execution into U-Boot */ 158 159 }
+8
include/test/ut.h
··· 530 530 const char *select_name, int runs_per_test, bool force_run, 531 531 const char *test_insert); 532 532 533 + /** 534 + * ut_report() - Report stats on a test run 535 + * 536 + * @stats: Stats to show 537 + * @run_count: Number of suites that were run 538 + */ 539 + void ut_report(struct ut_stats *stats, int run_count); 540 + 533 541 #endif
+1 -1
test/py/tests/test_spl.py
··· 36 36 cons = u_boot_console 37 37 cons.restart_uboot_with_flags(['-u', '-k', ut_spl_subtest.split()[1]]) 38 38 output = cons.get_spawn_output().replace('\r', '') 39 - assert 'Failures: 0' in output 39 + assert 'failures: 0' in output 40 40 finally: 41 41 # Restart afterward in case a non-SPL test is run next. This should not 42 42 # happen since SPL tests are run in their own invocation of test.py, but
+1 -1
test/py/tests/test_upl.py
··· 35 35 36 36 # Check the FIT offsets look correct 37 37 output = cons.run_command('ut upl -f upl_test_info_norun') 38 - assert 'Failures: 0' in output 38 + assert 'failures: 0' in output
+1 -1
test/py/tests/test_ut.py
··· 607 607 assert 'Unknown command \'quux\' - try \'help\'' in output 608 608 else: 609 609 output = u_boot_console.run_command('ut ' + ut_subtest) 610 - assert output.endswith('Failures: 0') 610 + assert output.endswith('failures: 0')
+1 -1
test/py/tests/test_vbe.py
··· 117 117 with cons.log.section('Kernel load'): 118 118 output = cons.run_command_list(cmd.splitlines()) 119 119 120 - assert 'Failures: 0' in output[-1] 120 + assert 'failures: 0' in output[-1]
+1 -1
test/py/tests/test_vpl.py
··· 26 26 cons = u_boot_console 27 27 cons.restart_uboot_with_flags(['-u', '-k', ut_vpl_subtest.split()[1]]) 28 28 output = cons.get_spawn_output().replace('\r', '') 29 - assert 'Failures: 0' in output 29 + assert 'failures: 0' in output 30 30 finally: 31 31 # Restart afterward in case a non-VPL test is run next. This should not 32 32 # happen since VPL tests are run in their own invocation of test.py, but
+13 -5
test/test-main.c
··· 673 673 return uts->cur.fail_count ? -EBADF : 0; 674 674 } 675 675 676 + void ut_report(struct ut_stats *stats, int run_count) 677 + { 678 + if (run_count > 1) 679 + printf("Suites run: %d, total tests", run_count); 680 + else 681 + printf("Tests"); 682 + printf(" run: %d, ", stats->test_count); 683 + if (stats->skip_count) 684 + printf("skipped: %d, ", stats->skip_count); 685 + printf("failures: %d\n", stats->fail_count); 686 + } 687 + 676 688 int ut_run_list(struct unit_test_state *uts, const char *category, 677 689 const char *prefix, struct unit_test *tests, int count, 678 690 const char *select_name, int runs_per_test, bool force_run, ··· 718 730 if (has_dm_tests) 719 731 dm_test_restore(uts->of_root); 720 732 721 - printf("Tests run: %d, ", uts->cur.test_count); 722 - if (uts->cur.skip_count) 723 - printf("Skipped: %d, ", uts->cur.skip_count); 733 + ut_report(&uts->cur, 1); 724 734 if (ret == -ENOENT) 725 735 printf("Test '%s' not found\n", select_name); 726 - else 727 - printf("Failures: %d\n", uts->cur.fail_count); 728 736 729 737 return ret; 730 738 }