]> git.saurik.com Git - apple/network_cmds.git/blob - unbound/testcode/testbed.sh
network_cmds-596.100.2.tar.gz
[apple/network_cmds.git] / unbound / testcode / testbed.sh
1 #!/usr/bin/env bash
2 # Testbed for NSD.
3 # By Wouter Wijngaards, NLnet Labs, 2006.
4 # BSD License.
5
6 # this version prefers gmake if available.
7 # adds variable LDNS for the LDNS path to use.
8
9 # global settings
10 CONFIGURE_FLAGS=""
11 REPORT_FILE=testdata/testbed.report
12 LOG_FILE=testdata/testbed.log
13 HOST_FILE=testdata/host_file.$USER
14
15 if test ! -f $HOST_FILE; then
16 echo "No such file: $HOST_FILE"
17 exit 1
18 fi
19
20 function echossh() # like ssh but echos.
21 {
22 echo "> ssh $*"
23 ssh $*
24 }
25
26 # Compile and run NSD on platforms
27 function dotest()
28 # parameters: <host> <dir>
29 # host is name of ssh host
30 # dir is directory of nsd trunk on host
31 {
32 echo "$1 begin on "`date` | tee -a $REPORT_FILE
33
34 DISABLE=""
35 if test $IP6 = no; then
36 DISABLE="--disable-ipv6"
37 fi
38 if test x$LDNS != x; then
39 DISABLE="--with-ldns=$LDNS $DISABLE"
40 fi
41 if test x$LIBEVENT != x; then
42 DISABLE="--with-libevent=$LIBEVENT $DISABLE"
43 fi
44
45 cat >makeconf.mak.$$ << EOF
46 #configure: configure.ac
47 # $AC_CMD
48 # touch configure
49 Makefile: Makefile.in #configure
50 ./configure $CONFIGURE_FLAGS $DISABLE
51 touch Makefile
52 EOF
53 scp makeconf.mak.$$ $1:$2
54 # determine make to use
55 tempx=`ssh $1 "cd $2; which gmake"`
56 MAKE_CMD=`ssh $1 "cd $2; if test -f '$tempx'; then echo $tempx; else echo $MAKE_CMD; fi"`
57
58 if test $SVN = yes; then
59 echossh $1 "cd $2; svn up"
60 echossh $1 "cd $2; $MAKE_CMD -f makeconf.mak.$$ configure"
61 else
62 # svn and autoconf locally
63 echo "fake svn via svnexport, tar, autoconf, bison, flex."
64 svn export svn+ssh://open.nlnetlabs.nl/svn/nsd/trunk unbound_ttt
65 (cd unbound_ttt; $AC_CMD; rm -r autom4te* .c-mode-rc.el .cvsignore)
66 if test $FIXCONFIGURE = yes; then
67 echo fixing up configure length test.
68 (cd unbound_ttt; mv configure oldconf; sed -e 's?while (test "X"?lt_cv_sys_max_cmd_len=65500; echo skip || while (test "X"?' <oldconf >configure; chmod +x ./configure)
69 fi
70 du unbound_ttt
71 rsync -vrcpz --rsync-path=/home/wouter/bin/rsync unbound_ttt $1:unbound_ttt
72 # tar czf unbound_ttt.tgz unbound_ttt
73 rm -rf unbound_ttt
74 # ls -al unbound_ttt.tgz
75 # scp unbound_ttt.tgz $1:unbound_ttt.tar.gz
76 # rm unbound_ttt.tgz
77 # echossh $1 "gtar xzf unbound_ttt.tar.gz && rm unbound_ttt.tar.gz"
78 fi
79 echossh $1 "cd $2; $MAKE_CMD -f makeconf.mak.$$ Makefile"
80 echossh $1 "cd $2; $MAKE_CMD all tests"
81 echossh $1 "cd $2; $MAKE_CMD doc"
82 if test $RUN_TEST = yes; then
83 echossh $1 "cd $2; bash testcode/do-tests.sh"
84 echossh $1 "cd $2/testdata; sh ../testcode/mini_tpkg.sh -q report" | tee -a $REPORT_FILE
85 fi
86 echossh $1 "cd $2; rm -f makeconf.mak.$$"
87 rm -f makeconf.mak.$$
88 echo "$1 end on "`date` | tee -a $REPORT_FILE
89 }
90
91 echo "on "`date`" by $USER." > $REPORT_FILE
92 echo "on "`date`" by $USER." > $LOG_FILE
93
94 # read host names
95 declare -a hostname desc dir vars
96 IFS=' '
97 i=0
98 while read a b c d; do
99 if echo $a | grep "^#" >/dev/null; then
100 continue # skip it
101 fi
102 # append after arrays
103 hostname[$i]=$a
104 desc[$i]=$b
105 dir[$i]=$c
106 vars[$i]=$d
107 i=$(($i+1))
108 done <$HOST_FILE
109 echo "testing on $i hosts"
110
111 # do the test
112 for((i=0; i<${#hostname[*]}; i=$i+1)); do
113 if echo ${hostname[$i]} | grep "^#" >/dev/null; then
114 continue # skip it
115 fi
116 # echo "hostname=[${hostname[$i]}]"
117 # echo "desc=[${desc[$i]}]"
118 # echo "dir=[${dir[$i]}]"
119 # echo "vars=[${vars[$i]}]"
120 AC_CMD="libtoolize -c --force; autoconf && autoheader"
121 MAKE_CMD="make"
122 SVN=yes
123 IP6=yes
124 FIXCONFIGURE=no
125 RUN_TEST=yes
126 LDNS=
127 LIBEVENT=
128 eval ${vars[$i]}
129 echo "*** ${hostname[$i]} ${desc[$i]} ***" | tee -a $LOG_FILE | tee -a $REPORT_FILE
130 dotest ${hostname[$i]} ${dir[$i]} 2>&1 | tee -a $LOG_FILE
131 done
132
133 echo "done"