[PATCH] tests: shell: Add test for ambguity while setting the value

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

 



This test checks bug identified and fixed in the commit mentioned below
In a statement if there are  multiple src data then it  would be
totally ambiguous to decide which value to set.

We don't add this test in python testsuite, because there we only have
"ok"  and "fail"  as return code. So, we can't detect 134 != 1 there.
(both 1 and 134 stats failure)

Test: 986dea8 ("evaluate: avoid reference to multiple src data in statements which set values")
Signed-off-by: Shyam Saini <mayhs11saini@xxxxxxxxx>
---
 .../testcases/sets/0023unknown_value_to_use_0      | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)
 create mode 100755 tests/shell/testcases/sets/0023unknown_value_to_use_0

diff --git a/tests/shell/testcases/sets/0023unknown_value_to_use_0 b/tests/shell/testcases/sets/0023unknown_value_to_use_0
new file mode 100755
index 0000000..011cedd
--- /dev/null
+++ b/tests/shell/testcases/sets/0023unknown_value_to_use_0
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+	# This test checks bug identified and fixed in the commit Id "986dea8".
+	# i.e, If in a statement there are  multiple src data then it would be totally ambiguous to decide which value to set.
+        
+	# Before this commit 986dea8, nft returns 134 which indicates the bug but after this commit it returns 1.
+	# We don't add this test in python testsuite, because there we can't detect 134 != 1 (returns code stating failure) 	
+
+declare -a rules=( 
+		 "tcp dport set {1, 2, 3}" "udp dport set {1, 2, 3}"
+		 "meta pkttype set {unicast, multicast, broadcast}"
+		 "meta mark set {0xffff, 0xcc}"
+		 "ct mark set {0x11333, 0x11}" "ct zone set {123, 127}"
+		 "ct label set {123, 127}" 
+		 "ct event set {new, related, destroy, label}"
+		 "ether daddr set {01:00:5e:00:01:01, 01:00:5e:00:02:02}"
+		 "ip saddr set {192.19.1.2, 191.1.22.1}"
+		 )
+
+$NFT add table t
+$NFT add chain t c
+
+for (( i = 0 ; i < ${#rules[@]} ; i++ ))
+do
+	$1
+	`$NFT add rule t c ${rules[$i]} 2>>/dev/null`
+	ret=$?
+	if [ $ret -ne 1 ];
+	then
+		echo "E: failed test: $1 returned $ret instead of 1" >&2
+		exit 1
+	fi
+done
+
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux