selftests/nolibc: exit with poweroff on success when getpid() == 1
authorWilly Tarreau <w@1wt.eu>
Tue, 19 Jul 2022 21:44:40 +0000 (23:44 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Wed, 31 Aug 2022 12:17:44 +0000 (05:17 -0700)
commitf49896d7d9a69b7565a59f5085c78ca1c08c7dd7
tree08606a2034c261aee42c2c3fcbb5b6b218140221
parent95bc989488eb7150949cf2fcce3f486741d1c57f
selftests/nolibc: exit with poweroff on success when getpid() == 1

The idea is to ease automated testing under qemu. If the test succeeds
while running as PID 1, indicating the system was booted with init=/test,
let's just power off so that qemu can exit with a successful code. In
other situations it will exit and provoke a panic, which may be caught
for example with CONFIG_PVPANIC.

Signed-off-by: Willy Tarreau <w@1wt.eu>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
tools/testing/selftests/nolibc/nolibc-test.c