Jan,
I think I might have to revise the commit message, but let's sort out
the details here first.
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)?
I have libcheck compiled with CF_FORK=no, and discovered that the tests
would not pass.
I figure the tests have been written assuming CF_FORK=yes, and 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.
The point of this commit is to expose this implicit assumption as an
explicit test.
What do you think?
Earl
On 2023-07-21 10:42, Jan Kiszka wrote:
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
--
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/ea6d3af5-afd6-21a9-a707-a66ae3e441e1%40yahoo.com.