Allow /build/<checksum>
[amitay/build-farm.git] / build_test.fns
index 8797d2a73f7c93051fe2819acffd1171b9522179..b7649bde3db5bbfd80774fe7ebc21ccba4831a39 100644 (file)
@@ -7,11 +7,13 @@
 # Copyright (C) 2001, 2003 by Martin Pool <mbp@samba.org>
 
 # default maximum runtime for any command
-MAXTIME=12000
+MAXTIME=25200 # 7 hours
+SMBD_MAXTIME=18000 # 5 hours for a samba process ..
 # default maximum memory size (100M) for any command
 MAXMEM=100000
 RUN_FROM_BUILD_FARM=yes
 export RUN_FROM_BUILD_FARM
+export MAXTIME SMBD_MAXTIME
 
 deptrees="";
 
@@ -141,12 +143,12 @@ fetch_revinfo() {
        if [ "$norsync" = "yes" ]; then
                echo "skipping .revinfo.$scm transfer"
        else
-       if [ -r $test_root/$tree.$scm ]; then
-               [ -f $test_root/$tree.$scm.old ] && rm -f $test_root/$tree.$scm.old
-               [ -f $test_root/$tree.$scm ] && mv $test_root/$tree.$scm $test_root/$tree.$scm.old
-       fi
-       rsync -q --timeout=200 -clz --ignore-errors \
-               samba.org::ftp/unpacked/$tree/.revinfo.$scm $test_root/$tree.$scm
+               if [ -r $test_root/$tree.$scm ]; then
+                       [ -f $test_root/$tree.$scm.old ] && rm -f $test_root/$tree.$scm.old
+                       [ -f $test_root/$tree.$scm ] && mv $test_root/$tree.$scm $test_root/$tree.$scm.old
+               fi
+               rsync -q --timeout=200 -clz --ignore-errors \
+                       samba.org::ftp/unpacked/$tree/.revinfo.$scm $test_root/$tree.$scm
        fi
        if [ -r $test_root/$tree.$scm ]; then
                return 0;
@@ -195,7 +197,7 @@ lock_file() {
                fi
 
                if test -f "$lckf"; then
-                       test $machine = $host || {
+                       test x$machine = x$host || {
                                echo "lock file $lckf is valid for other machine $machine"
                                return 1
                        }
@@ -289,6 +291,39 @@ do_make() {
        return 0
 }
 
+
+############################
+# do the coverage report
+############################
+
+action_lcovreport() {
+       if [ "$LCOV_REPORT" = "yes" ]; then
+               case "$tree" in
+               lorikeet-heimdal*)
+                       lcov --directory $builddir --capture --output-file $builddir/$tree.lcov.info
+                       ;;
+               samba_3_master*)
+                       lcov --base-directory $builddir --directory $builddir/.. --capture --output-file $builddir/$tree.lcov.info
+                       ;;
+               samba_4*)
+                       # rm -f heimdal/lib/*/{lex,parse,sel-lex}.{gcda,gcno}
+                       lcov --base-directory $builddir --directory $builddir/.. --capture --output-file $builddir/$tree.lcov.info
+                       ;;
+               *)
+                       lcov --base-directory $builddir --directory $builddir --capture --output-file $builddir/$tree.lcov.info
+                       ;;
+               esac
+               genhtml -o $builddir/coverage $builddir/$tree.lcov.info
+               rc=$?
+               echo "return code: $rc"
+       else
+               echo "LCOV_REPORT not set and lcovreport asked"
+               echo "Most probably an error please fix !"
+               return 1
+       fi
+}
+
+
 ############################
 # configure the tree
 ############################
