The error buffer was not getting filled when Curl_wait_for_resolv() fails.
[platform/upstream/curl.git] / testcurl.sh
1 #!/bin/sh
2 ###########################
3 #  What is This Script?
4 ###########################
5
6 # testcurl.sh is the master script to use for automatic testing of CVS-curl.
7 # This is written for the purpose of being run from a crontab job or similar
8 # at a regular interval. The output will be suitable to be mailed automaticly
9 # to "curl-autocompile@haxx.se" to be dealt with automaticly.  The most
10 # current build status (with a resonable backlog) will be published on the
11 # curl site, at http://curl.haxx.se/auto/
12
13 # USAGE:
14 # testcurl.sh > output
15
16 # version of this script
17 version=1
18 fixed=0
19
20 LANG="C"
21
22 export LANG
23
24 die(){
25     echo "testcurl: ENDING HERE"
26     exit 1
27 }
28
29 if [ -f setup ]; then
30   . "./setup"
31   infixed="$fixed"
32 fi
33
34 if [ -z "$name" ]; then
35   echo "please enter your name"
36   read name
37   fixed="1"
38 fi
39
40 if [ -z "$email" ]; then
41   echo "please enter your contact email address"
42   read email
43   fixed="2"
44 fi
45
46 if [ -z "$desc" ]; then
47   echo "please enter a one line system desrciption"
48   read desc
49   fixed="3"
50 fi
51
52 if [ -z "$confopts" ]; then
53   if [ $infixed -lt 4 ]; then
54     echo "please enter your additional arguments to configure"
55     echo "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4"
56     read confopts
57     fixed="4"
58   fi
59 fi
60
61
62 if [ "$fixed" -gt "0" ]; then
63   echo "name='$name'" > setup
64   echo "email='$email'" >> setup
65   echo "desc='$desc'" >> setup
66   echo "confopts='$confopts'" >> setup
67   echo "fixed='$fixed'" >> setup
68 fi
69
70 echo "testcurl: STARTING HERE"
71 echo "testcurl: NAME = $name"
72 echo "testcurl: EMAIL = $email"
73 echo "testcurl: DESC = $desc"
74 echo "testcurl: CONFOPTS = $confopts"
75 echo "testcurl: version = $version"
76 echo "testcurl: date = `date -u`"
77
78 # Make $pwd to become the path without newline. We'll use that in order to cut
79 # off that path from all possible logs and error messages etc.
80 ipwd=`pwd` 
81 pwd=`echo $ipwd | sed -e 's/$//g'`
82
83 if [ -d curl -a -d curl/CVS ]; then
84   echo "testcurl: curl is verified to be a fine source dir"
85 else
86   echo "testcurl: curl is not a source dir checked out from CVS!"
87   die
88 fi
89
90 build="build-$$"
91
92 # remove any previous left-overs
93 rm -rf build-*
94
95 # create a dir to build in
96 mkdir $build
97
98 if [ -d $build ]; then
99   echo "testcurl: build dir $build was created fine"
100 else
101   echo "testcurl: failed to create dir $build"
102   die
103 fi
104
105 # get in the curl source tree root
106 cd curl
107
108 echo "testcurl: update from CVS"
109
110 cvsup() {
111   # update quietly to the latest CVS
112   echo "testcurl: run cvs up"
113   cvs -Q up -dP 2>&1
114
115   cvsstat=$?
116
117   # return (1 - RETURNVALUE) so that errors return 0 while goodness
118   # returns 1
119   return `expr 1 - $cvsstat`
120 }
121
122 att="0"
123 while cvsup; do
124   att=`expr $att + 1`
125   echo "testcurl: failed CVS update attempt number $att."
126   if [ $att -gt 10 ]; then
127     cvsstat="111"
128     break # get out of the loop
129   fi
130   sleep 5
131 done
132
133 echo "testcurl: cvs returned: $cvsstat"
134
135 if [ "$cvsstat" -ne "0" ]; then
136   echo "testcurl: failed to update from CVS, exiting"
137   die
138 fi
139
140 # figure out the current collected CVS status
141 newstat="../allcvs.log"
142 oldstat="../oldcvs.log"
143 find . -name Entries -exec cat {} \; > "$newstat"
144
145 if [ -r "$oldstat" ]; then
146   # there is a previous cvs stat file to compare with
147   if { cmp "$oldstat" "$newstat"; } then
148     echo "testcurl: this is the same CVS status as before"
149     echo "testcurl: ALREADY TESTED THIS SETUP BEFORE"
150     #die
151   else
152     echo "testcurl: there has been a change in the CVS"
153   fi
154 fi
155
156 # remove possible left-overs from the past
157 rm -f configure
158 rm -rf autom4te.cache
159
160 # generate the build files
161 ./buildconf 2>&1
162
163 if [ -f configure ]; then
164   echo "testcurl: configure created"
165 else
166   echo "testcurl: no configure created"
167   die
168 fi
169
170 # change to build dir
171 cd "../$build"
172
173 # run configure script
174 ../curl/configure $confopts 2>&1
175
176 if [ -f lib/Makefile ]; then
177   echo "testcurl: configure seems to have finished fine"
178 else
179   echo "testcurl: configure didn't work"
180   die
181 fi
182
183 echo "testcurl: display lib/config.h"
184 grep "^ *#" lib/config.h
185
186 echo "testcurl: now run make"
187 make -i 2>&1 | sed -e "s:$pwd::g"
188
189 if [ -f src/curl ]; then
190   echo "testcurl: src/curl was created fine"
191 else
192   echo "testcurl: src/curl was not created"
193   die
194 fi
195
196 echo "testcurl: now run make test-full"
197 make test-full 2>&1 | sed -e "s:$pwd::g" | tee build.log
198
199 if { grep "^TESTFAIL:" build.log; } then
200   echo "testcurl: the tests were not successful"
201 else
202   echo "testcurl: the tests were successful!"  
203 fi
204
205 # store the cvs status for the next time
206 mv $newstat $oldstat
207
208 # get out of dir
209 cd ..
210
211 # delete build dir
212 rm -rf "$build"
213
214 die