add some more discontinued build trees
[build-farm.git] / build_test.fns
index 1ba94ad0a0dec249481e0bd308148d4107a486fe..33f22ab5ca7e20c2c3b4f04bfd1f7a0c1b6e244a 100644 (file)
@@ -7,7 +7,7 @@
 # Copyright (C) 2001, 2003 by Martin Pool <mbp@samba.org>
 
 # default maximum runtime for any command
-MAXTIME=7200
+MAXTIME=12000
 # default maximum memory size (100M) for any command
 MAXMEM=100000
 RUN_FROM_BUILD_FARM=yes
@@ -58,17 +58,24 @@ send_logs() {
                shift
                chmod 0644 "$log" "$err"
 
-               XARGS_I="xargs -i"
-               if [ "`uname`" = "FreeBSD" ]; then
-                       XARGS_I="xargs -I '{}' -R -1"
+               # xargs -i is implemented differently or not at all.
+               # GNU xargs did not implement "-I" until 4.2.9:
+               xargs --version 2>&1 | grep "^GNU xargs" > /dev/null
+               status=$?
+               if [ x"$status" = x"0" ]; then
+                       XARGS_IS_GNU=yes
                fi
-               if [ "`uname`" = "Darwin" ]; then
-                       XARGS_I="xargs -I '{}' -R -1"
+
+               if [ x"$XARGS_IS_GNU" = x"yes" ]; then
+                       XARGS_I="xargs -i"
+               else
+                       XARGS_I="xargs -I '{}'"
                fi
+
                find $log -size +40000 | $XARGS_I sh -c 'dd if={} bs=1024 count=20000 of={}.tmp && mv {}.tmp {} &&  echo "\n***LOG TRUNCATED***" >> {}'
                find $err -size +40000 | $XARGS_I sh -c 'dd if={} bs=1024 count=20000 of={}.tmp && mv {}.tmp {} &&  echo "\n***LOG TRUNCATED***" >> {}'
 
-               rsync $* -ct -q --password-file=.password -z --timeout=200 \
+               rsync $* -c -q --password-file=.password -z --timeout=200 \
                    "$log" "$err" $host@build.samba.org::build_farm_data/
        fi
 }
@@ -91,7 +98,7 @@ fetch_tree() {
        else
                fetchtree=$1
                if rsync --exclude=autom4te.cache/ --exclude=.svn/ --exclude=.git/ \
-                       --delete-excluded -q --partial --timeout=200 -crlpz --delete --ignore-errors \
+                       --delete-excluded -q --partial --timeout=200 -ctrlpz --delete --ignore-errors \
                        samba.org::ftp/unpacked/$fetchtree/ $test_root/$fetchtree; then
                        echo "transferred $fetchtree OK"
                else
@@ -134,11 +141,7 @@ choose_scm() {
        tree=$1
 
        case "$tree" in
-               ccache | distcc | rsync)
-                       echo "cvs"
-                       return 0
-               ;;
-               samba_3*)
+               samba* | rsync | libreplace | talloc | tdb | ldb | pidl | ccache*)
                        echo "git"
                        return 0
                ;;
@@ -211,7 +214,7 @@ do_make() {
   MMTIME=$MAXTIME
   # some trees don't need as much time
   case "$tree" in
-       rsync | tdb | talloc | libreplace | ccache | distcc)
+       rsync | tdb | talloc | libreplace | ccache*)
          if [ "$compiler" != "checker" ]; then
              MMTIME=`expr $MMTIME / 5`
          fi
