From: Cyril Hrubis <chrubis@suse.cz>
To: "Ricardo B. Marlière" <ricardo@marliere.net>
Cc: "Ricardo B. Marlière" <rbm@suse.com>,
"Linux Test Project" <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v2 1/3] syscalls/pause01: Clean up
Date: Fri, 21 Feb 2025 11:17:14 +0100 [thread overview]
Message-ID: <Z7hSqqK4PjZMEqPU@yuki.lan> (raw)
In-Reply-To: <20250218-conversions-pause-v2-1-8c72960fe1ec@suse.com>
Hi!
> 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);
This reorders how things are called which is wrong. The checkpoint wake
call before the pause() is there for a reason. The process may sleep in
kernel for any other reason not related to the test, so we need to
ensure that we are just about to call the pause() syscall before we wait
for the process state to change in the run() function.
If anything should be removed it's the second pair of checkpoints after
the pause() because the new test library has build-in timeout and there
is no reason to depend on checkpoint timeouts at the end of the test.
And there is no reason to wait() the child in the new test library
either. So (on the top of your patch) we can do:
diff --git a/testcases/kernel/syscalls/pause/pause01.c b/testcases/kernel/syscalls/pause/pause01.c
index adce0ddcf..680fa2c05 100644
--- a/testcases/kernel/syscalls/pause/pause01.c
+++ b/testcases/kernel/syscalls/pause/pause01.c
@@ -18,8 +18,8 @@ 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);
+ TST_EXP_FAIL(pause(), EINTR);
}
static void run(void)
@@ -32,15 +32,9 @@ static void run(void)
exit(0);
}
+ TST_CHECKPOINT_WAIT(0);
TST_PROCESS_STATE_WAIT(pid, 'S', 0);
SAFE_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);
}
static struct tst_test test = {
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2025-02-21 10:17 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-18 18:07 [LTP] [PATCH v2 0/3] syscalls/pause: Refactor tests Ricardo B. Marlière
2025-02-18 18:07 ` [LTP] [PATCH v2 1/3] syscalls/pause01: Clean up Ricardo B. Marlière
2025-02-21 10:17 ` Cyril Hrubis [this message]
2025-02-18 18:07 ` [LTP] [PATCH v2 2/3] syscalls/pause02: Refactor into new API Ricardo B. Marlière
2025-02-21 10:39 ` Cyril Hrubis
2025-02-24 10:49 ` Ricardo B. Marlière via ltp
2025-02-18 18:07 ` [LTP] [PATCH v2 3/3] syscalls/pause03: " Ricardo B. Marlière
2025-02-21 10:32 ` Cyril Hrubis
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=Z7hSqqK4PjZMEqPU@yuki.lan \
--to=chrubis@suse.cz \
--cc=ltp@lists.linux.it \
--cc=rbm@suse.com \
--cc=ricardo@marliere.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.