Patrick Georgi has submitted this change. ( https://review.coreboot.org/c/coreboot/+/57144 )
Change subject: tests: Improve test output readability ......................................................................
tests: Improve test output readability
When running multiple tests, e.g. by using unit-tests target, it is hard to differentiate, which output comes from which file and/or configuration. This patch makes the output easier to analyze and understand by using new wrapper macro cb_run_group_tests(). This macro uses __TEST_NAME__ value (containing test path and Makefile test name) as a group name when calling cmocka group runner.
Example: Test path: tests/lib/ Makefile test name: cbmem_stage_cache-test Test group array name: tests Result: tests/lib/cbmem_stage_cache-test(tests)
Signed-off-by: Jakub Czapiga jacz@semihalf.com Change-Id: I4fd936d00d77cbe2637b857ba03b4a208428ea0d Reviewed-on: https://review.coreboot.org/c/coreboot/+/57144 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Paul Fagerburg pfagerburg@chromium.org Reviewed-by: Julius Werner jwerner@chromium.org --- M Documentation/tutorial/part3.md M tests/Makefile.inc M tests/acpi/acpigen-test.c M tests/commonlib/bsd/helpers-test.c M tests/commonlib/region-test.c M tests/console/routing-test.c M tests/device/ddr4-test.c M tests/device/i2c-test.c M tests/include/tests/test.h M tests/lib/b64_decode-test.c M tests/lib/bootmem-test.c M tests/lib/cbmem_console-test.c M tests/lib/cbmem_stage_cache-test.c M tests/lib/compute_ip_checksum-test.c M tests/lib/coreboot_table-test.c M tests/lib/crc_byte-test.c M tests/lib/dimm_info_util-test.c M tests/lib/edid-test.c M tests/lib/fmap-test.c M tests/lib/hexstrtobin-test.c M tests/lib/imd-test.c M tests/lib/imd_cbmem-test.c M tests/lib/libgcc-test.c M tests/lib/list-test.c M tests/lib/malloc-test.c M tests/lib/memchr-test.c M tests/lib/memcmp-test.c M tests/lib/memcpy-test.c M tests/lib/memmove-test.c M tests/lib/memrange-test.c M tests/lib/memset-test.c M tests/lib/region_file-test.c M tests/lib/rtc-test.c M tests/lib/spd_cache-test.c M tests/lib/stack-test.c M tests/lib/string-test.c M tests/lib/timestamp-test.c M tests/lib/uuid-test.c 38 files changed, 48 insertions(+), 47 deletions(-)
Approvals: build bot (Jenkins): Verified Julius Werner: Looks good to me, approved Paul Fagerburg: Looks good to me, approved
diff --git a/Documentation/tutorial/part3.md b/Documentation/tutorial/part3.md index 7cdf7d9..dc48718 100644 --- a/Documentation/tutorial/part3.md +++ b/Documentation/tutorial/part3.md @@ -381,6 +381,6 @@ cmocka_unit_test(i2c_read_field_test), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } ``` diff --git a/tests/Makefile.inc b/tests/Makefile.inc index 2f73cb3..fa5faab 100644 --- a/tests/Makefile.inc +++ b/tests/Makefile.inc @@ -136,7 +136,8 @@ printf '#endif\n' >> $$@;
$($(1)-objs): TEST_CFLAGS += -I$$(dir $$($(1)-config-file)) \ - -D__$$(shell echo $$($(1)-stage) | tr '[:lower:]' '[:upper:]')__ + -D__$$(shell echo $$($(1)-stage) | tr '[:lower:]' '[:upper:]')__ \ + -D__TEST_NAME__="$(1)"
# Give us a way to distinguish between coreboot source files and test files in code. $($(1)-srcobjs): TEST_CFLAGS += -D__TEST_SRCOBJ__ diff --git a/tests/acpi/acpigen-test.c b/tests/acpi/acpigen-test.c index 369ff29..6bd1d02 100644 --- a/tests/acpi/acpigen-test.c +++ b/tests/acpi/acpigen-test.c @@ -213,5 +213,5 @@ setup_acpigen, teardown_acpigen), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/commonlib/bsd/helpers-test.c b/tests/commonlib/bsd/helpers-test.c index 324c901..6fae331 100644 --- a/tests/commonlib/bsd/helpers-test.c +++ b/tests/commonlib/bsd/helpers-test.c @@ -51,5 +51,5 @@ cmocka_unit_test(test_retry), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/commonlib/region-test.c b/tests/commonlib/region-test.c index fab5961..59f272a 100644 --- a/tests/commonlib/region-test.c +++ b/tests/commonlib/region-test.c @@ -404,5 +404,5 @@ cmocka_unit_test(test_mem_rdev), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/console/routing-test.c b/tests/console/routing-test.c index ea90342..153ca77 100644 --- a/tests/console/routing-test.c +++ b/tests/console/routing-test.c @@ -66,5 +66,5 @@ teardown_console_log_level), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/device/ddr4-test.c b/tests/device/ddr4-test.c index 0a9831d..3ee1e79 100644 --- a/tests/device/ddr4-test.c +++ b/tests/device/ddr4-test.c @@ -37,5 +37,5 @@ cmocka_unit_test(ddr4_speed_mhz_to_mts_test) };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/device/i2c-test.c b/tests/device/i2c-test.c index 2c94230..010b868 100644 --- a/tests/device/i2c-test.c +++ b/tests/device/i2c-test.c @@ -164,5 +164,5 @@ cmocka_unit_test(i2c_write_field_test) };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/include/tests/test.h b/tests/include/tests/test.h index 14dc7c7..523f8fa 100644 --- a/tests/include/tests/test.h +++ b/tests/include/tests/test.h @@ -36,4 +36,11 @@ TEST_SYMBOL(_e##region, _##region + size); \ TEST_SYMBOL(_##region##_size, size)
+/* Wrapper for running cmocka test groups using name provided by build system in __TEST_NAME__ + This should be used instead of cmocka_run_group_tests(). If there is a need to use custom + group name, then please use cmocka_run_group_tests_name(). */ +#define cb_run_group_tests(group_tests, group_setup, group_teardown) \ + cmocka_run_group_tests_name((__TEST_NAME__ "(" #group_tests ")"), group_tests, \ + group_setup, group_teardown) + #endif /* _TESTS_TEST_H */ diff --git a/tests/lib/b64_decode-test.c b/tests/lib/b64_decode-test.c index e6bbca5..631dc15 100644 --- a/tests/lib/b64_decode-test.c +++ b/tests/lib/b64_decode-test.c @@ -57,5 +57,5 @@ cmocka_unit_test(test_b64_decode), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/bootmem-test.c b/tests/lib/bootmem-test.c index b571ccb..6059833 100644 --- a/tests/lib/bootmem-test.c +++ b/tests/lib/bootmem-test.c @@ -411,5 +411,5 @@ cmocka_unit_test(test_bootmem_region_targets_type) };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/cbmem_console-test.c b/tests/lib/cbmem_console-test.c index 604ca7a..fca84a7 100644 --- a/tests/lib/cbmem_console-test.c +++ b/tests/lib/cbmem_console-test.c @@ -118,12 +118,6 @@
int main(void) { -#if ENV_ROMSTAGE_OR_BEFORE - const char *test_name = "cbmem_console-test-romstage"; -#else - const char *test_name = "cbmem_console-test-ramstage"; -#endif - const struct CMUnitTest tests[] = { cmocka_unit_test_teardown(test_cbmemc_init, teardown_cbmemc), cmocka_unit_test_setup_teardown(test_cbmemc_tx_byte, @@ -132,5 +126,5 @@ setup_cbmemc, teardown_cbmemc), };
- return cmocka_run_group_tests_name(test_name, tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/cbmem_stage_cache-test.c b/tests/lib/cbmem_stage_cache-test.c index 24ba095..8a07e6f 100644 --- a/tests/lib/cbmem_stage_cache-test.c +++ b/tests/lib/cbmem_stage_cache-test.c @@ -190,5 +190,5 @@ setup_test, teardown_test), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/compute_ip_checksum-test.c b/tests/lib/compute_ip_checksum-test.c index fb67439..18e7ff0 100644 --- a/tests/lib/compute_ip_checksum-test.c +++ b/tests/lib/compute_ip_checksum-test.c @@ -98,5 +98,5 @@ cmocka_unit_test(test_add_ip_checksums), };
- return cmocka_run_group_tests(tests, setup_test_group, NULL); + return cb_run_group_tests(tests, setup_test_group, NULL); } diff --git a/tests/lib/coreboot_table-test.c b/tests/lib/coreboot_table-test.c index ba3e63d..7668941 100644 --- a/tests/lib/coreboot_table-test.c +++ b/tests/lib/coreboot_table-test.c @@ -493,5 +493,5 @@ teardown_write_tables_test), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/crc_byte-test.c b/tests/lib/crc_byte-test.c index 12934bc..8624942 100644 --- a/tests/lib/crc_byte-test.c +++ b/tests/lib/crc_byte-test.c @@ -296,5 +296,5 @@ cmocka_unit_test(test_crc32_byte_static_data), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/dimm_info_util-test.c b/tests/lib/dimm_info_util-test.c index a698fc5..4b3f979 100644 --- a/tests/lib/dimm_info_util-test.c +++ b/tests/lib/dimm_info_util-test.c @@ -108,5 +108,5 @@ cmocka_unit_test(test_smbios_form_factor_to_spd_mod_type), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/edid-test.c b/tests/lib/edid-test.c index 0da7c61..73ce4ec 100644 --- a/tests/lib/edid-test.c +++ b/tests/lib/edid-test.c @@ -1267,6 +1267,6 @@ teardown_edid_test), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); }
diff --git a/tests/lib/fmap-test.c b/tests/lib/fmap-test.c index 444af5a..044c312 100644 --- a/tests/lib/fmap-test.c +++ b/tests/lib/fmap-test.c @@ -302,5 +302,5 @@ setup_fmap, teardown_fmap), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/hexstrtobin-test.c b/tests/lib/hexstrtobin-test.c index 46ad3df..f096b9b 100644 --- a/tests/lib/hexstrtobin-test.c +++ b/tests/lib/hexstrtobin-test.c @@ -44,5 +44,5 @@ cmocka_unit_test(test_hexstrtobin), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/imd-test.c b/tests/lib/imd-test.c index c2bcf0c..6da1ac9 100644 --- a/tests/lib/imd-test.c +++ b/tests/lib/imd-test.c @@ -759,6 +759,6 @@ cmocka_unit_test(test_imd_cursor_next), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); }
diff --git a/tests/lib/imd_cbmem-test.c b/tests/lib/imd_cbmem-test.c index f857579..1a1756c 100644 --- a/tests/lib/imd_cbmem-test.c +++ b/tests/lib/imd_cbmem-test.c @@ -626,5 +626,5 @@ setup_teardown_test_imd_cbmem), };
- return cmocka_run_group_tests(tests, setup_group_imd_cbmem, teardown_group_imd_cbmem); + return cb_run_group_tests(tests, setup_group_imd_cbmem, teardown_group_imd_cbmem); } diff --git a/tests/lib/libgcc-test.c b/tests/lib/libgcc-test.c index 3bdd145..d089f64 100644 --- a/tests/lib/libgcc-test.c +++ b/tests/lib/libgcc-test.c @@ -128,5 +128,5 @@ cmocka_unit_test(test_clzsi2_with_data), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/list-test.c b/tests/lib/list-test.c index 6688c4fa..309346a 100644 --- a/tests/lib/list-test.c +++ b/tests/lib/list-test.c @@ -125,5 +125,5 @@ };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/malloc-test.c b/tests/lib/malloc-test.c index b70de06..452d74f 100644 --- a/tests/lib/malloc-test.c +++ b/tests/lib/malloc-test.c @@ -164,5 +164,5 @@ cmocka_unit_test_setup(test_calloc_memory_is_zeroed, setup_calloc_test), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/memchr-test.c b/tests/lib/memchr-test.c index 9762b9a..eadabc7 100644 --- a/tests/lib/memchr-test.c +++ b/tests/lib/memchr-test.c @@ -101,5 +101,5 @@ cmocka_unit_test(test_memchr_zero_size), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/memcmp-test.c b/tests/lib/memcmp-test.c index f45b7f4..59ca86c 100644 --- a/tests/lib/memcmp-test.c +++ b/tests/lib/memcmp-test.c @@ -69,5 +69,5 @@ cmocka_unit_test(test_memcmp_zero_size), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/memcpy-test.c b/tests/lib/memcpy-test.c index 842a5f0..f4f6e18 100644 --- a/tests/lib/memcpy-test.c +++ b/tests/lib/memcpy-test.c @@ -192,5 +192,5 @@ setup_test, teardown_test), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/memmove-test.c b/tests/lib/memmove-test.c index a1d33cf..87cace9 100644 --- a/tests/lib/memmove-test.c +++ b/tests/lib/memmove-test.c @@ -245,6 +245,6 @@ setup_test, teardown_test), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); }
diff --git a/tests/lib/memrange-test.c b/tests/lib/memrange-test.c index f9e6056..1bdd62e 100644 --- a/tests/lib/memrange-test.c +++ b/tests/lib/memrange-test.c @@ -629,10 +629,10 @@ cmocka_unit_test(test_memrange_add_resources_filter), };
- return cmocka_run_group_tests_name("Boundary on 4GiB", + return cmocka_run_group_tests_name(__TEST_NAME__"(Boundary on 4GiB)", tests, setup_test_1, NULL) + - cmocka_run_group_tests_name("Boundaries 1 byte from 4GiB", + cmocka_run_group_tests_name(__TEST_NAME__"(Boundaries 1 byte from 4GiB)", tests, setup_test_2, NULL) + - cmocka_run_group_tests_name("Range over 4GiB boundary", + cmocka_run_group_tests_name(__TEST_NAME__"(Range over 4GiB boundary)", tests, setup_test_3, NULL); } diff --git a/tests/lib/memset-test.c b/tests/lib/memset-test.c index 7d888a6..bdc3cb3 100644 --- a/tests/lib/memset-test.c +++ b/tests/lib/memset-test.c @@ -116,5 +116,5 @@ setup_test, teardown_test), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/region_file-test.c b/tests/lib/region_file-test.c index aeeaa4e..98c4eb6 100644 --- a/tests/lib/region_file-test.c +++ b/tests/lib/region_file-test.c @@ -325,7 +325,6 @@ setup_teardown_region_file_test), };
- return cmocka_run_group_tests(tests, - setup_region_file_test_group, - teardown_region_file_test_group); + return cb_run_group_tests(tests, setup_region_file_test_group, + teardown_region_file_test_group); } diff --git a/tests/lib/rtc-test.c b/tests/lib/rtc-test.c index d58011d..e941571 100644 --- a/tests/lib/rtc-test.c +++ b/tests/lib/rtc-test.c @@ -308,5 +308,5 @@ cmocka_unit_test(test_leap_day_secday), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/spd_cache-test.c b/tests/lib/spd_cache-test.c index 4bc0a3d..4f75690 100644 --- a/tests/lib/spd_cache-test.c +++ b/tests/lib/spd_cache-test.c @@ -253,5 +253,5 @@ #endif };
- return cmocka_run_group_tests(tests, setup_spd_cache, teardown_spd_cache); + return cb_run_group_tests(tests, setup_spd_cache, teardown_spd_cache); } diff --git a/tests/lib/stack-test.c b/tests/lib/stack-test.c index bed59aa..1f671f3 100644 --- a/tests/lib/stack-test.c +++ b/tests/lib/stack-test.c @@ -129,5 +129,5 @@ cmocka_unit_test_setup(test_incorrectly_initialized_stack, setup_stack_test), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/string-test.c b/tests/lib/string-test.c index 7718547..0f21747 100644 --- a/tests/lib/string-test.c +++ b/tests/lib/string-test.c @@ -267,5 +267,5 @@ cmocka_unit_test(test_atol), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); } diff --git a/tests/lib/timestamp-test.c b/tests/lib/timestamp-test.c index 8dc103d..ad33ed0 100644 --- a/tests/lib/timestamp-test.c +++ b/tests/lib/timestamp-test.c @@ -131,7 +131,7 @@ };
#if CONFIG(COLLECT_TIMESTAMPS) - return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); #else return 0; #endif diff --git a/tests/lib/uuid-test.c b/tests/lib/uuid-test.c index c6e40f5..6b56842 100644 --- a/tests/lib/uuid-test.c +++ b/tests/lib/uuid-test.c @@ -91,5 +91,5 @@ cmocka_unit_test(test_guid), };
- return cmocka_run_group_tests(tests, NULL, NULL); + return cb_run_group_tests(tests, NULL, NULL); }