All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 1/3] selftests: harness: run the fixture teardown after a failed ASSERT
Date: Fri, 13 Nov 2026 06:19:58 +0200	[thread overview]
Message-ID: <20261113042331.517488-2-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261113042331.517488-1-eva.kurchatova@virtuozzo.com>

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 <eva.kurchatova@virtuozzo.com>
---
 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
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-11-13  4:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-13  4:19 [Devel] [PATCH hci-8.1 0/3] selftests: cgroup: fix test_numa_migrate, inactive_disk_file Eva Kurchatova
2026-11-13  4:19 ` Eva Kurchatova [this message]
2026-11-13  4:28   ` [Devel] [PATCH hci-8.1 1/3] selftests: harness: run the fixture teardown after a failed ASSERT no-reply
2026-11-13 19:57   ` Konstantin Khorenko
2026-11-13  4:19 ` [Devel] [PATCH hci-8.1 2/3] selftests: cgroup: mark the pages cold before numa_migrate starts Eva Kurchatova
2026-11-13  4:27   ` no-reply
2026-11-13 19:57   ` Konstantin Khorenko
2026-11-13  4:20 ` [Devel] [PATCH hci-8.1 3/3] selftests: cgroup: populate the inactive file with read faults Eva Kurchatova
2026-11-13  4:28   ` no-reply
2026-11-13 19:57   ` Konstantin Khorenko
2026-11-13 19:57 ` [Devel] [PATCH hci-8.1 0/3] selftests: cgroup: fix test_numa_migrate, inactive_disk_file Konstantin Khorenko
2026-11-13 19:59 ` Konstantin Khorenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261113042331.517488-2-eva.kurchatova@virtuozzo.com \
    --to=eva.kurchatova@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.