use generic.fns in SerNet-Tru64.fns
[build-farm.git] / build_test.fns
index 50a72267eddf9a176793446b09814c76864eff42..2358524ad9d35a3f991b852a1705d950fd886d57 100644 (file)
@@ -13,6 +13,7 @@ SMBD_MAXTIME=18000 # 5 hours for a samba process ..
 MAXMEM=100000
 RUN_FROM_BUILD_FARM=yes
 export RUN_FROM_BUILD_FARM
+export MAXTIME SMBD_MAXTIME
 
 deptrees="";
 
@@ -163,7 +164,7 @@ choose_scm() {
        tree=$1
 
        case "$tree" in
-                       samba* | rsync | libreplace | talloc | tdb | ldb | pidl | ccache*)
+                       samba* | rsync | libreplace | talloc | tdb* | ldb | pidl | ccache* | waf*)
                        echo "git"
                                return 0
                        ;;
@@ -195,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
                        }
@@ -236,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* | 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
@@ -275,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
@@ -304,9 +323,11 @@ action_lcovreport() {
                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
+               samba_4*|tdb*|talloc|ldb|libreplace)
+                       lcov --base-directory $builddir/bin --directory $builddir/bin --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
@@ -322,12 +343,41 @@ action_lcovreport() {
        fi
 }
 
+action_callcatcherreport() {
+       if [ "$CALLCATCHER_REPORT" = "yes" ]; then
+               case "$tree" in
+               tdb*|talloc|ldb)
+                       callanalyse `find $builddir/bin -name \*.so*` $builddir/bin/* > $builddir/coverage/unused-fns.txt
+                       ;;
+               samba_3_master|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"
@@ -391,7 +441,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:"
@@ -418,6 +468,10 @@ action_build() {
                do_make everything torture
                bstatus=$?
                ;;
+       waf*)
+               do_make build
+               bstatus=$?
+               ;;
        *)
                do_make all
                bstatus=$?
@@ -625,30 +679,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
@@ -704,6 +764,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" 
@@ -722,6 +784,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
 
@@ -733,7 +800,7 @@ test_tree() {
        actions="$*"
 
        if [ "$actions" = "" ]; then
-               actions="configure config_log config_header build install test"
+               actions="configure config_log config_header build install test $EXTRA_ACTIONS"
        fi
 
        # start the build
@@ -858,18 +925,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"
 
@@ -927,7 +990,7 @@ 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"
        for d in $old_trees; do
                delete_old_tree $d
        done