public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: Martin Doucha <martin.doucha@suse.com>, ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] lib: tst_fd: Avoid tst_brk(TCONF, ...) on older distros
Date: Wed, 24 Jan 2024 15:16:25 +0100	[thread overview]
Message-ID: <20240124141625.GC299755@pevik> (raw)
In-Reply-To: <20240124125813.6611-1-chrubis@suse.cz>

> All the lapi/ functions does call tst_syscall() that does
> tst_brk(TCONF, ...) on ENOSYS which exits the testrun prematurely on older
> distributions.

> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> Reported-by: Martin Doucha <mdoucha@suse.cz>
> ---
>  lib/tst_fd.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

> diff --git a/lib/tst_fd.c b/lib/tst_fd.c
> index ea84e1c85..ab7de81aa 100644
> --- a/lib/tst_fd.c
> +++ b/lib/tst_fd.c
> @@ -139,7 +139,7 @@ static void open_timerfd(struct tst_fd *fd)

>  static void open_pidfd(struct tst_fd *fd)
>  {
> -	fd->fd = pidfd_open(getpid(), 0);
> +	fd->fd = syscall(__NR_pidfd_open, getpid(), 0);
Actually at least here tst_syscall() needs to be called or it fails on older
distros due missing ENOSYS check in raw syscall():

tst_fd.c:144: TBROK: pidfd_open(): ENOSYS (38)

Other syscall() are probably skipped due tst_brk(), but I would replace them
anyway.

Also, I wonder if we can avoid tst_brk() because it quits the test.

Kind regards,
Petr

>  	if (fd->fd < 0)
>  		tst_brk(TBROK | TERRNO, "pidfd_open()");
>  }
> @@ -194,7 +194,7 @@ static void open_io_uring(struct tst_fd *fd)
>  {
>  	struct io_uring_params uring_params = {};

> -	fd->fd = io_uring_setup(1, &uring_params);
> +	fd->fd = syscall(__NR_io_uring_setup, 1, &uring_params);
>  	if (fd->fd < 0) {
>  		tst_res(TCONF | TERRNO,
>  			"Skipping %s", tst_fd_desc(fd));
> @@ -210,7 +210,7 @@ static void open_bpf_map(struct tst_fd *fd)
>  		.max_entries = 1,
>  	};

> -	fd->fd = bpf(BPF_MAP_CREATE, &array_attr, sizeof(array_attr));
> +	fd->fd = syscall(__NR_bpf, BPF_MAP_CREATE, &array_attr, sizeof(array_attr));
>  	if (fd->fd < 0) {
>  		tst_res(TCONF | TERRNO,
>  			"Skipping %s", tst_fd_desc(fd));
> @@ -219,7 +219,7 @@ static void open_bpf_map(struct tst_fd *fd)

>  static void open_fsopen(struct tst_fd *fd)
>  {
> -	fd->fd = fsopen("ext2", 0);
> +	fd->fd = syscall(__NR_fsopen, "ext2", 0);
>  	if (fd->fd < 0) {
>  		tst_res(TCONF | TERRNO,
>  			"Skipping %s", tst_fd_desc(fd));
> @@ -228,7 +228,7 @@ static void open_fsopen(struct tst_fd *fd)

>  static void open_fspick(struct tst_fd *fd)
>  {
> -	fd->fd = fspick(AT_FDCWD, "/", 0);
> +	fd->fd = syscall(__NR_fspick, AT_FDCWD, "/", 0);
>  	if (fd->fd < 0) {
>  		tst_res(TCONF | TERRNO,
>  			"Skipping %s", tst_fd_desc(fd));
> @@ -237,7 +237,7 @@ static void open_fspick(struct tst_fd *fd)

>  static void open_open_tree(struct tst_fd *fd)
>  {
> -	fd->fd = open_tree(AT_FDCWD, "/", 0);
> +	fd->fd = syscall(__NR_open_tree, AT_FDCWD, "/", 0);
>  	if (fd->fd < 0) {
>  		tst_res(TCONF | TERRNO,
>  			"Skipping %s", tst_fd_desc(fd));

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

  parent reply	other threads:[~2024-01-24 14:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-24 12:58 [LTP] [PATCH] lib: tst_fd: Avoid tst_brk(TCONF, ...) on older distros Cyril Hrubis
2024-01-24 13:54 ` Martin Doucha
2024-01-24 14:10 ` Petr Vorel
2024-01-24 14:11   ` Cyril Hrubis
2024-01-24 14:22     ` Petr Vorel
2024-01-24 14:16 ` Petr Vorel [this message]
2024-01-24 14:21   ` Cyril Hrubis
2024-01-24 14:25     ` Petr Vorel
2024-01-24 14:36     ` Martin Doucha
2024-01-24 14:56       ` Petr Vorel
2024-01-24 15:19         ` Cyril Hrubis
2024-01-24 15:50           ` Petr Vorel
2024-01-24 16:57           ` Petr Vorel

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=20240124141625.GC299755@pevik \
    --to=pvorel@suse.cz \
    --cc=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    --cc=martin.doucha@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