From ffdd3b36cd90ad3f4e199344d20c00fb06762eb2 Mon Sep 17 00:00:00 2001 From: Petr Vorel Date: Mon, 11 Nov 2024 15:17:55 +0100 Subject: [PATCH] syscalls: Add missing exit status check Check exit code via WEXITSTATUS(). Also in madvise08 change exit code to 0 (1 may confuse people into thinking that the return value actually carries any information, which it does not since the failure has been already reported. 0 makes it more clear that we just need to exit the process, nothing more.) Link: https://lore.kernel.org/ltp/20241111143609.185692-1-pvorel@suse.cz/ Reviewed-by: Cyril Hrubis Signed-off-by: Petr Vorel --- testcases/kernel/syscalls/madvise/madvise08.c | 4 ++-- testcases/kernel/syscalls/select/select03.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/testcases/kernel/syscalls/madvise/madvise08.c b/testcases/kernel/syscalls/madvise/madvise08.c index 96bcaf159aa..b8096abef2c 100644 --- a/testcases/kernel/syscalls/madvise/madvise08.c +++ b/testcases/kernel/syscalls/madvise/madvise08.c @@ -165,7 +165,7 @@ static pid_t run_child(int advice) fmem, FMEMSIZE, advstr); - exit(1); + exit(0); } abort(); } @@ -173,7 +173,7 @@ static pid_t run_child(int advice) SAFE_WAITPID(pid, &status, 0); if (WIFSIGNALED(status) && WCOREDUMP(status)) return pid; - if (WIFEXITED(status)) + if (WIFEXITED(status) && !WEXITSTATUS(status)) return 0; tst_res(TCONF, "No coredump produced after signal (%d)", diff --git a/testcases/kernel/syscalls/select/select03.c b/testcases/kernel/syscalls/select/select03.c index 1cec3a4c763..216b22104f0 100644 --- a/testcases/kernel/syscalls/select/select03.c +++ b/testcases/kernel/syscalls/select/select03.c @@ -77,7 +77,7 @@ static void run(unsigned int n) SAFE_WAITPID(pid, &status, 0); - if (WIFEXITED(status)) + if (WIFEXITED(status) && !WEXITSTATUS(status)) return; if (tst_variant == GLIBC_SELECT_VARIANT &&