testcurl.sh 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. # What is This Script?
  26. ###########################
  27. # testcurl.sh is the master script to use for automatic testing of CVS-curl.
  28. # This is written for the purpose of being run from a crontab job or similar
  29. # at a regular interval. The output will be suitable to be mailed automaticly
  30. # to "curl-autocompile@haxx.se" to be dealt with automatically. The most
  31. # current build status (with a resonable backlog) will be published on the
  32. # curl site, at http://curl.haxx.se/auto/
  33. # USAGE:
  34. # testcurl.sh [curl-daily-name] > output
  35. # Updated:
  36. # v1.1 6-Nov-03 - to take an optional parameter, the name of a daily-build
  37. # directory. If present, build from that directory, otherwise
  38. # perform a normal CVS build.
  39. # version of this script
  40. version='$Revision: 1.41 $'
  41. fixed=0
  42. # Determine if we're running from CVS or a canned copy of curl
  43. if [ "$#" -ge "1" -a "$1" ]; then
  44. CURLDIR=$1
  45. CVS=0
  46. else
  47. CURLDIR="curl"
  48. CVS=1
  49. fi
  50. LANG="C"
  51. export LANG
  52. log() {
  53. text=$1
  54. if test -n "$text"; then
  55. echo "testcurl: $text"
  56. fi
  57. }
  58. die(){
  59. text=$1
  60. log "$text"
  61. cd $pwd # cd back to the original root dir
  62. if test -n "$pwd/$build"; then
  63. # we have a build directory name, remove the dir
  64. log "removing the $build dir"
  65. rm -rf "$pwd/$build"
  66. fi
  67. if test -r "$buildlog"; then
  68. # we have a build log output file left, remove it
  69. log "removing the $buildlogname file"
  70. rm -rf "$buildlog"
  71. fi
  72. log "ENDING HERE" # last line logged!
  73. exit 1
  74. }
  75. if [ -f setup ]; then
  76. . "./setup"
  77. infixed="$fixed"
  78. else
  79. infixed=0 # so that "additional args to configure" works properly first time...
  80. fi
  81. if [ -z "$name" ]; then
  82. echo "please enter your name"
  83. read name
  84. fixed="1"
  85. fi
  86. if [ -z "$email" ]; then
  87. echo "please enter your contact email address"
  88. read email
  89. fixed="2"
  90. fi
  91. if [ -z "$desc" ]; then
  92. echo "please enter a one line system description"
  93. read desc
  94. fixed="3"
  95. fi
  96. if [ -z "$confopts" ]; then
  97. if [ $infixed -lt 4 ]; then
  98. echo "please enter your additional arguments to configure"
  99. echo "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4"
  100. read confopts
  101. fixed="4"
  102. fi
  103. fi
  104. if [ "$fixed" -gt "0" ]; then
  105. echo "name='$name'" > setup
  106. echo "email='$email'" >> setup
  107. echo "desc='$desc'" >> setup
  108. echo "confopts='$confopts'" >> setup
  109. echo "fixed='$fixed'" >> setup
  110. fi
  111. log "STARTING HERE" # first line logged
  112. log "NAME = $name"
  113. log "EMAIL = $email"
  114. log "DESC = $desc"
  115. log "CONFOPTS = $confopts"
  116. log "CFLAGS = $CFLAGS"
  117. log "CC = $CC"
  118. log "version = $version"
  119. log "date = `date -u`"
  120. # Make $pwd to become the path without newline. We'll use that in order to cut
  121. # off that path from all possible logs and error messages etc.
  122. ipwd=`pwd`
  123. pwd=`echo $ipwd | sed -e 's/$//g'`
  124. if [ -d "$CURLDIR" ]; then
  125. if [ $CVS -eq 1 -a -d $CURLDIR/CVS ]; then
  126. log "curl is verified to be a fine source dir"
  127. # remove the generated sources to force them to be re-generated each
  128. # time we run this test
  129. rm -f $CURLDIR/lib/getdate.c
  130. rm -f $CURLDIR/src/hugehelp.c
  131. elif [ $CVS -eq 0 -a -f $CURLDIR/testcurl.sh ]; then
  132. log "curl is verified to be a fine daily source dir"
  133. else
  134. die "curl is not a daily source dir or checked out from CVS!"
  135. fi
  136. fi
  137. build="build-$$"
  138. buildlogname="buildlog-$$"
  139. buildlog="$pwd/$buildlogname"
  140. # remove any previous left-overs
  141. rm -rf build-*
  142. rm -rf buildlog-*
  143. # this is to remove old build logs that ended up in the wrong dir
  144. rm -rf $CURLDIR/buildlog-*
  145. # create a dir to build in
  146. mkdir $build
  147. if [ -d $build ]; then
  148. log "build dir $build was created fine"
  149. else
  150. die "failed to create dir $build"
  151. fi
  152. # get in the curl source tree root
  153. cd $CURLDIR
  154. # Do the CVS thing, or not...
  155. if [ $CVS -eq 1 ]; then
  156. # this is a temporary fix to make things work again, remove later
  157. log "remove ares/aclocal.m4"
  158. rm -f ares/aclocal.m4
  159. log "update from CVS"
  160. cvsup() {
  161. # update quietly to the latest CVS
  162. log "run cvs up"
  163. cvs -Q up -dP 2>&1
  164. cvsstat=$?
  165. # return (1 - RETURNVALUE) so that errors return 0 while goodness
  166. # returns 1
  167. return `expr 1 - $cvsstat`
  168. }
  169. att="0"
  170. while cvsup; do
  171. att=`expr $att + 1`
  172. log "failed CVS update attempt number $att."
  173. if [ $att -gt 10 ]; then
  174. cvsstat="111"
  175. break # get out of the loop
  176. fi
  177. sleep 5
  178. done
  179. if [ "$cvsstat" -ne "0" ]; then
  180. die "failed to update from CVS ($cvsstat), exiting"
  181. fi
  182. # remove possible left-overs from the past
  183. rm -f configure
  184. rm -rf autom4te.cache
  185. # generate the build files
  186. log "invoke buildconf, but filter off the silly aclocal warnings"
  187. ./buildconf 2>&1 | grep -v "warning: underquoted definition of" | tee $buildlog
  188. if { grep "^buildconf: OK" $buildlog >/dev/null 2>&1; } then
  189. log "buildconf was successful"
  190. else
  191. die "buildconf was NOT successful"
  192. fi
  193. fi
  194. if [ -f configure ]; then
  195. log "configure created"
  196. else
  197. die "no configure created"
  198. fi
  199. # change to build dir
  200. cd "../$build"
  201. # run configure script
  202. ../$CURLDIR/configure $confopts 2>&1
  203. if [ -f lib/Makefile ]; then
  204. log "configure seems to have finished fine"
  205. else
  206. die "configure didn't work"
  207. fi
  208. log "display lib/config.h"
  209. grep "^ *#" lib/config.h
  210. log "display src/config.h"
  211. grep "^ *#" src/config.h
  212. if { grep "define USE_ARES" lib/config.h; } then
  213. log "setup to build ares"
  214. log "build ares"
  215. cd ares
  216. make 2>&1 | sed -e "s:$pwd::g"
  217. if [ -f libcares.a ]; then
  218. log "ares is now built successfully"
  219. else
  220. log "ares build failed"
  221. fi
  222. # cd back to the curl build dir
  223. cd ..
  224. fi
  225. log "run make"
  226. make -i 2>&1 | sed -e "s:$pwd::g"
  227. if [ -f src/curl ]; then
  228. log "src/curl was created fine"
  229. else
  230. die "src/curl was not created"
  231. fi
  232. log "display curl --version output"
  233. ./src/curl --version
  234. log "run make test-full"
  235. make test-full 2>&1 | sed -e "s:$pwd::g" | tee $buildlog
  236. if { grep "^TEST" $buildlog >/dev/null 2>&1; } then
  237. log "tests were run"
  238. else
  239. die "test suite failure"
  240. fi
  241. if { grep "^TESTFAIL:" $buildlog >/dev/null 2>&1; } then
  242. log "the tests were not successful"
  243. else
  244. log "the tests were successful!"
  245. fi
  246. # die to cleanup
  247. die "ending nicely"