Re: [PATCH net-next v1 5/5] selftest: net: add proc_net_pktgen

From: Jakub Kicinski
Date: Fri Jan 17 2025 - 16:12:04 EST


On Fri, 17 Jan 2025 15:16:13 +0100 Peter Seiderer wrote:
> +FIXTURE_SETUP(proc_net_pktgen) {
> + ssize_t len;
> +
> + self->ctrl_fd = open("/proc/net/pktgen/kpktgend_0", O_RDWR);
> + ASSERT_GE(self->ctrl_fd, 0) TH_LOG("CONFIG_NET_PKTGEN not enabled, module pktgen nod loaded?");

nod -> not?

Please take a look at the instructions here:
https://github.com/linux-netdev/nipa/wiki/How-to-run-netdev-selftests-CI-style
the test currently fails in our CI, you need to add it to
tools/testing/selftests/net/config, and perhaps try to call
modprobe in the test?

> + len = write(self->ctrl_fd, add_loopback_0, sizeof(add_loopback_0));
> + ASSERT_EQ(len, sizeof(add_loopback_0)) TH_LOG("device lo@0 already registered?");

FWIW we prefer to stick to 80 char line width in networking,
but it's not a big deal for a test, up to you.

> + // complete command string without/with trailing '\0'
> + EXPECT_EQ(len, i);

Run this patch thru checkpatch, please. This looks misaligned.

> + }
> + }
> +}

> +#if 0 // needs CONFIG_XFRM

Add it to the config, too, then?

> +TEST_F(proc_net_pktgen, device_command_spi) {
> + ssize_t len;
> +
> + len = write(self->device_fd, device_command_spi_0, sizeof(device_command_spi_0));
> + EXPECT_EQ(len, sizeof(device_command_spi_0));
> +}
> +#endif

Thanks for working on a test!