The tests will not pass if libcheck is compiled with CF_FORK=no because they have been written assuming CF_FORK=yes. Each test inherits a pristine copy of global state in the forked child process. Mutations of global state by the child process are not propagated forward to the next test.
This commit exposes the implicit assumption of CF_FORK=yes as an explicit test. Signed-off-by: Earl Chew <[email protected]> --- tools/tests/test_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/tests/test_main.c b/tools/tests/test_main.c index 73b42d1..6111f91 100644 --- a/tools/tests/test_main.c +++ b/tools/tests/test_main.c @@ -13,6 +13,7 @@ */ #include <stdlib.h> +#include <stdio.h> #include <check.h> #include <fff.h> @@ -20,7 +21,7 @@ extern Suite *ebg_test_suite(void); int main(void) { - int number_failed; + int number_failed = 1; Suite *s; SRunner *sr; @@ -28,9 +29,13 @@ int main(void) s = ebg_test_suite(); sr = srunner_create(s); - srunner_run_all(sr, CK_NORMAL); - number_failed = srunner_ntests_failed(sr); - srunner_free(sr); + if (srunner_fork_status(sr) != CK_FORK) { + fprintf(stderr, "Tests assume fork() support"); + } else { + srunner_run_all(sr, CK_NORMAL); + number_failed = srunner_ntests_failed(sr); + srunner_free(sr); + } return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; } -- 2.39.1 -- You received this message because you are subscribed to the Google Groups "EFI Boot Guard" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/efibootguard-dev/20230722153447.2381228-1-earl_chew%40yahoo.com.
