blob: 03de50b3c4992bb7308d503856d4e657991176f6 (
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
|
#!/bin/bash
# This test the changes made in commit id "b14572f72aac".
# When the commit was not applied, nft pointed to wrong files name.
# As the commit only fixes the error messages and hence does not change the
# return value so, we need to compare the "file name" in the error message
# instead of return value of nft.
tmpfile1=$(mktemp -p .)
if [ ! -w $tmpfile1 ] ; then
echo "Failed to create tmp file" >&2
exit 0
fi
tmpfile2=$(mktemp -p .)
if [ ! -w $tmpfile2 ] ; then
echo "Failed to create tmp file" >&2
exit 0
fi
tmpfile3=$(mktemp -p .)
if [ ! -w $tmpfile3 ] ; then
echo "Failed to create tmp file" >&2
exit 0
fi
tmpfile4=$(mktemp -p .)
if [ ! -w $tmpfile4 ]; then
echo "Failed to create tmp file" >&2
exit 0
fi
trap "rm -rf $tmpfile1 $tmpfile2 $tmpfile3 $tmpfile4" EXIT # cleanup if aborted
RULESET1="include \"$tmpfile2\""
RULESET2="include \"$tmpfile3\""
RULESET3="add rule x y anything everything" # wrong nft syntax
echo "$RULESET1" > $tmpfile1
echo "$RULESET2" >> $tmpfile1
echo "$RULESET3" > $tmpfile2
$NFT -f $tmpfile1 2> $tmpfile4
var=$(awk -F: '$4==" Error"{print $1;exit;}' $tmpfile4)
if [ $var == "$tmpfile3" ]; then
echo "E: Test failed" >&2
exit 1
fi
|