]>
Commit | Line | Data |
---|---|---|
89c4ed63 A |
1 | #!/usr/local/bin/bash |
2 | # run tpkg tests from within a VM. Looks for loopback addr. | |
3 | # if run not from within a VM, runs the tests as usual. | |
4 | # with one argument: run that tpkg, otherwise, run all tpkgs. | |
5 | ||
6 | get_lo0_ip4() { | |
7 | if test -x /sbin/ifconfig | |
8 | then | |
9 | LO0_IP4=`/sbin/ifconfig lo0 | grep '[^0-9]127\.' | sed -e 's/^[^1]*\(127\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\)[^0-9]*.*$/\1/g'` | |
10 | if ( echo $LO0_IP4 | grep '^127\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*$' > /dev/null ) | |
11 | then | |
12 | return | |
13 | fi | |
14 | fi | |
15 | LO0_IP4=127.0.0.1 | |
16 | } | |
17 | get_lo0_ip4 | |
18 | export LO0_IP4 | |
19 | if test "x$LO0_IP4" = "x127.0.0.1" | |
20 | then | |
21 | ALT_LOOPBACK=false | |
22 | else | |
23 | ALT_LOOPBACK=true | |
24 | fi | |
25 | cd testdata | |
26 | TPKG=../testcode/mini_tpkg.sh | |
27 | #RUNLIST=`(ls -1 *.tpkg|grep -v '^0[016]')` | |
28 | RUNLIST=`(ls -1 *.tpkg)` | |
29 | if test "$#" = "1"; then RUNLIST="$1"; fi | |
30 | ||
31 | # fix up tpkg that was edited on keyboard interrupt. | |
32 | cleanup() { | |
33 | echo cleanup | |
34 | if test -f "$t.bak"; then mv "$t.bak" "$t"; fi | |
35 | exit 0 | |
36 | } | |
37 | trap cleanup SIGINT | |
38 | ||
39 | for t in $RUNLIST | |
40 | do | |
41 | if ! $ALT_LOOPBACK | |
42 | then | |
43 | $TPKG exe $t | |
44 | continue | |
45 | fi | |
46 | # We have alternative 127.0.0.1 number | |
47 | if ( echo $t | grep '6\.tpkg$' ) # skip IPv6 tests | |
48 | then | |
49 | continue | |
50 | elif test "$t" = "edns_cache.tpkg" # This one is IPv6 too! | |
51 | then | |
52 | continue | |
53 | fi | |
54 | cp -p "$t" "$t.bak" | |
55 | tar xzf $t | |
56 | find "${t%.tpkg}.dir" -type f \ | |
57 | -exec grep -q -e '127\.0\.0\.1' -e '@localhost' {} \; -print | { | |
58 | while read f | |
59 | do | |
60 | sed "s/127\.0\.0\.1/${LO0_IP4}/g" "$f" > "$f._" | |
61 | mv "$f._" "$f" | |
62 | sed "s/@localhost/@${LO0_IP4}/g" "$f" > "$f._" | |
63 | mv "$f._" "$f" | |
64 | done | |
65 | } | |
66 | find "${t%.tpkg}.dir" -type d -name "127.0.0.1" -print | { | |
67 | while read d | |
68 | do | |
69 | mv -v "$d" "${d%127.0.0.1}${LO0_IP4}" | |
70 | done | |
71 | } | |
72 | tar czf $t "${t%.tpkg}.dir" | |
73 | rm -fr "${t%.tpkg}.dir" | |
74 | $TPKG exe $t | |
75 | mv "$t.bak" "$t" | |
76 | done | |
77 | # get out of testdata/ | |
78 | cd .. |