When an ASSERT fails in a TEST_F(), __bail() longjmp()s back to the
setjmp() in the test wrapper, where the grandchild that ran the test
should see child == 0 and run the fixture teardown. child is a local
that fork() sets after setjmp(), so its value after longjmp() is
indeterminate. With -O2 it comes back as 1, its value at setjmp(): the
grandchild takes the parent's path, skips the teardown and aborts. A
failed test then leaves its cgroups, files or mounts behind, and the
next test can fail on them, as test_cache does on the cgroup that a
failed test_numa_migrate left.

Make the variable volatile, so it keeps the value fork() returned.

Mainline no longer uses setjmp() here since commit 869c788909b9
("selftests: harness: Stop using setjmp()/longjmp()"), which was a
large rewrite, and out of scope for this series.

https://virtuozzo.atlassian.net/browse/VSTOR-154520
Feature: fix selftests

Signed-off-by: Eva Kurchatova <[email protected]>
---
 tools/testing/selftests/kselftest_harness.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kselftest_harness.h 
b/tools/testing/selftests/kselftest_harness.h
index 19b05734b18c..5c46b8a854cf 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -407,7 +407,7 @@
        { \
                /* fixture data is alloced, setup, and torn down per call. */ \
                FIXTURE_DATA(fixture_name) self_private, *self = NULL; \
-               pid_t child = 1; \
+               volatile pid_t child = 1; \
                int status = 0; \
                /* Makes sure there is only one teardown, even when child forks 
again. */ \
                bool *teardown = mmap(NULL, sizeof(*teardown), \
-- 
2.56.0

_______________________________________________
Devel mailing list
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to