[LTP] [PATCH v3 1/5] syscalls/pause01: Clean up
Ricardo B. Marlière
rbm@suse.com
Mon Feb 24 19:53:02 CET 2025
From: Ricardo B. Marlière <rbm@suse.com>
Tidy up and add a description.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
testcases/kernel/syscalls/pause/pause01.c | 41 +++++++++++--------------------
1 file changed, 15 insertions(+), 26 deletions(-)
diff --git a/testcases/kernel/syscalls/pause/pause01.c b/testcases/kernel/syscalls/pause/pause01.c
index c88248da0d9961c5414a694a91cf1aef40ff263a..d830016a68b77daad4851d7f7d6436c0922de002 100644
--- a/testcases/kernel/syscalls/pause/pause01.c
+++ b/testcases/kernel/syscalls/pause/pause01.c
@@ -1,10 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) 2016 Linux Test Project
+ * Copyright (c) 2025 Ricardo B. Marlière <rbm@suse.com>
*/
-#include <errno.h>
-#include <signal.h>
-#include <stdlib.h>
+
+/*\
+ * Verify that, pause() returns -1 and sets errno to EINTR after receipt of a
+ * signal which is caught by the calling process.
+ */
+
#include "tst_test.h"
static void sig_handler(int sig LTP_ATTRIBUTE_UNUSED)
@@ -14,43 +18,28 @@ static void sig_handler(int sig LTP_ATTRIBUTE_UNUSED)
static void do_child(void)
{
SAFE_SIGNAL(SIGINT, sig_handler);
-
TST_CHECKPOINT_WAKE(0);
-
- TEST(pause());
- if (TST_RET != -1)
- tst_res(TFAIL, "pause() succeeded unexpectedly");
- else if (TST_ERR == EINTR)
- tst_res(TPASS, "pause() interrupted with EINTR");
- else
- tst_res(TFAIL | TTERRNO, "pause() unexpected errno");
-
- TST_CHECKPOINT_WAKE(0);
- exit(0);
+ TST_EXP_FAIL(pause(), EINTR);
+ tst_res(TPASS, "Process resumed from pause()");
}
-static void do_test(void)
+static void run(void)
{
int pid, status;
pid = SAFE_FORK();
- if (pid == 0)
+ if (!pid) {
do_child();
+ exit(0);
+ }
TST_CHECKPOINT_WAIT(0);
TST_PROCESS_STATE_WAIT(pid, 'S', 0);
- kill(pid, SIGINT);
-
- /*
- * TST_CHECKPOINT_WAIT has built-in timeout, if pause() doesn't return,
- * this checkpoint call will reliably end the test.
- */
- TST_CHECKPOINT_WAIT(0);
- SAFE_WAIT(&status);
+ SAFE_KILL(pid, SIGINT);
}
static struct tst_test test = {
.forks_child = 1,
.needs_checkpoints = 1,
- .test_all = do_test,
+ .test_all = run,
};
--
2.48.1
More information about the ltp
mailing list