@@ -222,21 +225,33 @@ do_make() {
   for t in $*; do
     if [ x"$BUILD_FARM_NUM_JOBS" = x ]; then
       echo "$MAKE $t"
-      ./timelimit $MMTIME "$MAKE" "$t"
+      $builddir/timelimit $MMTIME "$MAKE" "$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"
-        ./timelimit $MMTIME "$MAKE" "-j$BUILD_FARM_NUM_JOBS"  "$t"
+        $builddir/timelimit $MMTIME "$MAKE" "-j$BUILD_FARM_NUM_JOBS"  "$t"
         status=$?
       else
         echo "$MAKE $t"
-        ./timelimit $MMTIME "$MAKE" "$t"
+        $builddir/timelimit $MMTIME "$MAKE" "$t"
         status=$?
       fi
     fi
 
+    if [ $status != 0 ]; then
+       case "$t" in
+           test | check | installcheck)
+               ;;
+           *)
+               # run again with V=1, so we see failed commands
+               $builddir/timelimit $MMTIME "$MAKE" "$t" V=1
+               status=$?
+               ;;
+       esac
+    fi
+
     if [ $status != 0 ]; then
       return $status;
     fi
@@ -249,6 +264,12 @@ do_make() {
 ############################
 # configure the tree
 action_configure() {
+       if [ ! -x $srcdir/configure -a -r $srcdir/Makefile.PL ]; then
+               perl $srcdir/Makefile.PL PREFIX="$prefix"
+               cstatus=$?
+               echo "CONFIGURE STATUS: $cstatus"
+               return $cstatus;
+       fi
         if [ ! -x $srcdir/configure ]; then
            ls -l $srcdir/configure
            echo "$srcdir/configure is missing"
@@ -261,133 +282,70 @@ action_configure() {
        echo CC="$CCACHE $compiler" $srcdir/configure $config_and_prefix
        CC="$CCACHE $compiler"
        export CC
-       ./timelimit $MAXTIME $srcdir/configure $config_and_prefix
+       $builddir/timelimit $MAXTIME $srcdir/configure $config_and_prefix
        cstatus=$?
-       echo "CONFIGURE STATUS: $cstatus"
-       if [ -f config.h ]; then
-           echo "contents of config.h:"
-           cat config.h
-       fi
-       if [ -f include/config.h ]; then
-           echo "contents of include/config.h:"
-           cat include/config.h
+       if [ x"$cstatus" != x"0" ]; then
+               if [ -f config.log ]; then
+                       echo "contents of config.log:"
+                       cat config.log
+               fi
+               if [ -f bin/config.log ]; then
+                       echo "contents of config.log:"
+                       cat bin/config.log
+               fi
        fi
+       echo "CONFIGURE STATUS: $cstatus"
        return $cstatus;
 }
 
 ############################
 # show the configure log
 action_config_log() {
-        if [ ! -f config.log ]; then
+    log_files="config.log bin/config.log"
+    for f in $log_files; do
+        if [ -f $f ]; then
+           echo "contents of config.log:"
+           cat $f
            return 0;
        fi
-       echo "contents of config.log:"
-       cat config.log
-       return 0;
+    done
+    return 0
+}
+
+############################
+# show the config.h
+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"
+    for h in $hdr_files; do
+       if [ -f $h ]; then
+           echo "contents of $h:"
+           cat $h
+           return 0;
+       fi
+    done
+    return 0;
 }
 
 copy_dir() {
        Tsrc=$1
        Tdst=$2
-       rsync -a --delete $Tsrc/ $Tdst
-}
-
-s4selftest_create() {
-       lock_file "s4selftest.lck" || {
-               return 1;
-       }
-
-       rm -rf $s4selftest/
-       mkdir -p $s4selftest/source
-
-       copy_dir $builddir/bin $s4selftest/source/bin || {
-               rm -rf $s4selftest/;
-               unlock_file "s4selftest.lck";
-               return 1;
-       }
-
-       copy_dir $srcdir/setup $s4selftest/source/setup || {
-               rm -rf $s4selftest/;
-               unlock_file "s4selftest.lck";
-               return 1;
-       }
-
-       copy_dir $srcdir/../testprogs $s4selftest/testprogs || {
-               rm -rf $s4selftest/;
-               unlock_file "s4selftest.lck";
-               return 1;
-       }
-
-       copy_dir $srcdir/selftest $s4selftest/source/selftest || {
-               rm -rf $s4selftest/;
-               unlock_file "s4selftest.lck";
-               return 1;
-       }
-
-       copy_dir $srcdir/script $s4selftest/source/script || {
-               rm -rf $s4selftest/;
-               unlock_file "s4selftest.lck";
-               return 1;
-       }
-
-       mkdir -p $s4selftest/source/scripting || {
-               rm -rf $s4selftest/;
-               unlock_file "s4selftest.lck";
-               return 1;
-       }
-
-       copy_dir $srcdir/scripting/libjs $s4selftest/source/scripting/libjs || {
-               rm -rf $s4selftest/;
-               unlock_file "s4selftest.lck";
-               return 1;
-       }
-       
-       unlock_file "s4selftest.lck"
+       pwd
+       echo rsync -a --delete $Tsrc/ $Tdst
+       rsync -a --delete $Tsrc/ $Tdst || return 1
+       return 0
 }
 
-s4selftest_update() {
-       lock_file "s4selftest.lck" || {
-               return 1;
-       }
-
-       copy_dir $s4selftest $s4selftest.$tree.$compiler.$$ || {
-               rm -rf $s4selftest.$tree.$compiler.$$;
-               unlock_file "s4selftest.lck";
-               return 1;
-       }
-
-       rm -rf $s4selftest.$tree.$compiler
-       mv $s4selftest.$tree.$compiler.$$ $s4selftest.$tree.$compiler
-
-       unlock_file "s4selftest.lck"
-}
 
 ############################
 # build the tree
 action_build() {
        case "$tree" in
-       samba4)
+       samba_4*)
                do_make everything
                bstatus=$?
