All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] rseq01: basic test rseq
Date: Tue, 14 Feb 2023 12:46:36 +0100	[thread overview]
Message-ID: <Y+t0nO08MToOh/jC@yuki> (raw)
In-Reply-To: <20230213134619.27486-1-wegao@suse.com>

Hi!
> Add basic check for the newly added glibc API in LTP.
> This test references the glibc test case tst-rseq.c.
> 
> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  runtest/syscalls                          |  2 +
>  testcases/kernel/syscalls/rseq/.gitignore |  1 +
>  testcases/kernel/syscalls/rseq/Makefile   |  7 +++
>  testcases/kernel/syscalls/rseq/rseq01.c   | 74 +++++++++++++++++++++++
>  4 files changed, 84 insertions(+)
>  create mode 100644 testcases/kernel/syscalls/rseq/.gitignore
>  create mode 100644 testcases/kernel/syscalls/rseq/Makefile
>  create mode 100644 testcases/kernel/syscalls/rseq/rseq01.c
> 
> diff --git a/runtest/syscalls b/runtest/syscalls
> index ae37a1192..f46950b27 100644
> --- a/runtest/syscalls
> +++ b/runtest/syscalls
> @@ -1752,6 +1752,8 @@ copy_file_range01 copy_file_range01
>  copy_file_range02 copy_file_range02
>  copy_file_range03 copy_file_range03
>  
> +rseq01 rseq01
> +
>  statx01 statx01
>  statx02 statx02
>  statx03 statx03
> diff --git a/testcases/kernel/syscalls/rseq/.gitignore b/testcases/kernel/syscalls/rseq/.gitignore
> new file mode 100644
> index 000000000..8a6c7ee36
> --- /dev/null
> +++ b/testcases/kernel/syscalls/rseq/.gitignore
> @@ -0,0 +1 @@
> +/rseq01
> diff --git a/testcases/kernel/syscalls/rseq/Makefile b/testcases/kernel/syscalls/rseq/Makefile
> new file mode 100644
> index 000000000..159d5651c
> --- /dev/null
> +++ b/testcases/kernel/syscalls/rseq/Makefile
> @@ -0,0 +1,7 @@
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +#  Copyright (C) 2012 Linux Test Project, Inc.
> +
> +top_srcdir		?= ../../../..
> +
> +include $(top_srcdir)/include/mk/testcases.mk
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/rseq/rseq01.c b/testcases/kernel/syscalls/rseq/rseq01.c
> new file mode 100644
> index 000000000..ac096471e
> --- /dev/null
> +++ b/testcases/kernel/syscalls/rseq/rseq01.c
> @@ -0,0 +1,74 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2021-2023 Free Software Foundation, Inc.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with the GNU C Library; if not, see
> + * <https://www.gnu.org/licenses/>.

This part that says anything about GNU C Library shouldn't be there, the
copyright itself should be enough to keep the reference where the code
came from.

> + * Restartable Sequences single-threaded tests.
> + * These tests validate that rseq is registered from main in an executable
> + * not linked against libpthread.
> + */

This should be changed into docparse readable description.

> +#define _GNU_SOURCE
> +#include <errno.h>
> +#include <stdio.h>
> +#include <unistd.h>
> +#include "tst_test.h"
> +#include <stdbool.h>
> +
> +#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 35))
> +# include <sys/rseq.h>
> +#endif
> +
> +#ifdef RSEQ_SIG
> +# include <stdlib.h>
> +# include <string.h>
> +# include <syscall.h>
> +# include <sched.h>
> +
> +static int sys_rseq(struct rseq *rseq_abi, uint32_t rseq_len, int flags, uint32_t sig)
> +{
> +	return syscall(__NR_rseq, rseq_abi, rseq_len, flags, sig);
> +}

Can we please add a configure cehck and a fallback header into a lapi/ ?

LTP runs on different libc implmentations and such ifdefs shouldn't be
used at all.

> +static void check_rseq_available(void)
> +{
> +	int rc;
> +
> +	rc = sys_rseq(NULL, 0, 0, 0);
> +	if (rc != -1)
> +		tst_brk(TFAIL | TTERRNO, "Unexpected rseq return value %d ", rc);
> +	switch (errno) {
> +	case ENOSYS:
> +		tst_res(TCONF,
> +				"kernel does not support rseq, skipping test");
> +	case EINVAL:
> +		/* rseq is implemented, but detected an invalid rseq_len parameter.  */
> +		break;
> +	default:
> +		tst_brk(TFAIL | TTERRNO, "Unexpected rseq error ");
> +	}
> +}
> +
> +static void run(void)
> +{
> +	check_rseq_available();
> +
> +	TST_EXP_PASS(!(sched_getcpu() >= 0));
> +}
> +#else /* RSEQ_SIG */
> +
> +static void run(void)
> +{
> +	tst_res(TCONF,
> +		"glibc does not define RSEQ_SIG, skipping test");
> +}
> +
> +#endif /* RSEQ_SIG */
> +
> +static struct tst_test test = {
> +	.test_all = run,
> +	.needs_root = 1,
> +};
> -- 
> 2.35.3
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-02-14 11:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-13 13:46 [LTP] [PATCH v1] rseq01: basic test rseq Wei Gao via ltp
2023-02-14 11:46 ` Cyril Hrubis [this message]
2023-02-15  2:34 ` [LTP] [PATCH v2] " Wei Gao via ltp
2023-02-16 10:58   ` Cyril Hrubis
2023-02-17  4:17     ` Wei Gao via ltp
2023-02-17  9:33       ` Cyril Hrubis
2023-02-21  1:34   ` [LTP] [PATCH v3 0/2] Move linux rseq test into ltp Wei Gao via ltp
2023-02-21  1:34     ` [LTP] [PATCH v3 1/2] rseq: Copy linux rseq test header files to ltp Wei Gao via ltp
2023-03-13 15:48       ` Cyril Hrubis
2023-03-14 13:49         ` Wei Gao via ltp
2023-03-14 16:29           ` Cyril Hrubis
2023-03-14 22:40             ` Wei Gao via ltp
2023-02-21  1:34     ` [LTP] [PATCH v3 2/2] rseq01: basic test rseq Wei Gao via ltp
2023-03-09  2:04       ` [LTP] [PATCH v4] " Wei Gao via ltp
2023-03-09  8:16         ` [LTP] [PATCH v5] " 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=Y+t0nO08MToOh/jC@yuki \
    --to=chrubis@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 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.