[LTP] [PATCH v2 7/8] syscalls: Add epoll_wait12

Cyril Hrubis chrubis@suse.cz
Thu Jul 9 10:36:10 CEST 2026


Hi!
> > +static int efd = -1, fds[2] = {-1, -1};
> > +
> > +static void fill_pipe(int fd)
> > +{
> > +	char buf[4096];
> > +	struct pollfd pfd = {.fd = fd, .events = POLLOUT};
> > +	int nfd;
> > +
> > +	memset(buf, 'a', sizeof(buf));
> > +
> > +	do {
> > +		SAFE_WRITE(SAFE_WRITE_ANY, fd, buf, sizeof(buf));
> > +		nfd = poll(&pfd, 1, 0);
> 
> Why we don't have a SAFE_POLL() ? I just noticed how many times we are
> following a manual errors handling pattern inside the tests.

I will add it in the v3.

> > +		if (nfd == -1)
> > +			tst_brk(TBROK | TERRNO, "poll()");
> > +	} while (nfd > 0);
> > +}
> > +
> > +static void run(void)
> > +{
> > +	pid_t pid;
> > +
> > +	SAFE_PIPE(fds);
> > +	fill_pipe(fds[1]);
> > +
> > +	efd = SAFE_EPOLL_CREATE1(0);
> > +
> > +	struct epoll_event ev = {
> > +		.events = EPOLLOUT,
> > +		.data.fd = fds[1],
> > +	};
> > +
> > +	SAFE_EPOLL_CTL(efd, EPOLL_CTL_ADD, fds[1], &ev);
> > +
> > +	pid = SAFE_FORK();
> > +	if (!pid) {
> > +		SAFE_CLOSE(fds[0]);
> > +
> > +		TEST(epoll_wait(efd, &ev, 1, 5000));
> 
> We have SAFE_EPOLL_WAIT(), is there a reason why not to use it?
> Do we want to track the TST_RET ?

We do not use SAFE_MACROS() for the syscall that we test, because we
want to report the failure as TFAIL and not as TBROK.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list