From: Petr Vorel <pvorel@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1 1/2] ptrace05: Refactor the test using new LTP API
Date: Tue, 28 Nov 2023 10:24:20 +0100 [thread overview]
Message-ID: <20231128092420.GB303912@pevik> (raw)
In-Reply-To: <20230925112245.30701-2-wegao@suse.com>
Hi Wei,
make check-ptrace05 shows various redefinitions, that points on ptrace.h cleanup
needed, I'll fix it as a separate change.
CHECK testcases/kernel/syscalls/ptrace/ptrace05.c
ptrace05.c: note: in included file (through ptrace.h):
/usr/include/linux/ptrace.h:50:9: warning: preprocessor token PTRACE_GETREGSET redefined
ptrace05.c: note: in included file (through ptrace.h):
/usr/include/sys/ptrace.h:153:9: this was the original definition
ptrace05.c: note: in included file (through ptrace.h):
/usr/include/linux/ptrace.h:51:9: warning: preprocessor token PTRACE_SETREGSET redefined
ptrace05.c: note: in included file (through ptrace.h):
/usr/include/sys/ptrace.h:157:9: this was the original definition
ptrace05.c: note: in included file (through ptrace.h):
/usr/include/linux/ptrace.h:53:9: warning: preprocessor token PTRACE_SEIZE redefined
I handled this in separate patchset [3], I Cc you. Could you please base v2 on it?
I hope it will be merged soon.
[1] https://sourceware.org/glibc/wiki/Synchronizing_Headers
[2] https://github.com/linux-test-project/ltp/wiki/Supported-kernel,-libc,-toolchain-versions#11-oldest-tested-distributions
[3] https://patchwork.ozlabs.org/project/ltp/list/?series=384172&state=*
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
> testcases/kernel/syscalls/ptrace/ptrace05.c | 147 ++++++--------------
> 1 file changed, 39 insertions(+), 108 deletions(-)
> diff --git a/testcases/kernel/syscalls/ptrace/ptrace05.c b/testcases/kernel/syscalls/ptrace/ptrace05.c
> index 54cfa4d7b..4904b959c 100644
> --- a/testcases/kernel/syscalls/ptrace/ptrace05.c
> +++ b/testcases/kernel/syscalls/ptrace/ptrace05.c
> @@ -1,122 +1,67 @@
> +// SPDX-License-Identifier: GPL-2.0-only
// SPDX-License-Identifier: GPL-2.0-or-later
> /*
> - ******************************************************************************
> - *
> - * ptrace05 - an app which ptraces itself as per arbitrarily specified signals,
> - * over a user specified range.
> - *
> - * Copyright (C) 2009, Ngie Cooper
> - *
> - * 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.
"any later version" is why GPL-2.0-or-later instead of GPL-2.0-only.
> - * 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.
> + * Copyright (C) 2009, Ngie Cooper
> + * Copyright (c) 2023 Wei Gao <wegao@suse.com>
Please add also LTP copyright (more people contributed to this test):
* Copyright (c) Linux Test Project, 2009-2019
> + */
> +
> +/*\
> + * [Description]
> *
> - * 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.
> + * ptrace05 - an app which ptraces itself as per arbitrarily specified signals
I'm not really sure for a proper description, but we don't list the test name,
also s/app/test/
> *
> - ******************************************************************************
> */
> -#include <sys/types.h>
> -#include <sys/wait.h>
> -#include <signal.h>
> -#include <errno.h>
> -#include <libgen.h>
> -#include <math.h>
> #include <stdlib.h>
> -#include <stdio.h>
> -#include <string.h>
> -#include <unistd.h>
> -
> #include <config.h>
> #include "ptrace.h"
> -#include "test.h"
> #include "lapi/signal.h"
> +#include "tst_test.h"
> -char *TCID = "ptrace05";
> -int TST_TOTAL = 0;
> -
> -int usage(const char *);
> -
> -int usage(const char *argv0)
> -{
> - fprintf(stderr, "usage: %s [start-signum] [end-signum]\n", argv0);
> - return 1;
> -}
> -
> -int main(int argc, char **argv)
> +static void run(void)
> {
> - int end_signum = -1;
> - int signum;
> - int start_signum = -1;
> + int end_signum = SIGRTMAX;
> + int signum = 0;
> + int start_signum = 0;
> int status;
> pid_t child;
> - tst_parse_opts(argc, argv, NULL, NULL);
> -
> - if (start_signum == -1) {
> - start_signum = 0;
> - }
> - if (end_signum == -1) {
> - end_signum = SIGRTMAX;
> - }
> -
> for (signum = start_signum; signum <= end_signum; signum++) {
> - if (signum >= __SIGRTMIN && signum < SIGRTMIN)
> - continue;
> -
> - switch (child = fork()) {
> + switch (child = SAFE_FORK()) {
> case -1:
> - tst_brkm(TBROK | TERRNO, NULL, "fork() failed");
> + tst_brk(TBROK | TERRNO, "fork() failed");
We have this handled in SAFE_FORK(), it should be removed here.
Therefore switch+case should be replaced with if+else.
> case 0:
> - tst_resm(TFAIL | TERRNO,
> + tst_brk(TFAIL | TERRNO,
> "Failed to ptrace(PTRACE_TRACEME, ...) "
> "properly");
> -
> }
...
> - /* Shouldn't get here if signum == 0. */
> - exit((signum == 0 ? 0 : 2));
> +
> + exit(0);
Why there can be always exit(0) ?
> break;
> default:
> - waitpid(child, &status, 0);
> + SAFE_WAITPID(child, &status, 0);
> switch (signum) {
> case 0:
> if (WIFEXITED(status)
> && WEXITSTATUS(status) == 0) {
> - tst_resm(TPASS,
> + tst_res(TPASS,
> "kill(.., 0) exited "
> "with 0, as expected.");
Please join strings (this applies to code below as well).
> } else {
> - tst_resm(TFAIL,
> + tst_brk(TFAIL | TERRNO,
> "kill(.., 0) didn't exit "
> "with 0.");
Why not tst_res(TFAIL, ...) ? (this applies to code below as well)
...
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2023-11-28 9:25 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-25 11:22 [LTP] [PATCH v1 0/2] ptrace: Refactor Wei Gao via ltp
2023-09-25 11:22 ` [LTP] [PATCH v1 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2023-11-28 8:57 ` Richard Palethorpe
2023-11-28 9:24 ` Petr Vorel [this message]
2023-09-25 11:22 ` [LTP] [PATCH v1 2/2] ptrace06: " Wei Gao via ltp
2023-11-28 9:31 ` Richard Palethorpe
2023-11-28 9:51 ` Petr Vorel
2023-12-01 1:06 ` Wei Gao via ltp
2023-12-01 0:59 ` [LTP] [PATCH v2 0/2] ptrace: Refactor Wei Gao via ltp
2023-12-01 0:59 ` [LTP] [PATCH v2 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2024-02-08 16:15 ` Andrea Cervesato via ltp
2023-12-01 0:59 ` [LTP] [PATCH v2 2/2] ptrace06: " Wei Gao via ltp
2024-02-08 16:25 ` Andrea Cervesato via ltp
2024-06-03 10:35 ` [LTP] [PATCH v3 0/2] ptrace: Refactor Wei Gao via ltp
2024-06-03 10:35 ` [LTP] [PATCH v3 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2024-06-28 15:35 ` Cyril Hrubis
2024-06-03 10:35 ` [LTP] [PATCH v3 2/2] ptrace06: " Wei Gao via ltp
2024-06-28 16:15 ` Cyril Hrubis
2024-12-17 6:16 ` [LTP] [PATCH v4 0/2] ptrace: Refactor Wei Gao via ltp
2024-12-17 6:16 ` [LTP] [PATCH v4 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2025-01-08 13:39 ` Petr Vorel
2024-12-17 6:16 ` [LTP] [PATCH v4 2/2] ptrace06: " Wei Gao via ltp
2025-01-09 8:55 ` Petr Vorel
2025-01-13 8:16 ` [LTP] [PATCH v5 0/2] ptrace: Refactor Wei Gao via ltp
2025-01-13 8:16 ` [LTP] [PATCH v5 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2025-01-13 16:02 ` Cyril Hrubis
2025-01-13 21:40 ` Petr Vorel
2025-01-14 9:25 ` Cyril Hrubis
2025-01-13 8:16 ` [LTP] [PATCH v5 2/2] ptrace06: " Wei Gao via ltp
2025-01-14 12:40 ` [LTP] [PATCH v6 0/2] ptrace: Refactor Wei Gao via ltp
2025-01-14 12:40 ` [LTP] [PATCH v6 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2025-01-14 13:05 ` Cyril Hrubis
2025-01-14 12:40 ` [LTP] [PATCH v6 2/2] ptrace06: " Wei Gao via ltp
2025-01-14 14:32 ` [LTP] [PATCH v7 0/2] ptrace: Refactor Wei Gao via ltp
2025-01-14 14:32 ` [LTP] [PATCH v7 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2025-01-16 16:44 ` Cyril Hrubis
2025-01-14 14:32 ` [LTP] [PATCH v7 2/2] ptrace06: " Wei Gao via ltp
2025-01-16 16:50 ` Cyril Hrubis
2025-01-17 10:40 ` Petr Vorel
2025-01-17 10:42 ` Cyril Hrubis
2025-01-17 11:12 ` Petr Vorel
2025-01-20 4:14 ` [LTP] [PATCH v8 0/2] ptrace: Refactor Wei Gao via ltp
2025-01-20 4:14 ` [LTP] [PATCH v8 1/2] ptrace06: Refactor the test using new LTP API Wei Gao via ltp
2025-01-20 13:35 ` Petr Vorel
2025-01-20 4:14 ` [LTP] [PATCH v8 2/2] ptrace06_child.c: Remove unused ptrace06_child.c Wei Gao via ltp
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=20231128092420.GB303912@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
--cc=wegao@suse.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox