]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/curl/testcurl.sh
hello world
[icculus/iodoom3.git] / neo / curl / testcurl.sh
1 #!/bin/sh
2 #***************************************************************************
3 #                                  _   _ ____  _
4 #  Project                     ___| | | |  _ \| |
5 #                             / __| | | | |_) | |
6 #                            | (__| |_| |  _ <| |___
7 #                             \___|\___/|_| \_\_____|
8 #
9 # Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, et al.
10 #
11 # This software is licensed as described in the file COPYING, which
12 # you should have received as part of this distribution. The terms
13 # are also available at http://curl.haxx.se/docs/copyright.html.
14 #
15 # You may opt to use, copy, modify, merge, publish, distribute and/or sell
16 # copies of the Software, and permit persons to whom the Software is
17 # furnished to do so, under the terms of the COPYING file.
18 #
19 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20 # KIND, either express or implied.
21 #
22 # $Id: testcurl.sh,v 1.41 2004/03/09 11:24:36 bagder Exp $
23 ###########################################################################
24
25 ###########################
26 #  What is This Script?
27 ###########################
28
29 # testcurl.sh is the master script to use for automatic testing of CVS-curl.
30 # This is written for the purpose of being run from a crontab job or similar
31 # at a regular interval. The output will be suitable to be mailed automaticly
32 # to "curl-autocompile@haxx.se" to be dealt with automatically.  The most
33 # current build status (with a resonable backlog) will be published on the
34 # curl site, at http://curl.haxx.se/auto/
35
36 # USAGE:
37 # testcurl.sh [curl-daily-name] > output
38
39 # Updated: 
40 # v1.1 6-Nov-03 - to take an optional parameter, the name of a daily-build
41 #                 directory.  If present, build from that directory, otherwise
42 #                 perform a normal CVS build.
43
44 # version of this script
45 version='$Revision: 1.41 $'
46 fixed=0
47
48 # Determine if we're running from CVS or a canned copy of curl
49 if [ "$#" -ge "1" -a "$1" ]; then
50   CURLDIR=$1
51   CVS=0
52 else
53   CURLDIR="curl"
54   CVS=1
55 fi
56
57 LANG="C"
58
59 export LANG
60
61 log() {
62     text=$1
63     if test -n "$text"; then
64       echo "testcurl: $text"
65     fi
66 }
67
68 die(){
69     text=$1
70     log "$text"
71     cd $pwd # cd back to the original root dir
72
73     if test -n "$pwd/$build"; then
74       # we have a build directory name, remove the dir
75       log "removing the $build dir"
76       rm -rf "$pwd/$build"
77     fi
78     if test -r "$buildlog"; then
79       # we have a build log output file left, remove it
80       log "removing the $buildlogname file"
81       rm -rf "$buildlog"
82     fi
83     log "ENDING HERE" # last line logged!
84     exit 1
85 }
86
87 if [ -f setup ]; then
88   . "./setup"
89   infixed="$fixed"
90 else
91   infixed=0             # so that "additional args to configure" works properly first time...
92 fi
93
94 if [ -z "$name" ]; then
95   echo "please enter your name"
96   read name
97   fixed="1"
98 fi
99
100 if [ -z "$email" ]; then
101   echo "please enter your contact email address"
102   read email
103   fixed="2"
104 fi
105
106 if [ -z "$desc" ]; then
107   echo "please enter a one line system description"
108   read desc
109   fixed="3"
110 fi
111
112 if [ -z "$confopts" ]; then
113   if [ $infixed -lt 4 ]; then
114     echo "please enter your additional arguments to configure"
115     echo "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4"
116     read confopts
117     fixed="4"
118   fi
119 fi
120
121
122 if [ "$fixed" -gt "0" ]; then
123   echo "name='$name'" > setup
124   echo "email='$email'" >> setup
125   echo "desc='$desc'" >> setup
126   echo "confopts='$confopts'" >> setup
127   echo "fixed='$fixed'" >> setup
128 fi
129
130 log "STARTING HERE" # first line logged
131 log "NAME = $name"
132 log "EMAIL = $email"
133 log "DESC = $desc"
134 log "CONFOPTS = $confopts"
135 log "CFLAGS = $CFLAGS"
136 log "CC = $CC"
137 log "version = $version"
138 log "date = `date -u`"
139
140 # Make $pwd to become the path without newline. We'll use that in order to cut
141 # off that path from all possible logs and error messages etc.
142 ipwd=`pwd` 
143 pwd=`echo $ipwd | sed -e 's/$//g'`
144
145 if [ -d "$CURLDIR" ]; then
146   if [ $CVS -eq 1 -a -d $CURLDIR/CVS ]; then
147     log "curl is verified to be a fine source dir"
148     # remove the generated sources to force them to be re-generated each
149     # time we run this test
150     rm -f $CURLDIR/lib/getdate.c
151     rm -f $CURLDIR/src/hugehelp.c
152   elif [ $CVS -eq 0 -a -f $CURLDIR/testcurl.sh ]; then
153     log "curl is verified to be a fine daily source dir"
154   else
155     die "curl is not a daily source dir or checked out from CVS!"
156   fi
157 fi
158 build="build-$$"
159 buildlogname="buildlog-$$"
160 buildlog="$pwd/$buildlogname"
161
162 # remove any previous left-overs
163 rm -rf build-*
164 rm -rf buildlog-*
165
166 # this is to remove old build logs that ended up in the wrong dir
167 rm -rf $CURLDIR/buildlog-*
168
169 # create a dir to build in
170 mkdir $build
171
172 if [ -d $build ]; then
173   log "build dir $build was created fine"
174 else
175   die "failed to create dir $build"
176 fi
177
178 # get in the curl source tree root
179 cd $CURLDIR
180
181 # Do the CVS thing, or not...
182 if [ $CVS -eq 1 ]; then
183
184   # this is a temporary fix to make things work again, remove later
185   log "remove ares/aclocal.m4"
186   rm -f ares/aclocal.m4
187
188   log "update from CVS"
189
190   cvsup() {
191     # update quietly to the latest CVS
192     log "run cvs up"
193     cvs -Q up -dP 2>&1
194
195     cvsstat=$?
196
197     # return (1 - RETURNVALUE) so that errors return 0 while goodness
198     # returns 1
199     return `expr 1 - $cvsstat`
200   }
201
202   att="0"
203   while cvsup; do
204     att=`expr $att + 1`
205     log "failed CVS update attempt number $att."
206     if [ $att -gt 10 ]; then
207       cvsstat="111"
208       break # get out of the loop
209     fi
210     sleep 5
211   done
212   
213   if [ "$cvsstat" -ne "0" ]; then
214     die "failed to update from CVS ($cvsstat), exiting"
215   fi
216   
217   # remove possible left-overs from the past
218   rm -f configure
219   rm -rf autom4te.cache
220
221   # generate the build files
222   log "invoke buildconf, but filter off the silly aclocal warnings"
223   ./buildconf 2>&1 | grep -v "warning: underquoted definition of" | tee $buildlog
224
225   if { grep "^buildconf: OK" $buildlog >/dev/null 2>&1; } then
226      log "buildconf was successful"
227   else
228      die "buildconf was NOT successful"
229   fi
230
231 fi
232
233 if [ -f configure ]; then
234   log "configure created"
235 else
236   die "no configure created"
237 fi
238
239 # change to build dir
240 cd "../$build"
241
242 # run configure script
243 ../$CURLDIR/configure $confopts 2>&1
244
245 if [ -f lib/Makefile ]; then
246   log "configure seems to have finished fine"
247 else
248   die "configure didn't work"
249 fi
250
251 log "display lib/config.h"
252 grep "^ *#" lib/config.h
253
254 log "display src/config.h"
255 grep "^ *#" src/config.h
256
257 if { grep "define USE_ARES" lib/config.h; } then
258   log "setup to build ares"
259
260   log "build ares"
261   cd ares
262   make 2>&1 | sed -e "s:$pwd::g"
263
264   if [ -f libcares.a ]; then
265     log "ares is now built successfully"
266   else
267     log "ares build failed"
268   fi
269
270   # cd back to the curl build dir
271   cd ..
272 fi
273
274 log "run make"
275 make -i 2>&1 | sed -e "s:$pwd::g"
276
277 if [ -f src/curl ]; then
278   log "src/curl was created fine"
279 else
280   die "src/curl was not created"
281 fi
282
283 log "display curl --version output"
284
285 ./src/curl --version
286
287 log "run make test-full"
288 make test-full 2>&1 | sed -e "s:$pwd::g" | tee $buildlog
289
290 if { grep "^TEST" $buildlog >/dev/null 2>&1; } then
291   log "tests were run"
292 else
293   die "test suite failure"
294 fi
295
296 if { grep "^TESTFAIL:" $buildlog >/dev/null 2>&1; } then
297   log "the tests were not successful"
298 else
299   log "the tests were successful!"  
300 fi
301
302 # die to cleanup
303 die "ending nicely"