[PATCH 2/2] selftests: riscv: vector: Fix the check for children exiting with -1

From: Danish Khateeb

Date: Sat Sep 26 2026 - 12:01:47 EST


vstate_exec_nolibc and launch_test() look for a child which failed with
exit(-1) by checking WEXITSTATUS(status) == -1. But WEXITSTATUS() only
returns the low 8 bits of the exit code, so the check never matches.

vstate_exec_nolibc then returns ctrl as if the child had succeeded,
which is the value the harness expects. So when a child finds that its
vstate_ctrl differs from its parent's, it prints an error, but the test
still passes.

Compare the exit status with 255 instead. A successful child exits with
its vstate_ctrl, which is at most 0x1f. launch_test() already failed
the test on 255, but now reports it as an abnormal exit.

Fixes: 7cf6198ce22d ("selftests: Test RISC-V Vector prctl interface")
Assisted-by: LLM
Signed-off-by: Danish Khateeb <danishkhateeb03@xxxxxxxxx>
---
tools/testing/selftests/riscv/vector/v_helpers.c | 2 +-
tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/riscv/vector/v_helpers.c b/tools/testing/selftests/riscv/vector/v_helpers.c
index de6da7c8d2f1..8942ddf2b52b 100644
--- a/tools/testing/selftests/riscv/vector/v_helpers.c
+++ b/tools/testing/selftests/riscv/vector/v_helpers.c
@@ -81,7 +81,7 @@ int launch_test(char *next_program, int test_inherit, int xtheadvector)
return -3;
}

- if ((WIFEXITED(status) && WEXITSTATUS(status) == -1) ||
+ if ((WIFEXITED(status) && WEXITSTATUS(status) == 255) ||
WIFSIGNALED(status)) {
printf("child exited abnormally\n");
return -4;
diff --git a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
index 5f53e5e8ac52..05f18b13a36a 100644
--- a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
+++ b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
exit(-1);
}

- if (WIFEXITED(status) && WEXITSTATUS(status) == -1) {
+ if (WIFEXITED(status) && WEXITSTATUS(status) == 255) {
puts("child exited abnormally\n");
exit(-1);
}
--
2.55.0