-               if test x"$bstatus" != x"0"; then
-                       # the 2nd 'make everything' is to work around a bug
-                       # in netbsd make. 
-                       do_make everything
-                       bstatus=$?
-               fi
-
-               if test x"$bstatus" != x"0"; then
-                       do_make testsuite
-                       bstatus=$?
-               fi
-
-               if test x"$bstatus" = x"0"; then
-                       s4selftest_create
-               fi
-
                ;;
        samba_3*)
-               do_make proto everything torture
+               do_make everything torture
                bstatus=$?
                ;;
        *)
@@ -437,6 +395,11 @@ action_install() {
 action_test_samba() {
        do_make test
        totalstatus=$?
+       # if we produced a test summary then show it
+       [ -f st/summary ] && {
+           echo "TEST SUMMARY"
+           cat st/summary
+       }
        return "$totalstatus"
 }
 
@@ -494,7 +457,7 @@ test_tree() {
        shift
        shift
        shift
-       if [ "$compiler" = "gcc" ] && [ "$tree" != "ccache" ] && ccache -V > /dev/null; then
+       if [ "$compiler" = "gcc" ] && [ "$tree" != "ccache" ] && [ "$tree" != "ccache-maint" ] && ccache -V > /dev/null; then
            CCACHE="ccache"
            export CCACHE
        else
@@ -511,9 +474,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 150. That means we'll discover
+       # try and limit the number of open files to 250. That means we'll discover
        # fd leaks faster
-       ulimit -n 150 2> /dev/null
+       ulimit -n 250 2> /dev/null
 
        # Keep stuff private
        umask 077
@@ -535,14 +498,8 @@ test_tree() {
        # work out what other trees this package depends on
        deptrees=""
        case "$tree" in
-           talloc | tdb)
-               deptrees="libreplace";
-           ;;
-           ldb)
-               deptrees="libreplace talloc tdb";
-           ;;
-               samba-gtk)
-               deptrees="samba4"
+           samba-gtk)
+               deptrees="samba_4_0_test"
                ;;
        esac
 
