diff mbox series

[net-next] selftests: netfilter: fix conntrack_dump_flush retval on unsupported kernel

Message ID 20240422103358.3511-1-fw@strlen.de (mailing list archive)
State Accepted
Commit dd99c29e83e48acf80ee1855a5a6991b3e6523f5
Delegated to: Netdev Maintainers
Headers show
Series [net-next] selftests: netfilter: fix conntrack_dump_flush retval on unsupported kernel | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/build_tools success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 4 maintainers not CCed: kadlec@netfilter.org linux-kselftest@vger.kernel.org coreteam@netfilter.org shuah@kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-04-24--15-00 (tests: 995)

Commit Message

Florian Westphal April 22, 2024, 10:33 a.m. UTC
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 <fw@strlen.de>
---
 .../selftests/net/netfilter/conntrack_dump_flush.c        | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 25, 2024, 12:30 a.m. UTC | #1
Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 22 Apr 2024 12:33:53 +0200 you wrote:
> 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
> 
> [...]

Here is the summary with links:
  - [net-next] selftests: netfilter: fix conntrack_dump_flush retval on unsupported kernel
    https://git.kernel.org/netdev/net-next/c/dd99c29e83e4

You are awesome, thank you!
diff mbox series

Patch

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)