[LTP] [PATCH v2 1/3] syscalls/pause01: Clean up
Ricardo B. Marlière
ricardo@marliere.net
Tue Feb 18 19:07:17 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 | 34 +++++++++++++------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/testcases/kernel/syscalls/pause/pause01.c b/testcases/kernel/syscalls/pause/pause01.c
index c88248da0d9961c5414a694a91cf1aef40ff263a..adce0ddcf2e0639407b4e21de0a1be7b30efaa01 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,32 +18,22 @@ static void sig_handler(int sig LTP_ATTRIBUTE_UNUSED)
static void do_child(void)
{
SAFE_SIGNAL(SIGINT, sig_handler);
-
+ TST_EXP_FAIL(pause(), EINTR);
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);
}
-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);
+ SAFE_KILL(pid, SIGINT);
/*
* TST_CHECKPOINT_WAIT has built-in timeout, if pause() doesn't return,
@@ -52,5 +46,5 @@ static void do_test(void)
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