]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/powerpc: Don't rely on segfault to rerun the test
authorGustavo Luiz Duarte <gustavold@linux.ibm.com>
Tue, 11 Feb 2020 03:38:31 +0000 (00:38 -0300)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 25 Mar 2020 01:06:30 +0000 (12:06 +1100)
commitecae56cd102ee8d8ec9536e42641385400a98b4b
tree74666d64331a65f96e26716957162f185e777553
parent7223413b01cec0ff3137f3f34f4bb3b664383c86
selftests/powerpc: Don't rely on segfault to rerun the test

The test case tm-signal-context-force-tm expects a segfault to happen
on returning from signal handler, and then does a setcontext() to run
the test again. However, the test doesn't always segfault, causing the
test to run a single time.

This patch fixes the test by putting it within a loop and jumping, via
setcontext, just prior to the loop in case it segfaults. This way we
get the desired behavior (run the test COUNT_MAX times) regardless if
it segfaults or not. This also reduces the use of setcontext for
control flow logic, keeping it only in the segfault handler.

Also, since 'count' is changed within the signal handler, it is
declared as volatile to prevent any compiler optimization getting
confused with asynchronous changes.

Signed-off-by: Gustavo Luiz Duarte <gustavold@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200211033831.11165-3-gustavold@linux.ibm.com
tools/testing/selftests/powerpc/tm/tm-signal-context-force-tm.c