1
0
mirror of https://github.com/moparisthebest/curl synced 2025-03-01 01:41:50 -05:00

use a die and a log function to die and log texts

better detect test suite failures
remove the buildlog at exit
make a random buildlog file name, now in the same dir where the build dir
is created
checks if the ares build succeeded
This commit is contained in:
Daniel Stenberg 2004-02-19 12:56:45 +00:00
parent 6ca7af3419
commit c14fa2c935

View File

@ -36,16 +36,28 @@ LANG="C"
export LANG export LANG
log() {
text=$1
if test -n "$text"; then
echo "testcurl: $text"
fi
}
die(){ die(){
echo "testcurl: ENDING HERE" text=$1
log "$text"
if test -n "$pwd/$build"; then if test -n "$pwd/$build"; then
# we have a build directory name, remove the dir # we have a build directory name, remove the dir
log "removing the $build dir"
rm -rf "$pwd/$build" rm -rf "$pwd/$build"
fi fi
if test -r "$pwd/build.log"; then if test -r "$pwd/$buildlog"; then
# we have a build log output file left, remove it # we have a build log output file left, remove it
rm -rf "$pwd/build.log" log "removing the $buildlog file"
rm -rf "$buildlog"
fi fi
log "ENDING HERE" # last line logged!
exit 1 exit 1
} }
@ -92,13 +104,13 @@ if [ "$fixed" -gt "0" ]; then
echo "fixed='$fixed'" >> setup echo "fixed='$fixed'" >> setup
fi fi
echo "testcurl: STARTING HERE" log "STARTING HERE" # first line logged
echo "testcurl: NAME = $name" log "NAME = $name"
echo "testcurl: EMAIL = $email" log "EMAIL = $email"
echo "testcurl: DESC = $desc" log "DESC = $desc"
echo "testcurl: CONFOPTS = $confopts" log "CONFOPTS = $confopts"
echo "testcurl: version = $version" log "version = $version"
echo "testcurl: date = `date -u`" log "date = `date -u`"
# Make $pwd to become the path without newline. We'll use that in order to cut # Make $pwd to become the path without newline. We'll use that in order to cut
# off that path from all possible logs and error messages etc. # off that path from all possible logs and error messages etc.
@ -107,15 +119,15 @@ pwd=`echo $ipwd | sed -e 's/$//g'`
if [ -d "$CURLDIR" ]; then if [ -d "$CURLDIR" ]; then
if [ $CVS -eq 1 -a -d $CURLDIR/CVS ]; then if [ $CVS -eq 1 -a -d $CURLDIR/CVS ]; then
echo "testcurl: curl is verified to be a fine source dir" log "curl is verified to be a fine source dir"
elif [ $CVS -eq 0 -a -f $CURLDIR/testcurl.sh ]; then elif [ $CVS -eq 0 -a -f $CURLDIR/testcurl.sh ]; then
echo "testcurl: curl is verified to be a fine daily source dir" log "curl is verified to be a fine daily source dir"
else else
echo "testcurl: curl is not a daily source dir or checked out from CVS!" die "curl is not a daily source dir or checked out from CVS!"
die
fi fi
fi fi
build="build-$$" build="build-$$"
buildlog="buildlog-$$"
# remove any previous left-overs # remove any previous left-overs
rm -rf build-* rm -rf build-*
@ -124,10 +136,9 @@ rm -rf build-*
mkdir $build mkdir $build
if [ -d $build ]; then if [ -d $build ]; then
echo "testcurl: build dir $build was created fine" log "build dir $build was created fine"
else else
echo "testcurl: failed to create dir $build" die "failed to create dir $build"
die
fi fi
# get in the curl source tree root # get in the curl source tree root
@ -135,11 +146,11 @@ cd $CURLDIR
# Do the CVS thing, or not... # Do the CVS thing, or not...
if [ $CVS -eq 1 ]; then if [ $CVS -eq 1 ]; then
echo "testcurl: update from CVS" log "update from CVS"
cvsup() { cvsup() {
# update quietly to the latest CVS # update quietly to the latest CVS
echo "testcurl: run cvs up" log "run cvs up"
cvs -Q up -dP 2>&1 cvs -Q up -dP 2>&1
cvsstat=$? cvsstat=$?
@ -152,7 +163,7 @@ if [ $CVS -eq 1 ]; then
att="0" att="0"
while cvsup; do while cvsup; do
att=`expr $att + 1` att=`expr $att + 1`
echo "testcurl: failed CVS update attempt number $att." log "failed CVS update attempt number $att."
if [ $att -gt 10 ]; then if [ $att -gt 10 ]; then
cvsstat="111" cvsstat="111"
break # get out of the loop break # get out of the loop
@ -160,11 +171,8 @@ if [ $CVS -eq 1 ]; then
sleep 5 sleep 5
done done
echo "testcurl: cvs returned: $cvsstat"
if [ "$cvsstat" -ne "0" ]; then if [ "$cvsstat" -ne "0" ]; then
echo "testcurl: failed to update from CVS, exiting" die "failed to update from CVS ($cvsstat), exiting"
die
fi fi
# remove possible left-overs from the past # remove possible left-overs from the past
@ -172,22 +180,20 @@ if [ $CVS -eq 1 ]; then
rm -rf autom4te.cache rm -rf autom4te.cache
# generate the build files # generate the build files
./buildconf 2>&1 | tee build.log ./buildconf 2>&1 | tee $buildlog
if { grep "^buildconf: OK" build.log >/dev/null 2>&1; } then if { grep "^buildconf: OK" $buildlog >/dev/null 2>&1; } then
echo "testcurl: buildconf was successful" log "buildconf was successful"
else else
echo "testcurl: buildconf was NOT successful" die "buildconf was NOT successful"
die
fi fi
fi fi
if [ -f configure ]; then if [ -f configure ]; then
echo "testcurl: configure created" log "configure created"
else else
echo "testcurl: no configure created" die "no configure created"
die
fi fi
# change to build dir # change to build dir
@ -197,50 +203,54 @@ cd "../$build"
../$CURLDIR/configure $confopts 2>&1 ../$CURLDIR/configure $confopts 2>&1
if [ -f lib/Makefile ]; then if [ -f lib/Makefile ]; then
echo "testcurl: configure seems to have finished fine" log "configure seems to have finished fine"
else else
echo "testcurl: configure didn't work" die "configure didn't work"
die
fi fi
echo "testcurl: display lib/config.h" log "display lib/config.h"
grep "^ *#" lib/config.h grep "^ *#" lib/config.h
if { grep "define USE_ARES" lib/config.h; } then if { grep "define USE_ARES" lib/config.h; } then
echo "testcurl: setup to build ares" log "setup to build ares"
echo "testcurl: build ares" log "build ares"
cd ares cd ares
make 2>&1 | sed -e "s:$pwd::g" make 2>&1 | sed -e "s:$pwd::g"
echo "testcurl: ares is now built"
if [ -f libcares.a]; then
log "ares is now built successfully"
else
log "ares build failed"
fi
# cd back to the curl build dir # cd back to the curl build dir
cd .. cd ..
fi fi
echo "testcurl: now run make" log "run make"
make -i 2>&1 | sed -e "s:$pwd::g" make -i 2>&1 | sed -e "s:$pwd::g"
if [ -f src/curl ]; then if [ -f src/curl ]; then
echo "testcurl: src/curl was created fine" log "src/curl was created fine"
else else
echo "testcurl: src/curl was not created" die "src/curl was not created"
die
fi fi
echo "testcurl: now run make test-full" log "run make test-full"
make test-full 2>&1 | sed -e "s:$pwd::g" | tee build.log make test-full 2>&1 | sed -e "s:$pwd::g" | tee $buildlog
if { grep "^TESTFAIL:" build.log; } then if { grep "^TEST" $buildlog >/dev/null 2>&1; } then
echo "testcurl: the tests were not successful" log "tests were run"
else else
echo "testcurl: the tests were successful!" die "test suite failure"
fi fi
# get out of dir if { grep "^TESTFAIL:" $buildlog >/dev/null 2>&1; } then
cd .. log "the tests were not successful"
else
log "the tests were successful!"
fi
# delete build dir # die to cleanup
rm -rf "$build" die "ending nicely"
die