Some tests modify global variables which are then reused in subsequent tests. With fork() support, modifications are contained within the child process, allowing the parent to run the next test without having to reinitialise global state.
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..11a4c2f 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/20230721141600.1967250-1-earl_chew%40yahoo.com.
