@@ -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
new file mode 100755
@@ -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
Test is added for iptables-restore with no option. Shell test-suite is updated for new tests. Signed-off-by: Arushi Singhal <arushisinghal19971997@gmail.com> --- 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