Debian Codegraph @

tests/shell/testcases/include/0012glob_dependency_1

raw
1 #!/bin/bash
2
3 # Files are included in alphabetical order.
4
5 set -e
6
7 tmpdir=$(mktemp -d)
8 if [ ! -d $tmpdir ] ; then
9 echo "Failed to create tmp directory" >&2
10 exit 0
11 fi
12
13 tmpfile1="$tmpdir/01_file.nft"
14 touch $tmpfile1
15 if [ ! -w $tmpfile1 ] ; then
16 echo "Failed to create tmp file" >&2
17 exit 0
18 fi
19
20 tmpfile2="$tmpdir/02_file.nft"
21 touch $tmpfile2
22 if [ ! -w $tmpfile2 ] ; then
23 echo "Failed to create tmp file" >&2
24 exit 0
25 fi
26
27 tmpfile3=$(mktemp)
28 if [ ! -w $tmpfile3 ] ; then
29 echo "Failed to create tmp file" >&2
30 exit 0
31 fi
32
33 # cleanup if aborted
34 trap "rm -rf $tmpfile1 $tmpfile2 $tmpfile3 && rmdir $tmpdir" EXIT
35
36 # add interdependent rulesets
37 RULESET1="add table x"
38 RULESET2="add chain x y"
39 RULESET3="include \"$tmpdir/*\""
40
41 # Note different order when compared with 0011dir_dependency_0. The idea
42 # here is to introduce wrong order to get the loading fail.
43 echo "$RULESET1" > $tmpfile2
44 echo "$RULESET2" > $tmpfile1
45 echo "$RULESET3" > $tmpfile3
46
47 $NFT -f $tmpfile3 || exit 0
48 echo "E: did not catch wrong file order in include directory" >&2
49 exit 1