]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: add test case for rename-to-same-name
authorFlorian Westphal <fw@strlen.de>
Tue, 17 Jul 2018 05:11:12 +0000 (07:11 +0200)
committerFlorian Westphal <fw@strlen.de>
Wed, 18 Jul 2018 14:07:31 +0000 (16:07 +0200)
kernel currently permits chains with same name when a transaction renames
2 chains to the same new name.  Add a test case for this.

Signed-off-by: Florian Westphal <fw@strlen.de>
tests/shell/testcases/chains/0014rename_0 [new file with mode: 0755]
tests/shell/testcases/chains/0014rename_1 [deleted file]

diff --git a/tests/shell/testcases/chains/0014rename_0 b/tests/shell/testcases/chains/0014rename_0
new file mode 100755 (executable)
index 0000000..bebe48d
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+$NFT add table t || exit 1
+$NFT add chain t c1 || exit 1
+$NFT add chain t c2 || exit 1
+# kernel should return EEXIST
+$NFT rename chain t c1 c2
+
+if [ $? -eq 0 ] ; then
+       echo "E: Renamed with existing chain" >&2
+       exit 1
+fi
+
+# same, should return EEXIST
+$NFT 'rename chain t c1 c3;rename chain t c2 c3'
+if [ $? -eq 0 ] ; then
+       echo "E: Renamed two chains to same name" >&2
+       exit 1
+fi
diff --git a/tests/shell/testcases/chains/0014rename_1 b/tests/shell/testcases/chains/0014rename_1
deleted file mode 100755 (executable)
index e29e788..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/bash
-
-set -e
-
-$NFT add table t
-$NFT add chain t c1
-$NFT add chain t c2
-# kernel should return EEXIST
-$NFT rename chain t c1 c2
-
-if [ $? -eq 0 ] ; then
-       echo "E: Renamed with existing chain" >&2
-       exit 0
-fi