Re: [PATCH v3 1/9] syscalls: Add epoll_create03
Petr Vorel <[email protected]>
| Newsgroups | gmane.linux.ltp |
|---|---|
| Message-ID | <20260709105159.GA874350@pevik> |
Hi Cyril, > Test that checks that we get EMFILE when limit on per-process file > descriptors is hit. +1. ... > +++ b/testcases/kernel/syscalls/epoll_create/epoll_create03.c > @@ -0,0 +1,72 @@ > +// SPDX-License-Identifier: GPL-2.0-or-later > +/* > + * Copyright (c) 2026 Cyril Hrubis <[email protected]> > + */ > + > +/*\ > + * Verify that :manpage:epoll_create() fails with EMFILE when the per-process Please add 2 to the manpage link. :manpage:epoll_create(2) Without it it's not working (plain text instead of link). Can be changed before merge. > + * limit on the number of open file descriptors has been reached. > + */ > + > +#include <stdlib.h> > +#include <sys/epoll.h> > + > +#include "tst_test.h" > +#include "lapi/epoll.h" > +#include "lapi/syscalls.h" > + > +#include "epoll_create.h" > + > +static int *fds; > +static int nfds; > +static long maxfds; > + > +static void setup(void) > +{ > + int fd; > + > + variant_info(); > + > + maxfds = SAFE_SYSCONF(_SC_OPEN_MAX); > + fds = SAFE_MALLOC(maxfds * sizeof(int)); > + memset(fds, -1, maxfds * sizeof(int)); > + > + fds[0] = SAFE_OPEN("dummy", O_RDWR | O_CREAT, 0700); > + nfds = 1; > + > + for (int i = 1; i < maxfds; i++) { > + fd = dup(fds[0]); > + if (fd == -1) > + break; > + fds[nfds++] = fd; > + } How many files are created is done via `ulimit -n`, right? (not sure if there is file for it in /proc/sys). Would it be worth we check that? Or at least check that at least 2 files were opened? Maybe this check should be rather put into dup03.c. Or maybe to print how many descriptors was created? tst_res(TINFO, "Created %d file descriptors", nfds); > +} > + > +static void run(void) > +{ > + TST_EXP_FAIL2(do_epoll_create(1), EMFILE, > + "epoll_create(1) with exhausted fds"); Otherwise LGTM. Reviewed-by: Petr Vorel <[email protected]> Kind regards, Petr -- Mailing list info: https://lists.linux.it/listinfo/ltp