public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: Li Wang <liwang@redhat.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] open04: add EMFILE check
Date: Thu, 15 Sep 2022 14:52:21 +0200	[thread overview]
Message-ID: <YyMgBQu+phGCulxV@pevik> (raw)
In-Reply-To: <20220915031020.2633347-1-liwang@redhat.com>

Hi LI,

> [pre-release testing fix]

> Test in automation easily get EMFILE error before reaching the fds_limit,
> but hard to reproduce it again manually. The possible reason is that some
> shared fd being opened in the parent shell and occupying the fd numbers
> which inherited by test then results in open failed with EMFILE early.

> This patch adds back of the EMFILE check in the open() loops, to flexible
> test fd limitation.

>   open04.c:36: TBROK: open(open04.1020,66,0777) failed: EMFILE (24)
>   open04.c:53: TWARN: close(0) failed: EBADF (9)

> Signed-off-by: Li Wang <liwang@redhat.com>
> ---
>  testcases/kernel/syscalls/open/open04.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)

> diff --git a/testcases/kernel/syscalls/open/open04.c b/testcases/kernel/syscalls/open/open04.c
> index d452405d4..01a8b12d6 100644
> --- a/testcases/kernel/syscalls/open/open04.c
> +++ b/testcases/kernel/syscalls/open/open04.c
> @@ -33,7 +33,12 @@ static void setup(void)

>  	for (i = first + 1; i < fds_limit; i++) {
>  		sprintf(fname, FNAME ".%d", i);
> -		fd = SAFE_OPEN(fname, O_RDWR | O_CREAT, 0777);
> +		fd = open(fname, O_RDWR | O_CREAT, 0777);
> +		if (fd == -1) {
> +			if (errno != EMFILE)
> +				tst_brk(TBROK, "Expected EMFILE but got %d", errno);
> +			break;
> +		}
>  		fds[i - first] = fd;
>  	}
>  }

LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr


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

  reply	other threads:[~2022-09-15 12:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-15  3:10 [LTP] [PATCH] open04: add EMFILE check Li Wang
2022-09-15 12:52 ` Petr Vorel [this message]
2022-09-15 14:21   ` Cyril Hrubis
2022-09-16  1:36     ` Li Wang
2022-09-16  9:39       ` Cyril Hrubis
2022-09-19 12:12         ` Li Wang
2022-09-20  5:53           ` Li Wang
2022-09-20 14:21             ` Cyril Hrubis
2022-09-20 18:29             ` 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=YyMgBQu+phGCulxV@pevik \
    --to=pvorel@suse.cz \
    --cc=liwang@redhat.com \
    --cc=ltp@lists.linux.it \
    /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