Re: [PATCH v3 12/32] selftests: harness: Stop using setjmp()/longjmp()

From: Mark Brown
Date: Mon May 05 2025 - 06:50:42 EST


On Fri, Apr 11, 2025 at 11:00:36AM +0200, Thomas Weißschuh wrote:
> Usage of longjmp() was added to ensure that teardown is always run in
> commit 63e6b2a42342 ("selftests/harness: Run TEARDOWN for ASSERT failures")
> However instead of calling longjmp() to the teardown handler it is easier to
> just call the teardown handler directly from __bail().
> Any potential duplicate teardown invocations are harmless as the actual
> handler will only ever be executed once since
> commit fff37bd32c76 ("selftests/harness: Fix fixture teardown").

I didn't fully verify (I'm on holiday right now) but it looks like this,
which is in -next as 8a37733a874f:

> @@ -757,7 +749,7 @@
> */
> #define OPTIONAL_HANDLER(_assert) \
> for (; _metadata->trigger; _metadata->trigger = \
> - __bail(_assert, _metadata))
> + __bail(_assert, _metadata, self, variant))
>
> #define is_signed_type(var) (!!(((__typeof__(var))(-1)) < (__typeof__(var))1))
>

breaks the build of several selftests when building for arm64:

In file included from seccomp_bpf.c:56:
seccomp_bpf.c: In function ‘kill_thread_or_group’:
../kselftest_harness.h:755:52: error: ‘self’ undeclared (first use in this function)
755 | __bail(_assert, _metadata, self, variant))
| ^~~~
../kselftest_harness.h:803:14: note: in expansion of macro ‘OPTIONAL_HANDLER’
803 | } while (0); OPTIONAL_HANDLER(_assert)
| ^~~~~~~~~~~~~~~~
../kselftest_harness.h:516:9: note: in expansion of macro ‘__EXPECT’
516 | __EXPECT(expected, #expected, seen, #seen, ==, 1)
| ^~~~~~~~
seccomp_bpf.c:844:9: note: in expansion of macro ‘ASSERT_EQ’
844 | ASSERT_EQ(0, prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) {
| ^~~~~~~~~

Full build log at:

https://builds.sirena.org.uk/407f60a151df3c44397e5afc0111eb9b026c38d3/arm64/defconfig/build.log

Attachment: signature.asc
Description: PGP signature