From: Phil Sutter Date: Thu, 13 Aug 2026 11:35:24 +0000 (+0200) Subject: tests: shell: Use --numeric-protocol for dumps X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b3b7f21663dbf8a86eb02bf90dfc539720893f59;p=thirdparty%2Fnftables.git tests: shell: Use --numeric-protocol for dumps The py test suite does this as well. Protocol names depend on contents of /etc/protocols which is not in control of nftables. Using numeric protocol values for dumps therefore prevents the host system from compromising test results. Signed-off-by: Phil Sutter --- diff --git a/tests/shell/helpers/test-wrapper.sh b/tests/shell/helpers/test-wrapper.sh index 7a73e531..78a01d56 100755 --- a/tests/shell/helpers/test-wrapper.sh +++ b/tests/shell/helpers/test-wrapper.sh @@ -152,21 +152,22 @@ fi rc_chkdump=0 rc=0 -$NFT list ruleset > "$NFT_TEST_TESTTMPDIR/ruleset-after" 2> "$NFT_TEST_TESTTMPDIR/chkdump" || rc=$? +chkdump_nft="$NFT --numeric-protocol" +$chkdump_nft list ruleset > "$NFT_TEST_TESTTMPDIR/ruleset-after" 2> "$NFT_TEST_TESTTMPDIR/chkdump" || rc=$? if [ "$rc" -ne 0 -o -s "$NFT_TEST_TESTTMPDIR/chkdump" ] ; then - show_file "$NFT_TEST_TESTTMPDIR/chkdump" "Command \`$NFT list ruleset\` failed" >> "$NFT_TEST_TESTTMPDIR/rc-failed-chkdump" + show_file "$NFT_TEST_TESTTMPDIR/chkdump" "Command \`$chkdump_nft list ruleset\` failed" >> "$NFT_TEST_TESTTMPDIR/rc-failed-chkdump" rc_chkdump=1 fi if [ "$NFT_TEST_HAVE_json" != n ] ; then rc=0 - $NFT -j list ruleset > "$NFT_TEST_TESTTMPDIR/ruleset-after.json" 2> "$NFT_TEST_TESTTMPDIR/chkdump" || rc=$? + $chkdump_nft -j list ruleset > "$NFT_TEST_TESTTMPDIR/ruleset-after.json" 2> "$NFT_TEST_TESTTMPDIR/chkdump" || rc=$? # Workaround known bug in stmt_print_json(), due to # "chain_stmt_ops.json" being NULL. This spams stderr. sed -i '/^warning: stmt ops chain have no json callback$/d' "$NFT_TEST_TESTTMPDIR/chkdump" if [ "$rc" -ne 0 -o -s "$NFT_TEST_TESTTMPDIR/chkdump" ] ; then - show_file "$NFT_TEST_TESTTMPDIR/chkdump" "Command \`$NFT -j list ruleset\` failed" >> "$NFT_TEST_TESTTMPDIR/rc-failed-chkdump" + show_file "$NFT_TEST_TESTTMPDIR/chkdump" "Command \`$chkdump_nft -j list ruleset\` failed" >> "$NFT_TEST_TESTTMPDIR/rc-failed-chkdump" rc_chkdump=1 fi # JSON output needs normalization/sanitization, otherwise it's not stable.