]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
tests: shell: cover add and create set command
authorPablo Neira Ayuso <pablo@netfilter.org>
Wed, 24 Aug 2016 14:45:07 +0000 (16:45 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 25 Aug 2016 12:22:32 +0000 (14:22 +0200)
This patch validates that creation of an already existing element
bails out with EEXIST.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
tests/shell/testcases/sets/0007create_element_0 [new file with mode: 0755]

diff --git a/tests/shell/testcases/sets/0007create_element_0 b/tests/shell/testcases/sets/0007create_element_0
new file mode 100755 (executable)
index 0000000..47b3559
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# This testcase checks for add and create element commands.
+
+set -e
+$NFT add table t
+$NFT add set t s { type ipv4_addr \; }
+$NFT add element t s { 1.1.1.1 }
+if $NFT create element t s { 1.1.1.1 } 2>/dev/null ; then
+       echo "E: accepted element creation that already exists" >&2
+       exit 1
+fi
+$NFT add element t s { 1.1.1.1 }
+
+exit 0