@@ -504,7 +539,8 @@ test_tree() {
        shift
        shift
        shift
-       if [ "$compiler" = "gcc" ] && [ "$tree" != "ccache" ] && [ "$tree" != "ccache-maint" ] && ccache -V > /dev/null; then
+       echo "Starting to deal with tree $tree with compiler $compiler"
+       if [ "$compiler" = "gcc" ] && [ "$tree" != "ccache" ] && [ "$tree" != "ccache-maint" ] && ccache -V > /dev/null 2>/dev/null; then
                CCACHE="ccache"
                export CCACHE
        else
@@ -553,16 +589,22 @@ test_tree() {
        scm=`choose_scm "$tree"`
 
        # pull the entries, if any
+       # Remove old .svn or .git files
+       # Move the current .svn org .git to .svn.old or
+       # .git.old then fetch the new from rsync
        if fetch_revinfo "$tree" "$scm"; then
                for d in $deptrees; do
+                       # If there is dependency substree(s) we add info
+                       # from the dependency tree so that we
+                       # can rebuild in case one of them has changed
                        dscm=`choose_scm "$d"`
-               if [ -f "$test_root/$d.$dscm" ]; then
-                       if [ "$d" != "$tree" ]; then
-                       cat "$test_root/$d.$dscm" >> $test_root/$tree.$scm
+                       if [ -f "$test_root/$d.$dscm" ]; then
+                               if [ "$d" != "$tree" ]; then
+                                       cat "$test_root/$d.$dscm" >> $test_root/$tree.$scm
+                               fi
                        fi
-               fi
                done
-               [ -f $test_root/$tree.$compiler.$scm ] && rm -f $test_root/$tree.$compiler.$scm.old
+               [ -f $test_root/$tree.$compiler.$scm.old ] && rm -f $test_root/$tree.$compiler.$scm.old
                [ -f $test_root/$tree.$compiler.$scm ] && mv $test_root/$tree.$compiler.$scm $test_root/$tree.$compiler.$scm.old
                [ -f $test_root/$tree.$scm ] && cp $test_root/$tree.$scm $test_root/$tree.$compiler.$scm
 
@@ -584,7 +626,7 @@ test_tree() {
                return
        }
 
-               if [ ! -x $srcdir/configure ] && [ "$tree" != "pidl" ]; then
+       if [ ! -x $srcdir/configure ] && [ "$tree" != "pidl" ]; then
                echo "skip: $tree.$compiler configure not present, try again next time!"
                cd $test_root
                unlock_file "$lck"
@@ -593,40 +635,43 @@ test_tree() {
 
        echo "Starting build of $tree.$compiler in process $$ at `date`"
 
+
+       # Parameters for the build depending on the tree
        case "$tree" in
                libreplace)
-               builddir="$test_root/tmp.$tree.$compiler"
-               usingtmpbuild=1
-               if [ -d $builddir ]; then
-                       rm -rf $builddir
-               fi
-               mkdir -p $builddir
-               export builddir
-               ;;
+                       builddir="$test_root/tmp.$tree.$compiler"
+                       usingtmpbuild=1
+                       if [ -d $builddir ]; then
+                               rm -rf $builddir
+                       fi
+                       mkdir -p $builddir
+                       export builddir
+                       ;;
                *)
-               builddir=$srcdir
-               usingtmpbuild=0
-               export builddir
-               ;;
+                       builddir=$srcdir
+                       usingtmpbuild=0
+                       export builddir
+                       ;;
        esac
-       
+
+       #Fix the user
        if [ ! x$USER = x"" ]; then
                whoami=$USER
        else 
                if [ ! x$LOGNAME = x"" ]; then
-               whoami=$LOGNAME
+                       whoami=$LOGNAME
                else
-               whoami=build
+                       whoami=build
                fi
        fi
 
-               # build the timelimit utility
+       # build the timelimit utility
        echo "Building timelimit"
        mkdir -p $builddir
        echo $compiler $TIMELIMIT_FLAGS -o $builddir/timelimit $test_root/timelimit.c
        $compiler $TIMELIMIT_FLAGS -o $builddir/timelimit $test_root/timelimit.c || exit 1
 
-               # build the killbysubdir utility
+       # build the killbysubdir utility
        echo "Building killbysubdir"
        echo $compiler -o $builddir/killbysubdir $test_root/killbysubdir.c
        $compiler -o $builddir/killbysubdir $test_root/killbysubdir.c
@@ -634,6 +679,7 @@ test_tree() {
        prefix="$test_root/prefix/$tree.$compiler"
        mkdir -p "$prefix"
 
+       # This can be defined in <host>.fns files
        sw_config=$config
 
        case "$tree" in
@@ -684,8 +730,9 @@ test_tree() {
        [ -f $sum.old ] && /bin/rm -f $sum.old
        mv $sum $sum.old
 
+       #Action == what to do ie. configure config_log ...
        actions="$*"
-       
+
        if [ "$actions" = "" ]; then
                actions="configure config_log config_header build install test"
        fi
@@ -707,9 +754,9 @@ test_tree() {
                echo "used .fns file      : $build_test_used_fns_file"
                echo ""
 
-                               # we need to be able to see if a build farm machine is accumulating
-                               # stuck processes. We do this in two ways, as we don't know what style
-                               # of ps it will have
+               # we need to be able to see if a build farm machine is accumulating
+               # stuck processes. We do this in two ways, as we don't know what style
+               # of ps it will have
                ps xfuw 2> /dev/null
                ps -fu $USER 2> /dev/null
 
@@ -762,43 +809,39 @@ test_tree() {
                        mount
                        vmstat
 
+                       if [ "x$PREHOOKS" != "x" ]; then
+                               for hooks in $PREHOOKS; do
+                                       if [ "x$hooks" = "x$action" ]; then
+                                               ( prehook_$action )
+                                       fi
+                               done
+                       fi
+
                        ( action_$action )
                        action_status=$?
 
+                       if [ "x$POSTHOOKS" != "x" ]; then
+                               for hooks in $POSTHOOKS; do
+                                       if [ "x$hooks" = "x$action" ]; then
+                                               ( posthook_$action )
+                                       fi
+                               done
+                       fi
+
                        df .
 
                        if [ $action_status != 0 ]; then
-                       echo "ACTION FAILED: $action";
+                               echo "ACTION FAILED: $action";
+                               echo " return code $action_status $action";
                        else
-                       echo "ACTION PASSED: $action";
+                               echo "ACTION PASSED: $action";
                        fi
-                       
+
                        if [ $action_status != 0 ]; then 
-                       break;
+                               break;
                        fi
-
                done
 
-               if [ "$LCOV_REPORT" = "yes" ]; then
-                       case "$tree" in
-                       lorikeet-heimdal*)
-                               lcov --directory $builddir --capture --output-file $builddir/$tree.lcov.info
-                               ;;
-                       samba_3_master*)
-                               lcov --base-directory $builddir --directory $builddir/.. --capture --output-file $builddir/$tree.lcov.info
-                               ;;
-                       samba_4*)
-                               # ugly hack for s4, as lcov is otherwise not able to find 
-                               # these files
-                               rm -f heimdal/lib/*/{lex,parse,sel-lex}.{gcda,gcno}
-                               lcov --base-directory $builddir --directory $builddir/.. --capture --output-file $builddir/$tree.lcov.info
-                               ;;
-                       *)
-                               lcov --base-directory $builddir --directory $builddir --capture --output-file $builddir/$tree.lcov.info
-                               ;;
-                       esac
-                       genhtml -o $builddir/coverage $builddir/$tree.lcov.info
-               fi
 
                if [ "$noclean" = "yes" ]; then
                        echo cleanup skipped!
@@ -815,17 +858,17 @@ test_tree() {
        if [ "$LCOV_REPORT" = "yes" ]; then
                chmod u=rwX,g=rX,o=rX -R $builddir/coverage
                rsync -rct -q --password-file=.password -z --timeout=200 \
-               $builddir/coverage/ $host@build.samba.org::lcov_data/$host/$tree/
+                       $builddir/coverage/ $host@build.samba.org::lcov_data/$host/$tree/
        fi
 
        cd $test_root
 
-               /bin/rm -rf $prefix
+       /bin/rm -rf $prefix
        if [ "$usingtmpbuild" = "1" ]; then
                if [ "$noclean" = "yes" ]; then
-               echo builddir cleanup skipped!
+                       echo builddir cleanup skipped!
                else
-               /bin/rm -rf $builddir
+                       /bin/rm -rf $builddir
                fi
        fi
        # send the logs to the master site