From: Florian Westphal Date: Mon, 22 Apr 2024 10:33:53 +0000 (+0200) Subject: selftests: netfilter: fix conntrack_dump_flush retval on unsupported kernel X-Git-Tag: net-accept-more-20240515~4^2~152 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=dd99c29e83e48acf80ee1855a5a6991b3e6523f5;p=linux-block.git selftests: netfilter: fix conntrack_dump_flush retval on unsupported kernel With CONFIG_NETFILTER=n test passes instead of skip. Before: ./run_kselftest.sh -t net/netfilter:conntrack_dump_flush [..] # Starting 3 tests from 1 test cases. # RUN conntrack_dump_flush.test_dump_by_zone ... mnl_socket_open: Protocol not supported [..] ok 3 conntrack_dump_flush.test_flush_by_zone_default # PASSED: 3 / 3 tests passed. # Totals: pass:3 fail:0 xfail:0 xpass:0 skip:0 error:0 After: mnl_socket_open: Protocol not supported [..] ok 3 conntrack_dump_flush.test_flush_by_zone_default # SKIP cannot open netlink_netfilter socket # PASSED: 3 / 3 tests passed. # Totals: pass:0 fail:0 xfail:0 xpass:0 skip:3 error:0 Signed-off-by: Florian Westphal Link: https://lore.kernel.org/r/20240422103358.3511-1-fw@strlen.de Signed-off-by: Jakub Kicinski --- diff --git a/tools/testing/selftests/net/netfilter/conntrack_dump_flush.c b/tools/testing/selftests/net/netfilter/conntrack_dump_flush.c index ca8d6b976c42..bd9317bf5ada 100644 --- a/tools/testing/selftests/net/netfilter/conntrack_dump_flush.c +++ b/tools/testing/selftests/net/netfilter/conntrack_dump_flush.c @@ -313,13 +313,11 @@ FIXTURE_SETUP(conntrack_dump_flush) self->sock = mnl_socket_open(NETLINK_NETFILTER); if (!self->sock) { perror("mnl_socket_open"); - exit(EXIT_FAILURE); + SKIP(return, "cannot open netlink_netfilter socket"); } - if (mnl_socket_bind(self->sock, 0, MNL_SOCKET_AUTOPID) < 0) { - perror("mnl_socket_bind"); - exit(EXIT_FAILURE); - } + ret = mnl_socket_bind(self->sock, 0, MNL_SOCKET_AUTOPID); + EXPECT_EQ(ret, 0); ret = conntracK_count_zone(self->sock, TEST_ZONE_ID); if (ret < 0 && errno == EPERM)