run_vm.sh revision 1.1.1.2
1#!/usr/local/bin/bash 2# run tdir 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 tdir, otherwise, run all tdirs. 5 6get_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} 17get_lo0_ip4 18export LO0_IP4 19if test "x$LO0_IP4" = "x127.0.0.1" 20then 21 ALT_LOOPBACK=false 22else 23 ALT_LOOPBACK=true 24fi 25cd testdata 26TPKG=../testcode/mini_tdir.sh 27#RUNLIST=`(ls -1d *.tdir|grep -v '^0[016]')` 28RUNLIST=`(ls -1d *.tdir)` 29if test "$#" = "1"; then RUNLIST="$1"; fi 30 31# fix up tdir that was edited on keyboard interrupt. 32cleanup() { 33 echo cleanup 34 if test -f "$t.bak"; then mv "$t.bak" "$t"; fi 35 exit 0 36} 37trap cleanup SIGINT 38 39for t in $RUNLIST 40do 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\.tdir$' ) # skip IPv6 tests 48 then 49 continue 50 elif test "$t" = "edns_cache.tdir" # This one is IPv6 too! 51 then 52 continue 53 fi 54 cp -ap "$t" "$t.bak" 55 find "${t}" -type f \ 56 -exec grep -q -e '127\.0\.0\.1' -e '@localhost' {} \; -print | { 57 while read f 58 do 59 sed "s/127\.0\.0\.1/${LO0_IP4}/g" "$f" > "$f._" 60 mv "$f._" "$f" 61 sed "s/@localhost/@${LO0_IP4}/g" "$f" > "$f._" 62 mv "$f._" "$f" 63 done 64 } 65 find "${t}" -type d -name "127.0.0.1" -print | { 66 while read d 67 do 68 mv -v "$d" "${d%127.0.0.1}${LO0_IP4}" 69 done 70 } 71 $TPKG exe $t 72 rm -fr "${t}" 73 mv "$t.bak" "$t" 74done 75# get out of testdata/ 76cd .. 77