some css elements are standard now, now brwowser specific names needed for those
[build-farm.git] / build_test.fns
index 9c409ee55f8fe3e24d7f9fa30558f1e509e20b88..7fad7f17ea97ff0f0a58ac513638d028dfb248f9 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="";
 
@@ -36,23 +38,23 @@ sum_tree() {
        sum_tree_tree=$2
        sum_tree_sum=$3
        sum_tree_scm=$4
-       find $sum_tree_test_root/$sum_tree_tree -type f -print | grep -v version.h | sort | xargs sum > $sum_tree_sum
-       sum build_test build_test.fns >> $sum_tree_sum
+       find $sum_tree_test_root/$sum_tree_tree -type f -print | grep -v version.h | sort | xargs cksum > $sum_tree_sum
+       cksum build_test build_test.fns >> $sum_tree_sum
 
        if [ -f "$host.fns" ]; then
-               sum $host.fns >> $sum_tree_sum
+               cksum $host.fns >> $sum_tree_sum
        else
-               sum generic.fns >> $sum_tree_sum
+               cksum generic.fns >> $sum_tree_sum
        fi
 
        if [ -f "$test_root/$tree.$scm" ]; then
-               sum "$test_root/$tree.$scm" >> $sum_tree_sum
+               cksum "$test_root/$tree.$scm" >> $sum_tree_sum
        fi
 
        for d in $deptrees; do
                dscm=`choose_scm "$d"`
                if [ -f "$test_root/$d.$dscm" ]; then
-               sum "$test_root/$d.$dscm" >> $sum_tree_sum
+                       cksum "$test_root/$d.$dscm" >> $sum_tree_sum
                fi
        done
 }
@@ -102,7 +104,7 @@ send_logs() {
 
 send_logs_skip() {
        touch "$1" "$2"
-       send_logs "$1" "$2" -B 10000000
+       send_logs "$1" "$2" -B 131072
 }
 
 ############################
@@ -116,7 +118,7 @@ fetch_tree() {
                fetchtree=$1
                if rsync --exclude=autom4te.cache/ --exclude=.svn/ --exclude=.git/ \
                        --delete-excluded -q --partial --timeout=200 -ctrlpz --delete --ignore-errors \
-                       samba.org::ftp/unpacked/$fetchtree/ $test_root/$fetchtree; then
+                       download.samba.org::ftp/unpacked/$fetchtree/ $test_root/$fetchtree; then
                        echo "transferred $fetchtree OK"
                else
                        echo "transfer of $fetchtree failed code $?"
@@ -162,7 +164,7 @@ choose_scm() {
        tree=$1
 
        case "$tree" in
-                       samba* | rsync | libreplace | talloc | tdb | ldb | pidl | ccache*)
+                       samba* | rsync | libreplace | talloc | tdb | ntdb | ldb | pidl | ccache* | waf*)
                        echo "git"
                                return 0
                        ;;
@@ -194,8 +196,10 @@ lock_file() {
                        return 0
                fi
 
-               if test -f "$lckf"; then
-                       test $machine = $host || {
+               # We need to assert that the file is > 0 size, as otherwise we never
+                # recover from disk full situations
+               if test -f "$lckf" && test -s "$lckf"; then
+                       test x$machine = x$host || {
                                echo "lock file $lckf is valid for other machine $machine"
                                return 1
                        }
@@ -235,35 +239,51 @@ unlock_file() {
 ############################
 
 do_make() {
-       if [ x"$MAKE" = x ]; then
-               MAKE=make
-       fi
+        # work out correct make command
+       case "$tree" in
+           waf*)
+               MAKECOMMAND="./waf"
+               ;;
+           *)
+               MAKECOMMAND="$MAKE"
+               if [ x"$MAKECOMMAND" = x ]; then
+                   MAKECOMMAND=make
+               fi
+               ;;
+       esac
 
        MMTIME=$MAXTIME
        # some trees don't need as much time
        case "$tree" in
-               rsync | tdb | talloc | libreplace | ccache*)
+               rsync | tdb | ntdb | talloc | libreplace | ccache* | waf*)
                        if [ "$compiler" != "checker" ]; then
                                MMTIME=`expr $MMTIME / 5`
                        fi
                ;;
        esac
 
+       # special build for some trees
+       case "$tree" in
+           waf*)
+               ./waf distclean && ./waf configure build
+               ;;
+       esac
+
 
        for t in $*; do
                if [ x"$BUILD_FARM_NUM_JOBS" = x ]; then
-                       echo "$MAKE $t"
-                       $builddir/timelimit $MMTIME "$MAKE" "$t"
+                       echo "$MAKECOMMAND $t"
+                       $builddir/timelimit $MMTIME "$MAKECOMMAND" "$t"
                        status=$?
                else
                        # we can parallelize everything and all targets
                        if [ x"$t" = xeverything ] || [ x"$t" = xall]; then
