[PATCH nft 5/9] tests: shell: Add tests for variable definition.

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

 



This patch adds test cases for a variable definition and redefinition.

Signed-off-by: Varsha Rao <rvarsha016@xxxxxxxxx>
---
 tests/shell/testcases/nft-f/0013defines_1 | 25 +++++++++++++++++++++++++
 tests/shell/testcases/nft-f/0014defines_1 | 25 +++++++++++++++++++++++++
 tests/shell/testcases/nft-f/0015defines_1 | 24 ++++++++++++++++++++++++
 3 files changed, 74 insertions(+)
 create mode 100755 tests/shell/testcases/nft-f/0013defines_1
 create mode 100755 tests/shell/testcases/nft-f/0014defines_1
 create mode 100755 tests/shell/testcases/nft-f/0015defines_1

diff --git a/tests/shell/testcases/nft-f/0013defines_1 b/tests/shell/testcases/nft-f/0013defines_1
new file mode 100755
index 0000000..5519703
--- /dev/null
+++ b/tests/shell/testcases/nft-f/0013defines_1
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Tests use of variable before definition.
+
+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
+
+echo "
+define var2 = \$var1
+define var1 = lo
+
+table ip t {
+	chain c {
+		iif \$var2
+	}
+}" >> $tmpfile
+
+$NFT -f $tmpfile
diff --git a/tests/shell/testcases/nft-f/0014defines_1 b/tests/shell/testcases/nft-f/0014defines_1
new file mode 100755
index 0000000..914d910
--- /dev/null
+++ b/tests/shell/testcases/nft-f/0014defines_1
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+# Tests redefinition of an existing variable.
+
+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
+
+echo "
+define var1 = lo
+define var1 = lo
+
+table ip t {
+	chain c {
+		iif \$var1
+	}
+}" >> $tmpfile
+
+$NFT -f $tmpfile
diff --git a/tests/shell/testcases/nft-f/0015defines_1 b/tests/shell/testcases/nft-f/0015defines_1
new file mode 100755
index 0000000..1f9db11
--- /dev/null
+++ b/tests/shell/testcases/nft-f/0015defines_1
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# Tests recursive definition of a variable.
+
+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
+
+echo "
+define var1 = \$var1
+
+table ip t {
+	chain c {
+		iif \$var1
+	}
+}" >> $tmpfile
+
+$NFT -f $tmpfile
-- 
2.13.6

--
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