@@ -587,7 +544,7 @@ test_tree() {
        echo "Starting build of $tree.$compiler in process $$ at `date`"
 
        case "$tree" in
-           tdb | talloc | ldb | libreplace)
+           libreplace)
                builddir="$test_root/tmp.$tree.$compiler"
                usingtmpbuild=1
                if [ -d $builddir ]; then
@@ -613,55 +570,49 @@ test_tree() {
            fi
        fi
 
+        # 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
+       echo "Building killbysubdir"
+       echo $compiler -o $builddir/killbysubdir $test_root/killbysubdir.c
+       $compiler -o $builddir/killbysubdir $test_root/killbysubdir.c
+
        prefix="$test_root/prefix/$tree.$compiler"
        mkdir -p "$prefix"
 
-       s4selftest=$test_root/s4selftest
-       export s4selftest
-
        sw_config=$config
 
        case "$tree" in
        lorikeet-heimdal)
                sw_config="$config --enable-socket-wrapper"
                ;;
-       samba4)
+       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"
-               s4selftest_update "$tree" "$compiler" && {
-                       t="$s4selftest.$tree.$compiler/source"
-                       #sw_config="$sw_config --with-samba4srcdir=$t"
-                       t="$t/bin/smbtorture"
-                       sw_config="$sw_config --with-smbtorture4-path=$t"
-               }
                ;;
        samba-gtk)
-               PKG_CONFIG_PATH="$test_root/prefix/samba4.$compiler/lib/pkgconfig"
+               PKG_CONFIG_PATH="$test_root/prefix/samba_4_0_test.$compiler/lib/pkgconfig"
                export PKG_CONFIG_PATH
                ;;
-       ldb)
-               fetch_tree popt
-               ;;
-       talloc)
-               fetch_tree libreplace
-               ;;
        *)
                testsuite=testsuite
                ;;
        esac
 
        if [ "$LCOV_REPORT" = "yes" ]; then
-           GCOV_FLAGS="-ftest-coverage -fprofile-arcs"
-           GCOV_LIBS="-lgcov"
-           HOSTCC_CFLAGS="$HOSTCC_CFLAGS $GCOV_FLAGS" 
+           GCOV_FLAGS="--coverage"
            CFLAGS="$CFLAGS $GCOV_FLAGS" 
-           LDFLAGS="$LDFLAGS $GCOV_FLAGS $GCOV_LIBS" 
-           SHLD_FLAGS="$SHLD_FLAGS $GCOV_FLAGS $GCOV_LIBS"
-           export HOSTCC_CFLAGS CFLAGS LDFLAGS SHLD_FLAGS
+           LDFLAGS="$LDFLAGS $GCOV_FLAGS" 
+           export CFLAGS LDFLAGS
        fi
 
        config_and_prefix="$sw_config --prefix=$prefix"
