[PATCH nft 2/3] tests/shell: skip "sets/reset_command_0" on unsupported reset command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The NFT_MSG_GETSETELEM_RESET command was only added to kernel
v6.4-rc3-764-g079cd633219d. Also, it doesn't work on Fedora 38
(6.4.14-200.fc38.x86_64), although that would appear to have the
feature. On CentOS-Stream-9 (5.14.0-354.el9.x86_64) the test passes.

Note that this is not implemented via a re-usable feature detection.
Instead, we just in the middle of the test notice that it appears not to
work, and abort (skip).

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=079cd633219d7298d087cd115c17682264244c18

Signed-off-by: Thomas Haller <thaller@xxxxxxxxxx>
---
 tests/shell/testcases/sets/reset_command_0 | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tests/shell/testcases/sets/reset_command_0 b/tests/shell/testcases/sets/reset_command_0
index ad2e16a7d274..a0f5ca017b0f 100755
--- a/tests/shell/testcases/sets/reset_command_0
+++ b/tests/shell/testcases/sets/reset_command_0
@@ -2,7 +2,7 @@
 
 set -e
 
-trap '[[ $? -eq 0 ]] || echo FAIL' EXIT
+trap 'rc="$?"; [ "$rc" -ne 0 -a "$rc" -ne 77 ] && echo FAIL' EXIT
 
 RULESET="table t {
 	set s {
@@ -36,11 +36,21 @@ expires_minutes() {
 	sed -n 's/.*expires \([0-9]*\)m.*/\1/p'
 }
 
-echo -n "get set elem matches reset set elem: "
 elem='element t s { 1.0.0.1 . udp . 53 }'
-[[ $($NFT "get $elem ; reset $elem" | \
-	grep 'elements = ' | drop_seconds | uniq | wc -l) == 1 ]]
-echo OK
+
+rc=0
+OUT="$( $NFT "get $elem ; reset $elem" )" || rc=$?
+if [ "$rc" -ne 0 ] ; then
+	echo "Command \`nft \"get $elem ; reset $elem\"\` failed. Assume reset is not supported. SKIP"
+	exit 77
+fi
+
+[ "$(printf '%s\n' "$OUT" | \
+      grep 'elements = ' | \
+      drop_seconds | \
+      uniq | \
+      wc -l)" = 1 ] || die "Unexpected output getting elements: \`nft \"get $elem ; reset $elem\"\`"$'\nOutput\n>'"$OUT"'<'
+echo "get set elem matches reset set elem: OK"
 
 echo -n "counters and expiry are reset: "
 NEW=$($NFT "get $elem")
-- 
2.41.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux