[LTP] [PATCH v3 2/5] syscalls/pause01: Extend test to other signals

Ricardo B. Marlière rbm@suse.com
Mon Feb 24 19:53:03 CET 2025


From: Ricardo B. Marlière <rbm@suse.com>

Currently, the test only covers SIGINT. Add more to the mix by
parametrizing the main test function.

Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
 testcases/kernel/syscalls/pause/pause01.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/testcases/kernel/syscalls/pause/pause01.c b/testcases/kernel/syscalls/pause/pause01.c
index d830016a68b77daad4851d7f7d6436c0922de002..1c1b04038de11dc52deb841ad59d5a482345262a 100644
--- a/testcases/kernel/syscalls/pause/pause01.c
+++ b/testcases/kernel/syscalls/pause/pause01.c
@@ -11,35 +11,50 @@
 
 #include "tst_test.h"
 
-static void sig_handler(int sig LTP_ATTRIBUTE_UNUSED)
+static void sig_handler(int signal LTP_ATTRIBUTE_UNUSED)
 {
 }
 
-static void do_child(void)
+static void do_child(int signal)
 {
-	SAFE_SIGNAL(SIGINT, sig_handler);
+	SAFE_SIGNAL(signal, sig_handler);
 	TST_CHECKPOINT_WAKE(0);
 	TST_EXP_FAIL(pause(), EINTR);
 	tst_res(TPASS, "Process resumed from pause()");
 }
 
-static void run(void)
+static void run(int signal)
 {
-	int pid, status;
+	int pid;
 
 	pid = SAFE_FORK();
 	if (!pid) {
-		do_child();
+		do_child(signal);
 		exit(0);
 	}
 
 	TST_CHECKPOINT_WAIT(0);
 	TST_PROCESS_STATE_WAIT(pid, 'S', 0);
-	SAFE_KILL(pid, SIGINT);
+	SAFE_KILL(pid, signal);
+}
+
+static void run_all(void)
+{
+	run(SIGHUP);
+	run(SIGINT);
+	run(SIGQUIT);
+	run(SIGILL);
+	run(SIGTRAP);
+	run(SIGABRT);
+	run(SIGFPE);
+	run(SIGSEGV);
+	run(SIGPIPE);
+	run(SIGALRM);
+	run(SIGTERM);
 }
 
 static struct tst_test test = {
 	.forks_child = 1,
 	.needs_checkpoints = 1,
-	.test_all = run,
+	.test_all = run_all,
 };

-- 
2.48.1



More information about the ltp mailing list