@@ -686,11 +637,12 @@ test_tree() {
        actions="$*"
        
        if [ "$actions" = "" ]; then
-           actions="configure config_log build install test"
+           actions="configure config_log config_header build install test"
        fi
 
        # start the build
        (
+       {
                # we all want to be able to read the output...
                LANG=C
                export LANG
@@ -718,13 +670,8 @@ test_tree() {
                echo "Showing limits"
                ulimit -a 2> /dev/null
 
-               # build the timelimit utility
-               echo "Building timelimit"
-               mkdir -p $builddir
-               $compiler $TIMELIMIT_FLAGS -o $builddir/timelimit $test_root/timelimit.c || exit 1
-
                # the following is for non-samba builds only
-               if [ -r $test_root/$tree.svn ]; then
+               if [ "$scm" = "svn" -a -r $test_root/$tree.svn ]; then
                  h_rev=`grep 'Revision: ' $test_root/$tree.svn | cut -d ':' -f2 | cut -d ' ' -f2 | sed 1q`
                  if [ -n "$h_rev" ]; then
                        echo "HIGHEST SVN REVISION: $h_rev"
@@ -733,13 +680,24 @@ test_tree() {
                  if [ -n "$rev" ]; then
                        echo "BUILD REVISION: $rev"
                  fi
+               elif [ "$scm" = "git" -a -r $test_root/$tree.git ]; then
+                 csha1=`cat $test_root/$tree.git |head -3 | tail -1`
+                 if [ -n "$csha1" ]; then
+                   echo "BUILD COMMIT REVISION: $csha1"
+                 fi
+                 cdate=`cat $test_root/$tree.git |head -4 | tail -1`
+                 if [ -n "$cdate" ]; then
+                   echo "BUILD COMMIT DATE: $cdate"
+                 fi
+                 ctime=`cat $test_root/$tree.git |head -2 | tail -1`
+                 if [ -n "$ctime" ]; then
+                   echo "BUILD COMMIT TIME: $ctime"
+                 fi
                fi
 
-
-               if [ "$tree" = "pidl" ] 
-               then
-                       cd $builddir
-                       perl ./Makefile.PL "$prefix"
+               if [ -x $builddir/killbysubdir ]; then
+                   echo "$builddir/killbysubdir $builddir in `pwd`"
+                   $builddir/killbysubdir $builddir
                fi
 
                for action in $actions; do
@@ -756,7 +714,9 @@ test_tree() {
 
                    ( action_$action )
                    action_status=$?
-                   
+
+                   df .
+
                    if [ $action_status != 0 ]; then
                        echo "ACTION FAILED: $action";
                    else
@@ -774,10 +734,16 @@ test_tree() {
                        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}.{gcda,gcno}
+                           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
@@ -791,7 +757,10 @@ test_tree() {
                    do_make clean
                fi
                date
-       ) > "$log" 2> "$err"
+       } 3>&2 2>&1 1>&3 | tee "$err"
+       ) > "$log" 2>&1
+       # be aware the above channel swap may sometimes result in unordered
+       # stdout/stderr merge
 
        if [ "$LCOV_REPORT" = "yes" ]; then
            chmod u=rwX,g=rX,o=rX -R $builddir/coverage
@@ -830,17 +799,7 @@ global_unlock() {
     unlock_file "global.lck"
 }
 
-#########################################################
-# enable this on a per host basis only when needed please
-# (at least for the moment)
-kill_old_processes() {
-    # this should work on systems with linux like ps
-    (ps uxfw | grep /build | grep -v grep | egrep 'Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec' | awk '{print $2}' | xargs kill -9) 2> /dev/null
-    # and this should work on sysv style ps
-    (ps -fu $USER | grep /build | grep -v grep | egrep 'Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec' | awk '{print $2}' | xargs kill -9) 2> /dev/null
-}
-
-delete_old_svn_tree() {
+delete_old_tree() {
        otree=$1
 
        test -z "$otree" && return 0;
@@ -848,7 +807,8 @@ delete_old_svn_tree() {
        rm -rf $otree
        rm -rf $otree.svn
        rm -rf $otree.*.svn
-       rm -rf s4selftest.$otree.*
+       rm -rf $otree.git
+       rm -rf $otree.*.git
        rm -rf build.$otree.*
 }
 
@@ -861,9 +821,6 @@ per_run_hook() {
        nohost)
            echo "just a placeholder";
            ;;
-       tridge)
-           kill_old_processes
-           ;;
        deckchair)
            rm -f deckchair.fns
            ;;
@@ -873,7 +830,10 @@ per_run_hook() {
        rm -f build.log
     fi
 
-    delete_old_svn_tree "samba_3_2"
+    old_trees="web popt distcc samba-gtk smb-build lorikeet-heimdal samba_3_2 samba_3_2_test samba4 samba_4_0_waf samba_4_0_waf.metze samba_3_X_test samba_3_X_devel samba_3_X_devel"
+    for d in $old_trees; do
+       delete_old_tree $d
+    done
 }