This patch adds test cases for a variable definition and redefinition.
Signed-off-by: Varsha Rao <rvarsha016@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
--- /dev/null
+#!/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
--- /dev/null
+#!/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
--- /dev/null
+#!/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