summaryrefslogtreecommitdiffstats
path: root/iptables/tests/shell/testcases/ipt-save/0001load-dumps_0
blob: 48f5f7b42337909eabfec509a111b09cf3f223ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash

RET=0
tmpfile=""
set -x


clean_tmpfile()
{
        if [ ! -z "$tmpfile" ];then
                rm -f "$tmpfile"
        fi
}

trap clean_tmpfile EXIT

do_diff()
{
	A="$1"
	B="$2"

	AT=$(mktemp)
	grep -v "^#" "$A" > "$AT"

	diff -u "$AT" "$B"

	x=$?
	rm -f "$AT"
	echo "Return $x for $XT_MULTI $A"

	return $x
}

tmpfile=$(mktemp) || exit 1
do_simple()
{
	iptables="$1"
	dumpfile="$2"

	$XT_MULTI ${iptables}-restore < "$dumpfile"
	$XT_MULTI ${iptables}-save | grep -v "^#" > "$tmpfile"
	sed -i -e 's/-p 47 /-p gre /' "$tmpfile"
	do_diff $dumpfile "$tmpfile"
	if [ $? -ne 0 ]; then
		# cp "$tmpfile" "$dumpfile.got"
		RET=1
	fi
}

do_simple "iptables" $(dirname "$0")/dumps/ipt-save-filter.txt
do_simple "iptables" $(dirname "$0")/dumps/policy-drop.txt
do_simple "iptables" $(dirname "$0")/dumps/wireless.txt

exit $RET