Re: [PATCH net-next] selftest: epoll_busy_poll: epoll busy poll tests

From: Jakub Kicinski
Date: Fri May 03 2024 - 18:49:51 EST


On Thu, 2 May 2024 21:20:11 +0000 Joe Damato wrote:
> --- a/tools/testing/selftests/net/Makefile
> +++ b/tools/testing/selftests/net/Makefile
> @@ -84,6 +84,7 @@ TEST_GEN_FILES += sctp_hello
> TEST_GEN_FILES += csum
> TEST_GEN_FILES += ip_local_port_range
> TEST_GEN_FILES += bind_wildcard
> +TEST_GEN_FILES += epoll_busy_poll

"GEN" is for files which are built for other tests to use.
IOW unless there's also a wrapper script under TEST_PROGS
(or the C code is itself under TEST_PROGS) this test won't
be executed by most CIs.

FWIW here's how we run the tests in our CI upstream CI:
https://github.com/linux-netdev/nipa/wiki/How-to-run-netdev-selftests-CI-style

> TEST_PROGS += test_vxlan_mdb.sh
> TEST_PROGS += test_bridge_neigh_suppress.sh
> TEST_PROGS += test_vxlan_nolocalbypass.sh

> +static void do_simple_test(void)
> +{
> + int fd;
> +
> + fd = epoll_create1(0);
> + if (fd == -1)
> + error(1, errno, "epoll_create");
> +
> + do_simple_test_invalid_fd();
> + do_simple_test_invalid_ioctl(fd);
> + do_simple_test_get_params(fd);
> + do_simple_test_set_invalid(fd);
> + do_simple_test_set_and_get_valid(fd);

You don't want to use the kselftest_harness for this?
No strong preference here, but seems like you could
pop the epoll_create1 into a FIXTURE() and then the
test cases into TEST_F() and we'd get the KTAP output
formatting, ability to run the tests selectively etc.
for free.

tools/testing/selftests/net/tap.c is probably a good example
to take a look at