From: Danish Khateeb <danishkhateeb03@gmail.com>
To: "Willy Tarreau" <w@1wt.eu>, "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Danish Khateeb <danishkhateeb03@gmail.com>
Subject: [PATCH 2/2] selftests/nolibc: add tests for the wait status macros
Date: Wed, 23 Sep 2026 15:56:22 -0500 [thread overview]
Message-ID: <20260923205622.1123270-3-danishkhateeb03@gmail.com> (raw)
In-Reply-To: <20260923205622.1123270-1-danishkhateeb03@gmail.com>
Until the previous commit, WIFSIGNALED() was true for status 0, which is
what waitpid() reports for a child that exits with 0. nolibc-test did not
notice, because its only use of WIFSIGNALED(), in the abort test, also
checks WTERMSIG().
Add tests for WEXITSTATUS(), WIFEXITED(), WIFSIGNALED() and WTERMSIG(),
on the statuses the kernel reports for an exit with 0 or 0x12, a kill by
SIGKILL, a SIGSEGV with the core dump flag, and a stop by SIGSTOP.
Assisted-by: LLM
Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>
---
tools/testing/selftests/nolibc/nolibc-test.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
index f62183a46205..8985aa1ba96a 100644
--- a/tools/testing/selftests/nolibc/nolibc-test.c
+++ b/tools/testing/selftests/nolibc/nolibc-test.c
@@ -2038,6 +2038,14 @@ int run_stdlib(int min, int max)
CASE_TEST(htole32); EXPECT_EQ(1, htole32(is_le ? 0x01234567 : 0x67452301), 0x01234567); break;
CASE_TEST(htobe64); EXPECT_EQ(1, htobe64(is_le ? 0x0123456789000000 : 0x8967452301), 0x8967452301); break;
CASE_TEST(htole64); EXPECT_EQ(1, htole64(is_le ? 0x0123456789 : 0x8967452301000000), 0x0123456789); break;
+ CASE_TEST(wexitstatus); EXPECT_EQ(1, WEXITSTATUS(0x1200), 0x12); break;
+ CASE_TEST(wifexited_exit0); EXPECT_NZ(1, WIFEXITED(0)); break;
+ CASE_TEST(wifexited_signal); EXPECT_ZR(1, WIFEXITED(SIGKILL)); break;
+ CASE_TEST(wifsignaled_exit0); EXPECT_ZR(1, WIFSIGNALED(0)); break;
+ CASE_TEST(wifsignaled_exit); EXPECT_ZR(1, WIFSIGNALED(0x1200)); break;
+ CASE_TEST(wifsignaled_signal); EXPECT_NZ(1, WIFSIGNALED(SIGKILL)); break;
+ CASE_TEST(wifsignaled_stopped); EXPECT_ZR(1, WIFSIGNALED((SIGSTOP << 8) | 0x7f)); break;
+ CASE_TEST(wtermsig_core); EXPECT_EQ(1, WTERMSIG(0x80 | SIGSEGV), SIGSEGV); break;
case __LINE__:
return ret; /* must be last */
--
2.55.0
next prev parent reply other threads:[~2026-09-23 20:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 20:56 [PATCH 0/2] tools/nolibc: fix WIFSIGNALED() for status 0 Danish Khateeb
2026-09-23 20:56 ` [PATCH 1/2] " Danish Khateeb
2026-09-23 20:56 ` Danish Khateeb [this message]
2026-09-24 8:41 ` [PATCH 0/2] " Thomas Weißschuh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923205622.1123270-3-danishkhateeb03@gmail.com \
--to=danishkhateeb03@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=shuah@kernel.org \
--cc=w@1wt.eu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®