From: Amos Jeffries Date: Sun, 8 Mar 2009 12:27:41 +0000 (+1300) Subject: Author: Various X-Git-Tag: SQUID_3_1_0_7~24 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=14777424b3284bece27ee75dcdee521fb274ebf5;p=thirdparty%2Fsquid.git Author: Various TestBed: Several capability additions and fixes Henrik Nordstrom: Allow out-of-tree builds and separate .opts files Francesco Chemolli: Add parallel make capability under Linux Amos Jeffries: Several fixes. Better information reporting --- diff --git a/test-builds.sh b/test-builds.sh index a8a9d2f4ed..b53080d892 100755 --- a/test-builds.sh +++ b/test-builds.sh @@ -2,24 +2,81 @@ # # Run specific build tests for a given OS environment. # +top=`dirname $0` cleanup="no" -if test "${1}" = "--cleanup" ; then +verbose="no" +while [ $# -ge 1 ]; do + case "$1" in + --cleanup) cleanup="yes" shift -fi + ;; + --verbose) + verbose="yes" + shift + ;; + *) + break + ;; + esac +done # Things to catch errors="^ERROR|\ error:|\ Error\ |No\ such|assertion\ failed|FAIL:" -# Run a single test build by name -tmp="${1}" -if test -e ./test-suite/buildtests/${tmp}.opts ; then - echo "TESTING: ${tmp}" - rm -f -r bt${tmp} && mkdir bt${tmp} && cd bt${tmp} - ../test-suite/buildtest.sh ../test-suite/buildtests/${tmp} - grep -E "${errors}" buildtest_*.log && exit 1 - cd .. +logtee() { + if [ $verbose = yes ]; then + tee $1 + else + cat >$1 + fi +} + +buildtest() { + opts=$1 + layer=`basename $opts .opts` + btlayer="bt$layer" + log=${btlayer}.log + echo "TESTING: ${layer}" + rm -f -r ${btlayer} && mkdir ${btlayer} + { + cd ${btlayer} + if test -e $top/test-suite/buildtest.sh ; then + $top/test-suite/buildtest.sh $opts + elif test -e ../$top/test-suite/buildtest.sh ; then + ../$top/test-suite/buildtest.sh ../$opts + fi + } 2>&1 | logtee $log + grep -E "BUILD" ${log} + grep -E "${errors}" $log && exit 1 + if test "${cleanup}" = "yes" ; then + echo "REMOVE DATA: ${btlayer}" + rm -f -r ${btlayer} + fi + result=`tail -2 $log | head -1` + if test "${result}" = "Build Successful." ; then + echo "${result}" + else + echo "Build Failed:" + tail -5 $log + exit 1 + fi + if test "${cleanup}" = "yes" ; then + echo "REMOVE LOG: ${log}" + rm -f -r $log + fi +} + +# Run a single test build by name or opts file +if [ -e "$1" ]; then + + buildtest $1 + exit 0 +fi +tmp=`basename "${1}" .opts` +if test -e $top/test-suite/buildtests/${tmp}.opts ; then + buildtest $top/test-suite/buildtests/${tmp}.opts exit 0 fi @@ -30,18 +87,6 @@ fi # These layers are constructed from detailed knowledge of # component dependencies. # -for f in `ls -1 ./test-suite/buildtests/layer*.opts` ; do - layer=`echo "${f}" | grep -o -E "layer-[0-9]*-[^\.]*"` - rm -f -r bt${layer} && mkdir bt${layer} && cd bt${layer} - arg=`echo "${f}" | sed s/\\.opts//` - echo "TESTING: ${arg}" - ../test-suite/buildtest.sh ".${arg}" - grep -E "${errors}" buildtest_*.log && exit 1 - result=`tail -2 buildtest_*.log | head -1` - test "${result}" = "Build Successful." || ( tail -5 buildtest_*.log ; exit 1 ) - cd .. - if test "${cleanup}" = "yes" ; then - echo "REMOVE: bt${layer}" - rm -f -r bt${layer} - fi +for f in `ls -1 $top/test-suite/buildtests/layer*.opts` ; do + buildtest $f done diff --git a/test-suite/buildtest.sh b/test-suite/buildtest.sh index b7f6c3671a..8c813562b8 100755 --- a/test-suite/buildtest.sh +++ b/test-suite/buildtest.sh @@ -6,36 +6,39 @@ # Should be run from the source package root directory with paths relative to there. # -dist="${1}" - -# Figure out where to log the test output -log=`echo "${dist}" | sed s/..test-suite.buildtests.//g ` - -# ... and send everything there... -{ +config="${1}" +base="`dirname ${0}`" + +#if we are on Linux, let's try parallelizing +pjobs="" #default +if [ -e /proc/cpuinfo ]; then + ncpus=`grep '^processor' /proc/cpuinfo | tail -1|awk '{print $3}'` + ncpus=`expr ${ncpus} + 1` + pjobs="-j${ncpus}" +fi -if test -e ${dist%%.opts}.opts ; then - echo "BUILD: ${dist%%.opts}.opts" - . ./${dist%%.opts}.opts +if test -e ${config} ; then + echo "BUILD: ${config}" + . ${config} else - echo "BUILD: DEFAULT" - OPTS="" - FLAGS="" + echo -n "BUILD ERROR: Unable to locate test configuration '${config}' from " && pwd + exit 1; fi # # empty all the existing code, reconfigure and builds test code - -make -k distclean || echo "distclean done. errors are unwanted but okay here." +# but skip if we have no files to remove. +FILECOUNT=`ls -1 | grep -c .` +if test "${FILECOUNT}" != "0" ; then + make -k distclean || echo "distclean done. errors are unwanted but okay here." +fi # # above command currently encounters dependancy problems on cleanup. # rm -f -r src/fs/aufs/.deps src/fs/diskd/.deps && - ../configure --silent ${OPTS} 2>&1 && - make check 2>&1 && - make 2>&1 - -} 2>&1 > ./buildtest_${log}.log + $base/../configure --silent ${OPTS} 2>&1 && + make ${pjobs} check 2>&1 && + make ${pjobs} 2>&1 # do not build any of the install's ...