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 3/3] syscalls/pause03: Refactor into new API
Date: Fri, 21 Feb 2025 11:32:25 +0100 [thread overview]
Message-ID: <Z7hWOTzp7CSorBRu@yuki.lan> (raw)
In-Reply-To: <20250218-conversions-pause-v2-3-8c72960fe1ec@suse.com>
Hi!
> ---
> testcases/kernel/syscalls/pause/pause03.c | 115 +++++++-----------------------
> 1 file changed, 25 insertions(+), 90 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/pause/pause03.c b/testcases/kernel/syscalls/pause/pause03.c
> index 459222045c08dc1fc4804efd2ece02316fe55a0e..85c3c18b19d63343c65fa553a65ecb6f9f0c0700 100644
> --- a/testcases/kernel/syscalls/pause/pause03.c
> +++ b/testcases/kernel/syscalls/pause/pause03.c
> @@ -1,104 +1,39 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> /*
> * Copyright (c) International Business Machines Corp., 2001
> - * 07/2001 Ported by Wayne Boyer
> - *
> - * This program is free software; you can redistribute it and/or modify
> - * it under the terms of the GNU General Public License as published by
> - * the Free Software Foundation; either version 2 of the License, or
> - * (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
> - * the GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software Foundation,
> - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + * 07/2001 Ported by Wayne Boyer
> + * Copyright (c) 2025 Ricardo B. Marlière <rbm@suse.com>
> */
> -/*
> - * Test Description:
> - * pause() does not return due to receipt of SIGKILL signal and specified
> - * process should be terminated.
> - */
> -#include <unistd.h>
> -#include <errno.h>
> -#include <fcntl.h>
> -#include <sys/wait.h>
> -
> -#include "test.h"
> -#include "safe_macros.h"
> -
> -static pid_t cpid;
>
> -char *TCID = "pause03";
> -int TST_TOTAL = 1;
> +/*\
> + * This test verifies that pause() does not return after receiving a SIGKILL
> + * signal, at which point the process should be terminated.
Maybe this can be shorter, something as:
Verifies that pause() does not return after process recieved SIGKILL.
> + */
>
> -static void do_child(void);
> -static void setup(void);
> -static void cleanup(void);
> +#include "tst_test.h"
>
> -int main(int ac, char **av)
> +void run(void)
> {
> - int lc;
> int status;
> + pid_t pid;
>
> - tst_parse_opts(ac, av, NULL, NULL);
> -
> - setup();
> -
> - for (lc = 0; TEST_LOOPING(lc); lc++) {
> - tst_count = 0;
> -
> - if ((cpid = tst_fork()) == -1)
> - tst_brkm(TBROK | TERRNO, NULL, "fork() failed");
> -
> - if (cpid == 0)
> - do_child();
> -
> - TST_PROCESS_STATE_WAIT(cleanup, cpid, 'S');
> -
> - kill(cpid, SIGKILL);
> -
> - SAFE_WAIT(NULL, &status);
> -
> - if (WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL) {
> - tst_resm(TPASS, "pause() did not return after SIGKILL");
> - continue;
> - }
> -
> - if (WIFSIGNALED(status)) {
> - tst_resm(TFAIL, "child killed by %s unexpectedly",
> - tst_strsig(WTERMSIG(status)));
> - continue;
> - }
> -
> - tst_resm(TFAIL, "child exited with %i", WEXITSTATUS(status));
> + pid = SAFE_FORK();
> + if (!pid) {
> + TST_EXP_PASS(pause());
> + exit(0);
> }
>
> - cleanup();
> - tst_exit();
> + TST_PROCESS_STATE_WAIT(pid, 'S', 10000);
Same as with the pause01 we need the checpoints before we check the
process state.
> + SAFE_KILL(pid, SIGINT);
^
SIGKILL
The test does not even work with SIGINT...
> + SAFE_WAITPID(pid, &status, 0);
>
> + if (WIFSIGNALED(status) && WTERMSIG(status) == SIGKILL)
> + tst_res(TPASS, "pause() did not return after SIGKILL");
> + else
> + tst_res(TFAIL, "Child exited with %i", WEXITSTATUS(status));
This is not correct, you should use tst_strstatus(status) that covers
all the possible cases, as:
tst_res(TFAIL, "Child %s", tst_strstatus(status))
> }
>
> -void do_child(void)
> -{
> - TEST(pause());
> -
> - tst_resm(TFAIL, "Unexpected return from pause()");
> -
> - exit(0);
> -}
> -
> -void setup(void)
> -{
> - tst_sig(FORK, DEF_HANDLER, cleanup);
> -
> - TEST_PAUSE;
> -}
> -
> -
> -void cleanup(void)
> -{
> - kill(cpid, SIGKILL);
> -}
> +static struct tst_test test = {
> + .test_all = run,
> + .forks_child = 1,
> +};
>
> --
> 2.48.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
--
Cyril Hrubis
chrubis@suse.cz
--
Mailing list info: https://lists.linux.it/listinfo/ltp
prev parent reply other threads:[~2025-02-21 10:32 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
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 [this message]
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=Z7hWOTzp7CSorBRu@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.