Skip to contentSkip to conversation

tests: shell: delete useless stderr output in testcase

PATCH In review Arturo Borrero Gonzalez 2 participants 4 messages Nov 3, 2016 – Nov 8, 2016 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 tests: shell: delete useless stderr output in testcase

From: Arturo Borrero Gonzalez <[email protected]>

This stderr output is expected.

---
 tests/shell/testcases/transactions/0014chain_1 |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/shell/testcases/transactions/0014chain_1 +1 -1
index a03ef12..955860d 100755
@@ -16,5 +16,5 @@ delete chain x y
 delete chain x y"
 
 echo "$RULESET" > $tmpfile
-$NFT -f $tmpfile
+$NFT -f $tmpfile 2>/dev/null
 echo "E: allowing double-removal of chain" >&2
#1 lore raw

PATCH 2/3 tests: shell: introduce the cache testcases directory

From: Arturo Borrero Gonzalez <[email protected]>

This directory is for testcases related to the nft cache.

---
 tests/shell/testcases/cache/0001_cache_handling_0 |   29 +++++++++++++++++++++
 tests/shell/testcases/sets/cache_handling_0       |   29 ---------------------
 2 files changed, 29 insertions(+), 29 deletions(-)
 create mode 100755 tests/shell/testcases/cache/0001_cache_handling_0
 delete mode 100755 tests/shell/testcases/sets/cache_handling_0
tests/shell/testcases/cache/0001_cache_handling_0 new file +29 -0
new file mode 100755
index 0000000..9a73769
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+tmpfile=$(mktemp)
+if [ ! -w $tmpfile ] ; then
+	echo "Failed to create tmp file" >&2
+	exit 0
+fi
+
+trap "rm -rf $tmpfile" EXIT # cleanup if aborted
+
+echo "
+table inet test {
+	set test {
+		type ipv4_addr
+		elements = { 1.1.1.1}
+	}
+
+	chain test {
+		ip saddr @test counter accept
+		ip daddr { 2.2.2.2} counter accept
+	}
+}" > $tmpfile
+
+set -e
+
+$NFT -f $tmpfile
+$NFT delete rule inet test test handle 2
+$NFT delete set inet test test
+$NFT -f $tmpfile
tests/shell/testcases/sets/cache_handling_0 deleted +0 -29
deleted file mode 100755
index 9a73769..0000000
@@ -1,29 +0,0 @@
-#!/bin/bash
-
-tmpfile=$(mktemp)
-if [ ! -w $tmpfile ] ; then
-	echo "Failed to create tmp file" >&2
-	exit 0
-fi
-
-trap "rm -rf $tmpfile" EXIT # cleanup if aborted
-
-echo "
-table inet test {
-	set test {
-		type ipv4_addr
-		elements = { 1.1.1.1}
-	}
-
-	chain test {
-		ip saddr @test counter accept
-		ip daddr { 2.2.2.2} counter accept
-	}
-}" > $tmpfile
-
-set -e
-
-$NFT -f $tmpfile
-$NFT delete rule inet test test handle 2
-$NFT delete set inet test test
-$NFT -f $tmpfile
#2 lore raw

PATCH 3/3 tests: shell: add a new testcase for ruleset loading bug

In reply to Arturo Borrero Gonzalez

From: Arturo Borrero Gonzalez <[email protected]>

There seems to be a bug that prevent loading a ruleset twice in a row if the ruleset contains sets with intervals. This seems related to the nft cache.

By the time of this commit, the bug is not fixed yet.

---
 tests/shell/testcases/cache/0002_interval_0 |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
 create mode 100755 tests/shell/testcases/cache/0002_interval_0
tests/shell/testcases/cache/0002_interval_0 new file +27 -0
new file mode 100755
index 0000000..f500911
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# This testcase checks that we can load a ruleset twice in a row.
+# bug --> Error: interval overlaps with an existing one
+
+set -e
+
+tmpfile=$(mktemp)
+if [ ! -w $tmpfile ] ; then
+        echo "Failed to create tmp file" >&2
+        exit 0
+fi
+
+trap "rm -rf $tmpfile" EXIT # cleanup if aborted
+
+RULESET="flush ruleset
+table inet t {
+	set s { type ipv4_addr; flags interval; }
+}
+
+add element inet t s {
+	192.168.0.1/24,
+}"
+
+echo "$RULESET" > $tmpfile
+$NFT -f $tmpfile
+$NFT -f $tmpfile