tests: shell: add and use feature probing
Florian Westphal
maintainercover tests: shell: add and use feature probing
This series allows to run run-tests.sh on the centos-stream-9 kernel, which is based on 5.14.y, with all tests either passing or getting skipped as the feature tested isn't available.
Before:
I: results: [OK] 366 [FAILED] 7 [TOTAL] 373
After:
I: results: [OK] 370 [FAILED] 0 [SKIPPED] 3 [TOTAL] 373
First patch adds feature probe skeleton, second patch adds feature probe for netdev chains without a device.
Third patch alters a few test cases to no longer depend on 'inner header offset base'.
Patch 4 adds and uses feature probe test for treating maps like sets and last patch does the same for the inner header base offset.
Florian Westphal (5):
tests: add feature probing
tests: shell: let netdev_chain_0 test indicate SKIP if kernel requires
netdev device
tests: shell: typeof_integer/raw: prefer @nh for payload matching
tests: shell: add and use feature probe for map query like a set
tests: shell skip inner matching tests if unsupported
tests/shell/features/chain_binding.nft | 7 +++ tests/shell/features/inner_matching.nft | 7 +++ tests/shell/features/map_lookup.nft | 11 ++++ .../features/netdev_chain_without_device.nft | 7 +++ tests/shell/run-tests.sh | 35 ++++++++++++- tests/shell/testcases/chains/netdev_chain_0 | 2 + .../testcases/maps/dumps/typeof_integer_0.nft | 4 +- .../testcases/maps/dumps/typeof_raw_0.nft | 4 +- tests/shell/testcases/maps/typeof_integer_0 | 4 +- .../testcases/maps/typeof_maps_add_delete | 35 ++++++++++--- tests/shell/testcases/maps/typeof_raw_0 | 4 +- .../testcases/sets/dumps/typeof_raw_0.nft | 4 +- tests/shell/testcases/sets/inner_0 | 2 + tests/shell/testcases/sets/typeof_raw_0 | 4 +- tests/shell/testcases/transactions/30s-stress | 52 ++++++++++++++++--- 15 files changed, 154 insertions(+), 28 deletions(-) create mode 100644 tests/shell/features/chain_binding.nft create mode 100644 tests/shell/features/inner_matching.nft create mode 100644 tests/shell/features/map_lookup.nft create mode 100644 tests/shell/features/netdev_chain_without_device.nft
Signature · 1 line
2.41.0
Florian Westphal
maintainerPATCH 1/5 tests: add feature probing
Running selftests on older kernels makes some of them fail very early because some tests use features that are not available on older kernels, e.g. -stable releases.
Known examples:
- inner header matching
- anonymous chains
- elem delete from packet path
Also, some test cases might fail because a feature isn't compiled in, such as netdev chains for example.
This adds a feature-probing to the shell tests.
Simply drop a 'nft -f' compatible file with a .nft suffix into tests/shell/features.
run-tests.sh will load it via --check and will add
NFT_TESTS_HAVE_${filename}=$?
to the environment.
The test script can then either elide a part of the test or replace it with a supported feature subset.
This adds the probing skeleton, a probe file for chain_binding and alters 30s-stress to suppress anonon chains when its unuspported.
Note that 30s-stress is optionally be run standalone, so this adds more code than needed, for tests that always run via run-tests.sh its enough to do
[ $NFT_HAVE_chain_binding -eq 1 ] && test_chain_binding
--- tests/shell/features/chain_binding.nft | 7 +++ tests/shell/run-tests.sh | 24 +++++++++ tests/shell/testcases/transactions/30s-stress | 52 ++++++++++++++++--- 3 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 tests/shell/features/chain_binding.nft
tests/shell/features/chain_binding.nft new file +7 -0
@@ -0,0 +1,7 @@ +# d0e2c7de92c7 ("netfilter: nf_tables: add NFT_CHAIN_BINDING") +# v5.9-rc1~133^2~302^2~1 +table ip t { + chain c { + jump { counter; } + } +}
tests/shell/run-tests.sh +24 -0
@@ -163,6 +163,24 @@ ok=0 failed=0 taint=0 +check_features() +{ + for ffilename in $TESTDIR/../features/*.nft; do + feature=$(basename $ffilename) + + feature=${feature#*/} + feature=${feature%*.nft} + + eval NFT_HAVE_${feature}=0 + $NFT --check -f "$ffilename" 2>/dev/null + if [ $? -eq 0 ]; then + eval NFT_HAVE_${feature}=1 + fi + + export NFT_HAVE_${feature} + done +} + check_taint() { read taint_now < /proc/sys/kernel/tainted
@@ -211,6 +229,7 @@ check_kmemleak() fi } +check_features check_taint for testfile in $(find_tests)
@@ -277,5 +296,10 @@ check_kmemleak_force msg_info "results: [OK] $ok [FAILED] $failed [TOTAL] $((ok+failed))" +if [ "$VERBOSE" == "y" ] ; then + echo "Probed Features:" + env | grep NFT_HAVE_ +fi + kernel_cleanup [ "$failed" -eq 0 ]
tests/shell/testcases/transactions/30s-stress +45 -7
102 lines not on this page · raw message
Signature · 1 line
2.41.0
Phil Sutter
reviewerRe: [PATCH nft 1/5] tests: add feature probing
Quoted 12 lines · Florian Westphal
Running selftests on older kernels makes some of them fail very early because some tests use features that are not available on older kernels, e.g. -stable releases.
Known examples:
- inner header matching
- anonymous chains
- elem delete from packet pathAlso, some test cases might fail because a feature isn't compiled in, such as netdev chains for example.
Quoted 8 lines
This adds a feature-probing to the shell tests.
Simply drop a 'nft -f' compatible file with a .nft suffix into tests/shell/features.
run-tests.shwill load it via --check and will addNFT_TESTS_HAVE_${filename}=$?
Maybe make this:
| truefalse=(true false)
| NFT_TESTS_HAVE_${filename}=${truefalse[$?]}
[...]
Quoted 1 line
[ $NFT_HAVE_chain_binding -eq 1 ] &&
test_chain_binding
So this becomes:
| $NFT_HAVE_chain_binding && test_chain_binding
Use of true/false appears to work in dash, so might be POSIX sh compatible?
Cheers, Phil
Florian Westphal
maintainerRe: [PATCH nft 1/5] tests: add feature probing
Quoted 29 lines · Phil Sutter
Quoted 12 lines · Florian Westphal
Running selftests on older kernels makes some of them fail very early because some tests use features that are not available on older kernels, e.g. -stable releases.
Known examples:
- inner header matching
- anonymous chains
- elem delete from packet pathAlso, some test cases might fail because a feature isn't compiled in, such as netdev chains for example.
Quoted 8 lines
This adds a feature-probing to the shell tests.
Simply drop a 'nft -f' compatible file with a .nft suffix into tests/shell/features.
run-tests.shwill load it via --check and will addNFT_TESTS_HAVE_${filename}=$?
Maybe make this:
| truefalse=(true false)
| NFT_TESTS_HAVE_${filename}=${truefalse[$?]}[...]
Quoted 8 lines
Quoted 1 line
[ $NFT_HAVE_chain_binding -eq 1 ] &&
test_chain_bindingSo this becomes:
| $NFT_HAVE_chain_binding &&
test_chain_bindingUse of true/false appears to work in dash, so might be POSIX sh compatible?
Can do that, but if [ false ] evaluates to true...
Phil Sutter
reviewerRe: [PATCH nft 1/5] tests: add feature probing
Quoted 32 lines · Florian Westphal
Quoted 31 lines · Phil Sutter
Quoted 12 lines · Florian Westphal
Running selftests on older kernels makes some of them fail very early because some tests use features that are not available on older kernels, e.g. -stable releases.
Known examples:
- inner header matching
- anonymous chains
- elem delete from packet pathAlso, some test cases might fail because a feature isn't compiled in, such as netdev chains for example.
Quoted 8 lines
This adds a feature-probing to the shell tests.
Simply drop a 'nft -f' compatible file with a .nft suffix into tests/shell/features.
run-tests.shwill load it via --check and will addNFT_TESTS_HAVE_${filename}=$?
Maybe make this:
| truefalse=(true false)
| NFT_TESTS_HAVE_${filename}=${truefalse[$?]}[...]
Quoted 1 line
[ $NFT_HAVE_chain_binding -eq 1 ] &&
test_chain_binding
Quoted 8 lines
Quoted 6 lines
So this becomes:
| $NFT_HAVE_chain_binding &&
test_chain_bindingUse of true/false appears to work in dash, so might be POSIX sh compatible?
Can do that, but if [ false ] evaluates to true...
Sure, because that's a short-cut for '[ -n false ]'. In what context is that problematic?
Florian Westphal
maintainerRe: [PATCH nft 1/5] tests: add feature probing
Quoted 2 lines · Phil Sutter
Sure, because that's a short-cut for '[ -n false ]'. In what context is that problematic?
if [ $HAVE_NFT_foo ] ; then ...
Phil Sutter
reviewerRe: [PATCH nft 1/5] tests: add feature probing
Quoted 5 lines · Florian Westphal
Quoted 2 lines · Phil Sutter
Sure, because that's a short-cut for '[ -n false ]'. In what context is that problematic?
if [ $HAVE_NFT_foo ] ; then ...
Same as if $HAVE_NFT_foo was either 0 or 1?! Obviously, with variables holding the string "true" or "false", one has to test them either via:
| if $var; then ...
or
| if [ $var == true ]; then ...
I just find code more straightforward which does "if $have_foo; then ..." instead of "if [ $have_foo -ne 1 ]; then ...". The latter makes me question whether that 1 is positive (as with C) or negative (as with shell) and whether there are more possible values than two and any but 1 are OK.
Cheers, Phil
Re: [PATCH nft 1/5] tests: add feature probing
In reply to Phil SutterQuoted 32 lines · Phil Sutter
Quoted 13 lines · Florian Westphal
Running selftests on older kernels makes some of them fail very early
because some tests use features that are not available on older kernels, e.g. -stable releases.Known examples:
- inner header matching
- anonymous chains
- elem delete from packet pathAlso, some test cases might fail because a feature isn't compiled in, such as netdev chains for example.
Quoted 8 lines
This adds a feature-probing to the shell tests.
Simply drop a 'nft -f' compatible file with a .nft suffix into tests/shell/features.
run-tests.shwill load it via --check and will addNFT_TESTS_HAVE_${filename}=$?
Maybe make this:
Quoted 2 lines
truefalse=(true false)
NFT_TESTS_HAVE_${filename}=${truefalse[$?]}[...]
Quoted 1 line
[ $NFT_HAVE_chain_binding -eq 1 ] &&
test_chain_binding
Quoted 9 lines
So this becomes:
Quoted 1 line
$NFT_HAVE_chain_binding &&
test_chain_bindingUse of true/false appears to work in dash, so might be POSIX sh compatible?
Cheers, Phil
That's possible. But I would not do such non-obvious magic.
The existing variables like VERBOSE,VALGRIND,DUMPGEN use "y" for true and everything else is false. I'd stick with that form.
The form would be (exactly):
if [ "$NFT_TESTS_HAVE_chain_binding" = y ] ; then
Btw, as a matter of principle, I think that all variables in the patch set should be quoted.
Thomas
Re: [PATCH nft 1/5] tests: add feature probing
In reply to Florian WestphalQuoted 9 lines · Florian Westphal
Running selftests on older kernels makes some of them fail very early because some tests use features that are not available on older kernels, e.g. -stable releases.
Known examples:
- inner header matching
- anonymous chains
- elem delete from packet path
Quoted 4 lines
Also, some test cases might fail because a feature isn't compiled in, such as netdev chains for example.
This adds a feature-probing to the shell tests.
On my Fedora 38, I have currently 7 tests failing.
With this patchset, tests/shell/testcases/maps/typeof_maps_add_delete is now skipped (6 failing left).
Nice!
tests/shell/run-tests.sh ok=0 · line 177
Quoted 12 lines
tests/shell/run-tests.sh +12
-0+check_features() +{ + for ffilename in $TESTDIR/../features/*.nft; do + feature=$(basename $ffilename) + + feature=${feature#*/} + feature=${feature%*.nft} + + eval NFT_HAVE_${feature}=0 + $NFT --check -f "$ffilename" 2>/dev/null + if [ $? -eq 0 ]; then + eval NFT_HAVE_${feature}=1
the existing variables like VERBOSE,VALGRIND use "y" for true and everything else is false.
I think 0|1 looks better. But it should be consistent. If 0|1 is used, the other variables should be adjusted.
Note that on the other branch I added normalization functions bool_y()/bool_n() to accept values like true/1/y/yes from the user, and normalize to y|n. This could be changed internally to 1|0 without breaking user setups.
tests/shell/run-tests.sh check_kmemleak_force · line 302
Quoted 9 lines
for testfile in $(find_tests)
(quoted diff) +0
-0@@ -277,5 +296,10 @@ check_kmemleak_force
msg_info "results: [OK] $ok [FAILED] $failed [TOTAL] $((ok+failed))"tests/shell/run-tests.sh +4
-0+if [ "$VERBOSE" == "y" ] ; then + echo "Probed Features:" + env | grep NFT_HAVE_ +fi
xxx=$'\nNFT_HAVE_XXXXX=bogus' ./tests/shell/run-tests.sh /bin/true -v
gives the wrong output. Could be instead:
for v in $(compgen -v | grep '^NFT_HAVE_') ; do
echo "$v=${!v}";
doneFlorian Westphal
maintainerPATCH 2/5 tests: shell: let netdev_chain_0 test indicate SKIP if kernel requires netdev device
In reply to Florian WestphalThis test case only works on kernel 6.4+.
Add feature probe for this and then exit early.
We don't want to indicate a test failure, as this test doesn't apply on older kernels.
But we should not indicate sucess either, else we might be fooled in case something went wrong during feature probe.
Add a special return value, 123, and let run-tests.sh count this as 'SKIPPED'.
--- tests/shell/features/netdev_chain_without_device.nft | 7 +++++++ tests/shell/run-tests.sh | 11 ++++++++++- tests/shell/testcases/chains/netdev_chain_0 | 2 ++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/shell/features/netdev_chain_without_device.nft
tests/shell/features/netdev_chain_without_device.nft new file +7 -0
@@ -0,0 +1,7 @@ +# 207296f1a03b ("netfilter: nf_tables: allow to create netdev chain without device") +# v6.4-rc1~132^2~14^2 +table netdev t { + chain c { + type filter hook ingress priority 0; policy accept; + } +}
tests/shell/run-tests.sh +10 -1
@@ -161,6 +161,7 @@ fi echo "" ok=0 failed=0 +skipped=0 taint=0 check_features()
@@ -270,6 +271,9 @@ do msg_warn "[DUMP FAIL] $testfile" fi fi + elif [ "$rc_got" -eq 123 ]; then + ((skipped++)) + msg_info "[SKIPPED] $testfile" else ((failed++)) if [ "$VERBOSE" == "y" ] ; then
@@ -294,7 +298,12 @@ echo "" kmemleak_found=0 check_kmemleak_force -msg_info "results: [OK] $ok [FAILED] $failed [TOTAL] $((ok+failed))" +msg_info "results: [OK] $ok [FAILED] $failed [SKIPPED] $skipped [TOTAL] $((ok+failed+skipped))" + +if [ $ok -eq 0 -a $failed -eq 0 ]; then + # no test cases were run, indicate a failure + failed=1 +fi if [ "$VERBOSE" == "y" ] ; then echo "Probed Features:"
tests/shell/testcases/chains/netdev_chain_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +[ "$NFT_HAVE_netdev_chain_without_device" -eq 0 ] && exit 123 + ip link add d0 type dummy || { echo "Skipping, no dummy interface available" exit 0
Signature · 1 line
2.41.0
Phil Sutter
reviewerRe: [PATCH nft 2/5] tests: shell: let netdev_chain_0 test indicate SKIP if kernel requires netdev device
Quoted 11 lines · Florian Westphal
This test case only works on kernel 6.4+.
Add feature probe for this and then exit early.We don't want to indicate a test failure, as this test doesn't apply on older kernels.
But we should not indicate sucess either, else we might be fooled in case something went wrong during feature probe.
Add a special return value, 123, and let
run-tests.shcount this as 'SKIPPED'.
I suggest we adhere to Gnu automake convention:
"[...] an exit status of 0
from a test script will denote a success, an exit status of 77 a skipped test, an exit status of 99 a hard error, and any other exit status will denote a failure."[1]
Cheers, Phil
[1] https://www.gnu.org/software/automake/manual/html_node/Scripts_002dbased-Testsuites.html
Re: [PATCH nft 2/5] tests: shell: let netdev_chain_0 test indicate SKIP if kernel requires netdev device
In reply to Florian WestphalQuoted 12 lines · Florian Westphal
This test case only works on kernel 6.4+.
Add feature probe for this and then exit early.We don't want to indicate a test failure, as this test doesn't apply on older kernels.
But we should not indicate sucess either, else we might be fooled in case something went wrong during feature probe.
Add a special return value, 123, and let
run-tests.shcount this as 'SKIPPED'.
[...]
Quoted 6 lines
failed=0
+skipped=0
taint=0
check_features()(quoted diff) +0
-0@@ -270,6 +271,9 @@ do
Quoted 6 lines
msg_warn "[DUMP FAIL] $testfile" fi
fi
+ elif [ "$rc_got" -eq 123 ]; then
+ ((skipped++))
+ msg_info "[SKIPPED] $testfile"
I agree with Phil, I think this should return 77.
Btw, I did a similar patch on
[PATCH nft v5 08/19] tests/shell: interpret an exit code of 77 from scripts as "skipped"
Granted, you send your first version with this patch/idea a few hours before mine. I just point out the overlap...
Quoted 10 lines
else
((failed++))
if [ "$VERBOSE" == "y" ] ; then(quoted diff) +0
-0@@ -294,7 +298,12 @@ echo ""kmemleak_found=0
check_kmemleak_force(quoted diff) +1
-1-msg_info "results: [OK] $ok [FAILED] $failed [TOTAL] $((ok+failed))" +msg_info "results: [OK] $ok [FAILED] $failed [SKIPPED] $skipped[TOTAL] $((ok+failed+skipped))"
tests/shell/run-tests.sh echo "" · line 306
Quoted 5 lines
tests/shell/run-tests.sh +5
-0+ +if [ $ok -eq 0 -a $failed -eq 0 ]; then + # no test cases were run, indicate a failure + failed=1 +fi
I think this should be dropped.
When I run
./tests/shell/run-tests.sh tests/shell/testcases/maps/typeof_maps_add_delete
on my Fedora38, the test gets skipped. But I think the command should just give me a success. What would I do about the "failure" anyway?
Thomas
Florian Westphal
maintainerPATCH 3/5 tests: shell: typeof_integer/raw: prefer @nh for payload matching
In reply to Florian Westphal@ih fails on kernels where payload expression doesn't support the 'inner' base offset.
This test isn't about inner headers, so just use @nh which is universally available.
--- tests/shell/testcases/maps/dumps/typeof_integer_0.nft | 4 ++-- tests/shell/testcases/maps/dumps/typeof_raw_0.nft | 4 ++-- tests/shell/testcases/maps/typeof_integer_0 | 4 ++-- tests/shell/testcases/maps/typeof_raw_0 | 4 ++-- tests/shell/testcases/sets/dumps/typeof_raw_0.nft | 4 ++-- tests/shell/testcases/sets/typeof_raw_0 | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-)
tests/shell/testcases/maps/dumps/typeof_integer_0.nft +2 -2
@@ -13,8 +13,8 @@ table inet t { } chain c { - udp length . @ih,32,32 vmap @m1 - udp length . @ih,32,32 vmap @m2 + udp length . @nh,32,32 vmap @m1 + udp length . @nh,32,32 vmap @m2 udp length . @th,160,128 vmap { 47-63 . 0xe373135363130333131303735353203 : accept } } }
tests/shell/testcases/maps/dumps/typeof_raw_0.nft +2 -2
@@ -7,7 +7,7 @@ table ip x { } chain y { - ip saddr . @ih,32,32 vmap @y - ip saddr . @ih,32,32 vmap { 4.4.4.4 . 0x34 : accept, 5.5.5.5 . 0x45 : drop } + ip saddr . @nh,32,32 vmap @y + ip saddr . @nh,32,32 vmap { 4.4.4.4 . 0x34 : accept, 5.5.5.5 . 0x45 : drop } } }
tests/shell/testcases/maps/typeof_integer_0 +2 -2
@@ -13,8 +13,8 @@ EXPECTED="table inet t { } chain c { - udp length . @ih,32,32 vmap @m1 - udp length . @ih,32,32 vmap @m2 + udp length . @nh,32,32 vmap @m1 + udp length . @nh,32,32 vmap @m2 udp length . @th,160,128 vmap { 47-63 . 0xe373135363130333131303735353203 : accept } } }"
tests/shell/testcases/maps/typeof_raw_0 +2 -2
@@ -7,8 +7,8 @@ EXPECTED="table ip x { } chain y { - ip saddr . @ih,32,32 vmap @y - ip saddr . @ih,32,32 vmap { 4.4.4.4 . 0x34 : accept, 5.5.5.5 . 0x45 : drop} + ip saddr . @nh,32,32 vmap @y + ip saddr . @nh,32,32 vmap { 4.4.4.4 . 0x34 : accept, 5.5.5.5 . 0x45 : drop} } }"
tests/shell/testcases/sets/dumps/typeof_raw_0.nft +2 -2
@@ -6,7 +6,7 @@ table inet t { } chain y { - ip saddr . @ih,32,32 { 1.1.1.1 . 0x14, 2.2.2.2 . 0x1e } - ip daddr . @ih,32,32 @y + ip saddr . @nh,32,32 { 1.1.1.1 . 0x14, 2.2.2.2 . 0x1e } + ip daddr . @nh,32,32 @y } }
tests/shell/testcases/sets/typeof_raw_0 +2 -2
@@ -7,8 +7,8 @@ EXPECTED="table inet t { } chain y { - ip saddr . @ih,32,32 { 1.1.1.1 . 0x14, 2.2.2.2 . 0x1e } - ip daddr . @ih,32,32 @y + ip saddr . @nh,32,32 { 1.1.1.1 . 0x14, 2.2.2.2 . 0x1e } + ip daddr . @nh,32,32 @y } }"
Signature · 1 line
2.41.0
Florian Westphal
maintainerPATCH 4/5 tests: shell: add and use feature probe for map query like a set
In reply to Florian WestphalOn recent kernels one can perform a lookup in a map without a destination register (i.e., treat the map like a set -- pure existence check).
Add a feature probe and work around the missing feature intypeof_maps_add_delete: do the test with a simplified ruleset,
Indicate skipped even though a reduced test was run (earlier errors cause a failure) to not trigger dump validation error.
--- tests/shell/features/map_lookup.nft | 11 ++++++ .../testcases/maps/typeof_maps_add_delete | 35 ++++++++++++++----- 2 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 tests/shell/features/map_lookup.nft
tests/shell/features/map_lookup.nft new file +11 -0
@@ -0,0 +1,11 @@ +# a4878eeae390 ("netfilter: nf_tables: relax set/map validation checks") +# v6.5-rc1~163^2~256^2~8 +table ip t { + map m { + typeof ip daddr : meta mark + } + + chain c { + ip saddr @m + } +}
tests/shell/testcases/maps/typeof_maps_add_delete +27 -8
@@ -1,6 +1,15 @@ #!/bin/bash -EXPECTED='table ip dynset { +CONDMATCH="ip saddr @dynmark" +NCONDMATCH="ip saddr != @dynmark" + +# use reduced feature set +if [ $NFT_HAVE_map_lookup -eq 0 ] ;then + CONDMATCH="" + NCONDMATCH="" +fi + +EXPECTED="table ip dynset { map dynmark { typeof ip daddr : meta mark counter
@@ -9,20 +18,20 @@ EXPECTED='table ip dynset { } chain test_ping { - ip saddr @dynmark counter comment "should not increment" - ip saddr != @dynmark add @dynmark { ip saddr : 0x1 } counter - ip saddr @dynmark counter comment "should increment" - ip saddr @dynmark delete @dynmark { ip saddr : 0x1 } - ip saddr @dynmark counter comment "delete should be instant but might fail under memory pressure" + $CONDMATCH counter comment \"should not increment\" + $NCONDMATCH add @dynmark { ip saddr : 0x1 } counter + $CONDMATCH counter comment \"should increment\" + $CONDMATCH delete @dynmark { ip saddr : 0x1 } + $CONDMATCH counter comment \"delete should be instant but might fail under memory pressure\" } chain input { type filter hook input priority 0; policy accept; - add @dynmark { 10.2.3.4 timeout 1s : 0x2 } comment "also check timeout-gc" + add @dynmark { 10.2.3.4 timeout 1s : 0x2 } comment \"also check timeout-gc\" meta l4proto icmp ip daddr 127.0.0.42 jump test_ping } -}' +}" set -e $NFT -f - <<< $EXPECTED
@@ -31,5 +40,15 @@ $NFT list ruleset ip link set lo up ping -c 1 127.0.0.42 +$NFT get element ip dynset dynmark { 10.2.3.4 } + # wait so that 10.2.3.4 times out. sleep 2 + +set +e +$NFT get element ip dynset dynmark { 10.2.3.4 } && exit 1 + +# success, but indicate skip for reduced test to avoid dump validation error +if [ $NFT_HAVE_map_lookup -eq 0 ];then + exit 123 +fi
Signature · 1 line
2.41.0
Re: [PATCH nft 4/5] tests: shell: add and use feature probe for map query like a set
tests/shell/testcases/maps/typeof_maps_add_delete $NFT list ruleset · line 54
Quoted 9 lines · Florian Westphal
tests/shell/testcases/maps/typeof_maps_add_delete +4
-0+set +e +$NFT get element ip dynset dynmark { 10.2.3.4 } && exit 1 + +# success, but indicate skip for reduced test to avoid dumpvalidation error
tests/shell/testcases/maps/typeof_maps_add_delete +3
-0+if [ $NFT_HAVE_map_lookup -eq 0 ];then + exit 123 +fi
Instead of adding a comment, print a message with the reason why it was skipped. That's useful information to see in the test output. The echo line also makes the comment redundant.
Thomas
Florian Westphal
maintainerPATCH 5/5 tests: shell skip inner matching tests if unsupported
In reply to Florian Westphal--- tests/shell/features/inner_matching.nft | 7 +++++++ tests/shell/testcases/sets/inner_0 | 2 ++ 2 files changed, 9 insertions(+) create mode 100644 tests/shell/features/inner_matching.nft
tests/shell/features/inner_matching.nft new file +7 -0
@@ -0,0 +1,7 @@ +# 3a07327d10a0 ("netfilter: nft_inner: support for inner tunnel header matching") +# v6.2-rc1~99^2~350^2~4 +table ip t { + chain c { + udp dport 4789 vxlan ip saddr 1.2.3.4 + } +}
tests/shell/testcases/sets/inner_0 +2 -0
@@ -1,5 +1,7 @@ #!/bin/bash +[ $NFT_HAVE_inner_matching -eq 0 ] && exit 123 + set -e RULESET="table netdev x {
Signature · 1 line
2.41.0