-                               echo "$MAKE" "-j$BUILD_FARM_NUM_JOBS"  "$t"
-                               $builddir/timelimit $MMTIME "$MAKE" "-j$BUILD_FARM_NUM_JOBS"  "$t"
+                               echo "$MAKECOMMAND" "-j$BUILD_FARM_NUM_JOBS"  "$t"
+                               $builddir/timelimit $MMTIME "$MAKECOMMAND" "-j$BUILD_FARM_NUM_JOBS"  "$t"
                                status=$?
                        else
-                               echo "$MAKE $t"
-                               $builddir/timelimit $MMTIME "$MAKE" "$t"
+                               echo "$MAKECOMMAND $t"
+                               $builddir/timelimit $MMTIME "$MAKECOMMAND" "$t"
                                status=$?
                        fi
                fi
@@ -274,7 +294,7 @@ do_make() {
                                        ;;
                                *)
                                        #run again with V=1, so we see failed commands
-                                       $builddir/timelimit $MMTIME "$MAKE" "$t" V=1
+                                       $builddir/timelimit $MMTIME "$MAKECOMMAND" "$t" V=1
                                        status=$?
                                        ;;
                        esac
@@ -300,14 +320,11 @@ action_lcovreport() {
                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*|tdb|ntdb|talloc|ldb|libreplace)
+                       lcov --base-directory $builddir/bin --directory $builddir/bin --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
+               waf)
+                       lcov --base-directory $builddir/demos --directory $builddir/demos --capture --output-file $builddir/$tree.lcov.info
                        ;;
                *)
                        lcov --base-directory $builddir --directory $builddir --capture --output-file $builddir/$tree.lcov.info
@@ -323,12 +340,41 @@ action_lcovreport() {
        fi
 }
 
