On 21.07.23 16:16, 'Earl Chew' via EFI Boot Guard wrote:
> 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 {

Indention is off.

> +             srunner_run_all(sr, CK_NORMAL);
> +             number_failed = srunner_ntests_failed(sr);
> +             srunner_free(sr);
> +     }
>  
>       return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
>  }

Will that prevent calling the test suite with CK_FORK=no
(https://libcheck.github.io/check/doc/check_html/check_4.html#No-Fork-Mode)?

But I'm also not yet getting what this brings us. It only checks if
forking mode is on, right? But the commit message says that this allows
to simplify the tests - where are these simplifications?

Jan

-- 
Siemens AG, Technology
Linux Expert Center

-- 
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/30b5939a-b357-46ee-f5d2-a0855f705a37%40siemens.com.

Reply via email to