path: root/lib/tests/igt_subtest_group.c
diff options
authorArkadiusz Hiler <>2019-05-08 08:59:30 +0300
committerArkadiusz Hiler <>2019-05-10 10:58:54 +0300
commita269c21fc3d52ab502aa5cf98e47aca6520e5a37 (patch)
treeef3b86c4db2e695dcf356d2dffda0f474f76aba4 /lib/tests/igt_subtest_group.c
parent615c7566c9753722d9b5fe0422e8e188ad91f2ba (diff)
lib/tests/igt_subtest_group: Operate within defined behavior
Quoting lib/igt_core.c: * - Code blocks with magic control flow are implemented with setjmp() and * longjmp(). This applies to #igt_fixture and #igt_subtest blocks and all the * three variants to finish test: igt_success(), igt_skip() and igt_fail(). * Mostly this is of no concern, except when such a control block changes * stack variables defined in the same function as the control block resides. * Any store/load behaviour after a longjmp() is ill-defined for these * variables. Avoid such code. * * Quoting the man page for longjmp(): * * "The values of automatic variables are unspecified after a call to * longjmp() if they meet all the following criteria:" * - "they are local to the function that made the corresponding setjmp() call; * - "their values are changed between the calls to setjmp() and longjmp(); and * - "they are not declared as volatile." igt_subtest_group test uses two local variables for tracking the state of execution, making sure that skips are working correctly. We can just make them volatile to be back on the defined grounds. v2: comment on the volatiles as suggested by Simon Ser Cc: Simon Ser <> Cc: Daniel Vetter <> Signed-off-by: Arkadiusz Hiler <> Reviewed-by: Petri Latvala <> Reviewed-by: Simon Ser <>
Diffstat (limited to 'lib/tests/igt_subtest_group.c')
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/tests/igt_subtest_group.c b/lib/tests/igt_subtest_group.c
index 7783d021..973a30e4 100644
--- a/lib/tests/igt_subtest_group.c
+++ b/lib/tests/igt_subtest_group.c
@@ -28,8 +28,13 @@
- bool t1 = false;
- int t2 = 0;
+ /*
+ * local variables have to be volatile here otherwise they end up being
+ * undefined when modified in igt_subtest, fixture, etc. because of
+ * longjmps
+ */
+ volatile bool t1 = false;
+ volatile int t2 = 0;
igt_subtest_group {
igt_fixture {