+action_callcatcherreport() {
+       if [ "$CALLCATCHER_REPORT" = "yes" ]; then
+               case "$tree" in
+               tdb|ntdb|talloc|ldb)
+                       callanalyse `find $builddir/bin -name \*.so*` $builddir/bin/* > $builddir/coverage/unused-fns.txt
+                       ;;
+               samba_4*)
+                       callanalyse `find $builddir/bin -name \*.so*` $builddir/bin/* > $builddir/coverage/all-unused-fns.txt 
+                       grep -v -f $srcdir/callcatcher-exceptions.grep $builddir/coverage/all-unused-fns.txt > $builddir/coverage/unused-fns.txt
+                       ;;
+               esac
+               rc=$?
+               echo "return code: $rc"
+       else
+               echo "CALLCATCHER_REPORT not set and callcatcher asked"
+               echo "Most probably an error please fix !"
+               return 1
+       fi
+}
+
 
 ############################
 # configure the tree
 ############################
 
 action_configure() {
+        # special handling for some trees
+       case "$tree" in
+           waf*)
+               $builddir/timelimit $MAXTIME ./waf configure
+               cstatus=$?
+               echo "CONFIGURE STATUS: $cstatus"
+               return $cstatus
+               ;;
+       esac
 
        if [ ! -x $srcdir/configure -a -r $srcdir/Makefile.PL ]; then
                perl $srcdir/Makefile.PL PREFIX="$prefix"
@@ -392,7 +438,7 @@ action_config_log() {
 ############################
 
 action_config_header() {
-       hdr_files="config.h include/config.h bin/default/config.h bin/default/source4/include/config.h bin/default/source3/include/config.h"
+       hdr_files="config.h include/config.h include/autoconf/config.h bin/default/config.h bin/default/include/config.h bin/default/source3/include/config.h"
        for h in $hdr_files; do
                if [ -f $h ]; then
                        echo "contents of $h:"
@@ -419,6 +465,10 @@ action_build() {
                do_make everything torture
                bstatus=$?
                ;;
+       waf*)
+               do_make build
+               bstatus=$?
+               ;;
        *)
                do_make all
                bstatus=$?
@@ -526,6 +576,14 @@ action_test() {
        esac
 }
 
+#############################
+# Do nothing (needed if we have nothing to do for extra_actions)
+#############################
+
+action_none() {
+    return 0;
+}
+
 ###########################
 # do a test build of a particular tree
 # This is the master function called by generic.fns or
@@ -557,9 +615,9 @@ test_tree() {
        # darn, this affects sparse files too! disable it
        # ulimit -f 100000 2> /dev/null
 
-       # try and limit the number of open files to 250. That means we'll discover
-       # fd leaks faster
-       ulimit -n 250 2> /dev/null
+       # try and limit the number of open files to 500, up from 250. That means we'll discover
+       # fd leaks faster while allowing our very complex make test to run
+       ulimit -n 500 2> /dev/null
 
        # Keep stuff private
        umask 077
@@ -582,7 +640,7 @@ test_tree() {
        deptrees=""
        case "$tree" in
                samba-gtk)
-               deptrees="samba_4_0_test"
+               deptrees="samba_current"
                ;;
        esac
 
@@ -626,30 +684,36 @@ test_tree() {
                return
        }
 
-       if [ ! -x $srcdir/configure ] && [ "$tree" != "pidl" ]; then
-               echo "skip: $tree.$compiler configure not present, try again next time!"
-               cd $test_root
-               unlock_file "$lck"
-               return
-       fi
+       # check for essential files
+       case "$tree" in
+           pidl)
+               # no generated files
+               ;;
+           waf*)
+               if [ ! -x $srcdir/waf ]; then
+                   echo "skip: $tree.$compiler waf not present, try again next time!"
+                   cd $test_root
+                   unlock_file "$lck"
+                   return
+               fi
+               ;;
+           *)
+               if [ ! -x $srcdir/configure ]; then
+                   echo "skip: $tree.$compiler configure not present, try again next time!"
+                   cd $test_root
+                   unlock_file "$lck"
+                   return
+               fi
+               ;;
+       esac
 
        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=$srcdir
-                       usingtmpbuild=0
                        export builddir
                        ;;
        esac
@@ -686,17 +750,11 @@ test_tree() {
        lorikeet-heimdal)
                sw_config="$config --enable-socket-wrapper"
                ;;
-       samba_4*)
-               sw_config="$config --enable-socket-wrapper"
-               sw_config="$sw_config --enable-nss-wrapper"
-               sw_config="$sw_config --enable-uid-wrapper"
-               ;;
-       samba_3*)
-               sw_config="$config --enable-socket-wrapper"
-               sw_config="$sw_config --enable-nss-wrapper"
+       samba_*)
+               sw_config="$config --enable-selftest"
                ;;
        samba-gtk)
-               PKG_CONFIG_PATH="$test_root/prefix/samba_4_0_test.$compiler/lib/pkgconfig"
+               PKG_CONFIG_PATH="$test_root/prefix/samba_current.$compiler/lib/pkgconfig"
                export PKG_CONFIG_PATH
                ;;
        *)
@@ -705,6 +763,8 @@ test_tree() {
        esac
 
        if [ "$LCOV_REPORT" = "yes" ]; then
+               PRE_GCOV_CFLAGS=$CFLAGS
+               PRE_GCOV_LDFLAGS=$LDFLAGS
                GCOV_FLAGS="--coverage"
                CFLAGS="$CFLAGS $GCOV_FLAGS" 
                LDFLAGS="$LDFLAGS $GCOV_FLAGS" 
@@ -723,6 +783,11 @@ test_tree() {
                send_logs_skip "$log" "$err"
                unlock_file "$lck"
                echo "Ending build of $tree.$compiler in process $$ at `date`"
+               if [ "$LCOV_REPORT" = "yes" ]; then
+                   CFLAGS=$PRE_GCOV_CFLAGS
+                   LDFLAGS=$PRE_GCOV_LDFLAGS
+                   export CFLAGS LDFLAGS
+               fi
                return
        fi
 
@@ -732,11 +797,16 @@ test_tree() {
 
        #Action == what to do ie. configure config_log ...
        actions="$*"
+       extra_actions="$EXTRA_ACTIONS"
 
        if [ "$actions" = "" ]; then
                actions="configure config_log config_header build install test"
        fi
 
+       if [ "$extra_actions" = "" ]; then
+               extra_actions="none"
+       fi
+
        # start the build
        (
        {
@@ -842,6 +912,54 @@ test_tree() {
                        fi
                done
 
+               for action in $extra_actions; do
+                       if [ "x$action" = "x" ]; then
+                              break;
+                       fi
+
+                       echo Running action $action
+
+                       date
+
+                       cd $builddir || exit 1
+                       export srcdir
+                       df .
+                       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 " return code $action_status $action";
+                       else
+                               echo "ACTION PASSED: $action";
+                       fi
+
+                       if [ $action_status != 0 ]; then 
+                               break;
+                       fi
+               done
+
 
                if [ "$noclean" = "yes" ]; then
                        echo cleanup skipped!
@@ -859,18 +977,14 @@ test_tree() {
                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/
+               CFLAGS=$PRE_GCOV_CFLAGS
+               LDFLAGS=$PRE_GCOV_LDFLAGS
+               export CFLAGS LDFLAGS
        fi
 
        cd $test_root
 
        /bin/rm -rf $prefix
-       if [ "$usingtmpbuild" = "1" ]; then
-               if [ "$noclean" = "yes" ]; then
-                       echo builddir cleanup skipped!
-               else
-                       /bin/rm -rf $builddir
-               fi
-       fi
        # send the logs to the master site
        send_logs "$log" "$err"
 
@@ -928,7 +1042,8 @@ per_run_hook() {
 
        old_trees="web popt distcc samba-gtk smb-build lorikeet-heimdal samba_3_2"
        old_trees="$old_tree samba_3_2_test samba4 samba_4_0_waf samba_4_0_waf.metze"
-       old_trees="$old_tree samba_3_X_test samba_3_X_devel samba_3_X_devel"
+       old_trees="$old_tree samba_3_X_test samba_3_X_devel samba_3_X_devel samba_3_waf samba_3_master tdb2"
+       old_trees="$old_tree samba_3_current samba_3_next samba_4_0_test"
        for d in $old_trees; do
                delete_old_tree $d
        done