All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] open04: add EMFILE check
@ 2022-09-15  3:10 Li Wang
  2022-09-15 12:52 ` Petr Vorel
  0 siblings, 1 reply; 9+ messages in thread
From: Li Wang @ 2022-09-15  3:10 UTC (permalink / raw)
  To: ltp

[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;
 	}
 }
-- 
2.35.3


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

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-09-20 18:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15  3:10 [LTP] [PATCH] open04: add EMFILE check Li Wang
2022-09-15 12:52 ` Petr Vorel
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

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.