Test is added for iptables-restore with no option.
Shell test-suite is updated for new tests.

Signed-off-by: Arushi Singhal <[email protected]>
---
 iptables/tests/shell/run-tests.sh                  |  8 ++++--
 .../save-restore/0001_restore_no_option_0          | 30 ++++++++++++++++++++++
 2 files changed, 36 insertions(+), 2 deletions(-)
 create mode 100755 
iptables/tests/shell/testcases/save-restore/0001_restore_no_option_0

diff --git a/iptables/tests/shell/run-tests.sh 
b/iptables/tests/shell/run-tests.sh
index cf5cbdc..2cfa79d 100755
--- a/iptables/tests/shell/run-tests.sh
+++ b/iptables/tests/shell/run-tests.sh
@@ -5,6 +5,7 @@ TESTDIR="./$(dirname $0)/"
 RETURNCODE_SEPARATOR="_"
 XTABLES_MULTI="$(dirname $0)/../../xtables-multi"
 DIFF=$(which diff)
+RETURNCODE_SEPARATOR="_"
 
 msg_error() {
         echo "E: $1 ..." >&2
@@ -96,11 +97,14 @@ do
 
        for it in iptables ip6tables; do
                kernel_cleanup
-               rc_spec=`echo $(basename ${testfile}) | cut -d _ -f2-`
+               rc_spec=$(awk -F${RETURNCODE_SEPARATOR} '{print $NF}' <<< 
$testfile)
+
                IPTABLES="$XTABLES_MULTI $it"
+               IPTABLES_SAVE="$XTABLES_MULTI "$it"-save"
+               IPTABLES_RESTORE="$XTABLES_MULTI "$it"-restore"
 
                msg_info "[EXECUTING]   $testfile"
-               test_output=$(IPTABLES=$IPTABLES ${testfile} 2>&1)
+               test_output=$(IPTABLES=$IPTABLES IPTABLES_SAVE=$IPTABLES_SAVE 
IPTABLES_RESTORE=$IPTABLES_RESTORE ${testfile} 2>&1)
                rc_got=$?
                echo -en "\033[1A\033[K" # clean the [EXECUTING] foobar line
 
diff --git 
a/iptables/tests/shell/testcases/save-restore/0001_restore_no_option_0 
b/iptables/tests/shell/testcases/save-restore/0001_restore_no_option_0
new file mode 100755
index 0000000..4de285b
--- /dev/null
+++ b/iptables/tests/shell/testcases/save-restore/0001_restore_no_option_0
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+set -e
+
+DIFF=$(which diff)
+
+$IPTABLES -N FOO
+$IPTABLES -I INPUT
+$IPTABLES -I FOO
+$IPTABLES -I FOO
+$IPTABLES -L > temp
+$IPTABLES_SAVE > A
+$IPTABLES_RESTORE < A
+$IPTABLES -N BAR
+$IPTABLES -A BAR
+$IPTABLES_RESTORE  < A
+$IPTABLES -L > temp1
+
+if $DIFF temp temp1 >/dev/null ; then
+       rm -f temp
+       rm -f temp1
+       rm -f A
+       exit 0
+else
+       echo "$test_output"
+       rm -f temp
+       rm -f temp1
+       rm -f A
+       exit 1
+fi
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to