allow a couple more environment variables to be set before running QA.
[xfstests-dev.git] / tools / auto-qa
index a5fce01a1fae2d830e33040a56f2d01fd354003f..6d98dd288acc9f135f71c070b62916334d44b90b 100755 (executable)
 
 # configuration (you could tune this)
 
-EXTRA="-xfs-qa"
 BOOT="/boot"
 SOAK_PASSES="-1"
 SOAK_STRESS="10000"
 SOAK_PROC="3"
+export EXTRA=${EXTRA:=-xfs-qa}
 export MKFS_OPTIONS=${MKFS_OPTIONS:=-bsize=4096}
 export MOUNT_OPTIONS=${MOUNT_OPTIONS:=-ologbufs=2}
+export MALLOCLIB=${MALLOCLIB:=/usr/lib/libefence.a}
 
 _log()
 {
@@ -53,8 +54,8 @@ _fail()
 {
     if [ "$started" = "1" ] 
     then
-        echo "auto-qa stopped" | wall
-        started=0
+       echo "auto-qa stopped" | wall
+       started=0
     fi
 
     _log "$*"
@@ -62,9 +63,9 @@ _fail()
     # send special email if a cron'd qa run fails
     case $state
     in
-        cron*)
-            mail -s "xfs qa status report" $ADMINEMAIL \
-                < $LOG 2>&1
+       cron*)
+           mail -s "XFS QA status report" $ADMINEMAIL \
+               < $LOG 2>&1
        ;;
     esac
 
@@ -75,19 +76,19 @@ _fail()
 _get_kernel_version()
 {
     [ -x "$WORKAREA" ] \
-        || _fail "can't access workarea $WORKAREA"
+       || _fail "can't access workarea $WORKAREA"
     [ -r "$WORKAREA/linux/Makefile" ] \
-        || _fail "can't read makefile $WORKAREA/linux/Makefile"
+       || _fail "can't read makefile $WORKAREA/linux/Makefile"
 
     eval `awk '
-        BEGIN { FS = "[ \t=]+" }
-        /^VERSION =/ { a=$2 }
-        /^PATCHLEVEL =/ { b=$2 }
-        /^SUBLEVEL =/ { c=$2 }
-        /^EXTRAVERSION =/ { d=$2 }
+       BEGIN { FS = "[ \t=]+" }
+       /^VERSION =/ { a=$2 }
+       /^PATCHLEVEL =/ { b=$2 }
+       /^SUBLEVEL =/ { c=$2 }
+       /^EXTRAVERSION =/ { d=$2 }
        END { 
            print "VERSION=" a "." b "." c d " ; SVERSION=" a "." b "." c
-        }
+       }
    ' < $WORKAREA/linux/Makefile`
 }
 
@@ -117,15 +118,15 @@ LOG="$ROOT/qa.log"
 case $HOST
 in
     bruce)
-        EMAIL="nathans@larry"
-        ADMINEMAIL="nathans@larry"
-        MODULAR=0
-        ;;
+       EMAIL="nathans@larry"
+       ADMINEMAIL="nathans@larry"
+       MODULAR=0
+       ;;
     sagan)
-        EMAIL="tes@larry"
-        ADMINEMAIL="tes@larry"
-        MODULAR=1
-        ;;
+       EMAIL="tes@larry"
+       ADMINEMAIL="tes@larry"
+       MODULAR=1
+       ;;
     troppo)
        EMAIL="kaos@larry"
        ADMINEMAIL="kaos@larry"
@@ -137,8 +138,8 @@ in
        MODULAR=0
        ;;
     *)
-        _fail "auto-qa: no configuration information for host '$HOST'"
-        ;;
+       _fail "auto-qa: no configuration information for host '$HOST'"
+       ;;
 esac
 
 # do some cleanup on exit
@@ -149,8 +150,8 @@ _cleanup()
     umount $TEST_DEV &> /dev/null
     if [ "$started" = 1 ]
     then
-        echo "auto-qa stopped" | wall
-        started=0
+       echo "auto-qa stopped" | wall
+       started=0
     fi
 }
 status=1
@@ -181,20 +182,20 @@ _change_state()
     
     case $state
     in
-        *-*)
-            case $new
-            in
-                *-*)
-                    _set_state $new
-                    ;;
-                *)
-                    _set_state `echo $state | sed "s/-.*$/-$new/"`
-                    ;;
-            esac
-            ;;
-        *)
-            _set_state $new
-            ;;
+       *-*)
+           case $new
+           in
+               *-*)
+                   _set_state $new
+                   ;;
+               *)
+                   _set_state `echo $state | sed "s/-.*$/-$new/"`
+                   ;;
+           esac
+           ;;
+       *)
+           _set_state $new
+           ;;
     esac
 }
 
@@ -223,27 +224,27 @@ _update_autoqa_file()
 _update_workarea()
 {
     if [ -z "$CVSROOT" ]; then
-       _log "        *** p_tupdate"
+       _log "  *** p_tupdate"
        cd $WORKAREA 
        p_tupdate 2>&1 \
-                       || _fail "            !!! p_tupdate failed"
+                       || _fail "          !!! p_tupdate failed"
 
-       _log "        *** p_check/p_purge"
+       _log "  *** p_check/p_purge"
        cd $WORKAREA 
        p_check -s | p_purge -yiu 2>&1 \
-                       || _fail "            !!! p_check/p_purge failed"
+                       || _fail "          !!! p_check/p_purge failed"
 
-       _log "        *** non-trunk files"
+       _log "  *** non-trunk files"
        cd $WORKAREA 
        p_list -c 2>&1 \
-                       || _fail "            !!! p_list failed"
+                       || _fail "          !!! p_list failed"
     else
-       _log "        *** cvs update"
+       _log "  *** cvs update"
        cd $WORKAREA
        cvs -z3 update -d
     fi
 }
-            
+           
 
 _log "*** linux-xfs QA (`date`)"
 
@@ -253,23 +254,23 @@ _get_state
 case $1
 in
     cron-init)
-        case $state
-        in
-            *done)
-                ;;
-            *)
-                _fail "    !!! cron-init while not in \"*done\" state"
-                ;;
-        esac
-        ;;
+       case $state
+       in
+           *done)
+               ;;
+           *)
+               _fail "    !!! cron-init while not in \"*done\" state"
+               ;;
+       esac
+       ;;
     cron-restarted)
-        # we don't auto restart after reboot, but cron the restart
-        # to happen a bit later - it's much easier and safer that way
-        if [ "$state" != "cron-restarted" ]
-        then
-            _fail "    !!! cron-restarted while not in \"cron-restarted\" state"
-        fi
-        ;;
+       # we don't auto restart after reboot, but cron the restart
+       # to happen a bit later - it's much easier and safer that way
+       if [ "$state" != "cron-restarted" ]
+       then
+           _fail "    !!! cron-restarted while not in \"cron-restarted\" state"
+       fi
+       ;;
 esac
 
 if [ "$1" != "" ]
@@ -298,257 +299,255 @@ do
     _get_state
 
     _log "    *** state $state start (`date`)"
-    _log "        (user=$USER, host=$HOST)"
+    _log "     (user=$USER, host=$HOST)"
     new_state=""
 
     case $state
     in
-        *init)
-            echo "" > $ROOT/qa.log
-            echo "" > $ROOT/qa.full
-            _log "******************************************************"
-            _log "QA init $VERSION (`date`)"
-            _log "******************************************************"
+       *init)
+           echo "" > $ROOT/qa.log
+           echo "" > $ROOT/qa.full
+           _log "******************************************************"
+           _log "QA init $VERSION (`date`)"
+           _log "******************************************************"
            _log "--- kernel ($IMAGE)"
            _log "--- modules ($MODULES)"
 
-            _change_state "inited"
-            _update_autoqa_file
-            ;;
-            
-        *inited)
-            _log "        *** QA initialized"
-            new_state="update"
-            ;;
-        
-        *update)
-            _update_workarea
-            new_state="clean"
-            ;;
-
-        *clean)
-            # we need to configure or else we might fail to clean
-            for pkg in attr acl xfsprogs dmapi xfsdump xfstests
+           _change_state "inited"
+           _update_autoqa_file
+           ;;
+           
+       *inited)
+           _log "      *** QA initialized"
+           new_state="update"
+           ;;
+       
+       *update)
+           _update_workarea
+           new_state="clean"
+           ;;
+
+       *clean)
+           # we need to configure or else we might fail to clean
+           for pkg in attr acl xfsprogs dmapi xfsdump xfstests
+           do
+               cd $WORKAREA/cmd/$pkg
+               _log "  *** clean $pkg tools"
+               make realclean 2>&1 \
+                       || _fail "          !!! clean $pkg failed"
+           done
+
+           _log "      *** clean linux"
+           cd $WORKAREA/linux
+           make mrproper 2>&1 \
+                       || _fail "          !!! clean linux failed"
+
+           _log "      *** install configuration file"
+           cp -f $CONFIG $WORKAREA/linux/.config 2>&1 \
+                       || _fail "          !!! failed to install config"
+           
+           _log "      *** remove version file"
+           rm -f include/linux/version.h 2>&1 \
+                       || _fail "          !!! failed to clean version"
+
+           new_state="reconfig"
+           ;;
+           
+       *reconfig)
+       
+           _log "      *** reconfig kernel"
+           
+           _change_state "clean" ; # we better start from scratch if this fails
+           
+           cd $WORKAREA/linux
+           # we want to use default options for any new config options.
+           echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | \
+               make EXTRAVERSION=$EXTRA oldconfig 2>&1 \
+                       || _fail "          !!! reconfig oldconfig failed"
+           make EXTRAVERSION=$EXTRA dep 2>&1 \
+                       || _fail "          !!! reconfig dep failed"
+
+           new_state="buildtools"
+           ;;
+           
+       *buildtools)
+           _log "      *** build and install tools"
+           for pkg in attr acl xfsprogs dmapi xfsdump xfstests 
            do
-                cd $WORKAREA/cmd/$pkg
-                _log "        *** clean $pkg tools"
-                make realclean 2>&1 \
-                        || _fail "            !!! clean $pkg failed"
-            done
-
-            _log "        *** clean linux"
-            cd $WORKAREA/linux
-            make mrproper 2>&1 \
-                        || _fail "            !!! clean linux failed"
-
-            _log "        *** install configuration file"
-            cp -f $CONFIG $WORKAREA/linux/.config 2>&1 \
-                        || _fail "            !!! failed to install config"
-            
-            _log "        *** remove version file"
-            rm -f include/linux/version.h 2>&1 \
-                        || _fail "            !!! failed to clean version"
-
-            new_state="reconfig"
-            ;;
-            
-        *reconfig)
-        
-            _log "        *** reconfig kernel"
-            
-            _change_state "clean" ; # we better start from scratch if this fails
-            
-            cd $WORKAREA/linux
-            # we want to use default options for any new config options.
-            echo -e "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" | \
-                make EXTRAVERSION=$EXTRA oldconfig 2>&1 \
-                        || _fail "            !!! reconfig oldconfig failed"
-            make EXTRAVERSION=$EXTRA dep 2>&1 \
-                        || _fail "            !!! reconfig dep failed"
-
-            new_state="buildtools"
-            ;;
-            
-        *buildtools)
-            _log "        *** build and install tools"
-            for pkg in attr acl xfsprogs dmapi xfsdump xfstests 
-            do
-                cd $WORKAREA/cmd/$pkg
-
-                # use e-fence - but this will only take effect on configure
-                export MALLOCLIB=/usr/lib/libefence.a
-                make configure 2>&1 \
-                        || _fail "            !!! configure $pkg failed"
-                make default 2>&1 \
-                        || _fail "            !!! build $pkg failed"
-
-                _sudo make install install-dev 2>&1 \
-                        || _fail "            !!! install $pkg failed"
+               cd $WORKAREA/cmd/$pkg
+
+               # use e-fence - but this will only take effect on configure
+               make configure 2>&1 \
+                       || _fail "          !!! configure $pkg failed"
+               make default 2>&1 \
+                       || _fail "          !!! build $pkg failed"
+
+               _sudo make install install-dev 2>&1 \
+                       || _fail "          !!! install $pkg failed"
 
                # attr and acl now have install-lib targets as well
                [ "$pkg" == "attr" -o "$pkg" == "acl" ] || continue
                _sudo make install-lib 2>&1 \
-                       || _fail "            !!! install $pkg failed"
-            done
-
-            new_state="buildkernel"
-            ;;
-
-        *buildkernel)
-            _log "        *** build kernel"
-            
-            _change_state "clean" ; # we better start from scratch if this fails
-            
-            cd $WORKAREA/linux
-            make -j4 EXTRAVERSION=$EXTRA bzImage modules 2>&1 \
-                        || _fail "            !!! build bzImage/modules failed"
-            new_state="install"
-            ;;
-
-        *install)
-            _log "        *** blat old modules"
-            
-            _sudo rm -rf $MODULES
-            
-            _log "        *** install kernel"
-            cd $WORKAREA/linux
-            _sudo cp -f $WORKAREA/linux/arch/i386/boot/bzImage $IMAGE 2>&1 \
-                        || _fail "            !!! install kernel failed"
-            _sudo cp -f $WORKAREA/linux/System.map $SYSTEMMAP 2>&1 \
-                        || _fail "            !!! install kernel failed"
-            _sudo make EXTRAVERSION=$EXTRA modules_install 2>&1 \
-                        || _fail "            !!! install modules failed"
-
-            _log "        *** reinit lilo"
-            _sudo /sbin/lilo 2>&1 \
-                        || _fail "            !!! reinit lilo failed"
-            new_state="restart"
-            ;;
-            
-        *restart)
-            _log "            *** select qa kernel"
-            _sudo /sbin/lilo -R linux-xfs-qa 2>&1 \
-                        || _fail "            !!! lilo failed"
-            
-            _log "            *** prepare to restart"
-            _change_state "restarted"
-            
-            _log "            *** restarting"
+                       || _fail "          !!! install $pkg failed"
+           done
+
+           new_state="buildkernel"
+           ;;
+
+       *buildkernel)
+           _log "      *** build kernel"
+           
+           _change_state "clean" ; # we better start from scratch if this fails
+           
+           cd $WORKAREA/linux
+           make -j4 EXTRAVERSION=$EXTRA bzImage modules 2>&1 \
+                       || _fail "          !!! build bzImage/modules failed"
+           new_state="install"
+           ;;
+
+       *install)
+           _log "      *** blat old modules"
+           
+           _sudo rm -rf $MODULES
+           
+           _log "      *** install kernel"
+           cd $WORKAREA/linux
+           _sudo cp -f $WORKAREA/linux/arch/i386/boot/bzImage $IMAGE 2>&1 \
+                       || _fail "          !!! install kernel failed"
+           _sudo cp -f $WORKAREA/linux/System.map $SYSTEMMAP 2>&1 \
+                       || _fail "          !!! install kernel failed"
+           _sudo make EXTRAVERSION=$EXTRA modules_install 2>&1 \
+                       || _fail "          !!! install modules failed"
+
+           _log "      *** reinit lilo"
+           _sudo /sbin/lilo 2>&1 \
+                       || _fail "          !!! reinit lilo failed"
+           new_state="restart"
+           ;;
+           
+       *restart)
+           _log "          *** select qa kernel"
+           _sudo /sbin/lilo -R linux-xfs-qa 2>&1 \
+                       || _fail "          !!! lilo failed"
+           
+           _log "          *** prepare to restart"
+           _change_state "restarted"
+           
+           _log "          *** restarting"
 
            _restart # doesn't return
-            ;;
-            
-        *restarted)
-            _log "            *** QA reentered after restart"
-            
-            new_state="check"
-            ;;
-          
-        *check)
-            uname=`uname -ar`
-            _log "            *** uname $uname"
-            _log "            *** user tools"
-            ls -l /sbin/*xfs* /usr/sbin/*xfs* 2>&1
-            _log "            *** kernel"
-            ls -l /boot/*$EXTRA*  2>&1
-            _log "            *** kernel modules"
-            ls -l /lib/modules/$SVERSION$EXTRA/kernel/fs/xfs/* \
-                  /lib/modules/$SVERSION$EXTRA/kernel/fs/xfs_support/* 
-            
-            if [ "$MODULAR" -eq 0 ]
-            then
-                new_state="reset"
-            else
-                new_state="probe"
-            fi
-            ;;
-            
-        *probe)
-            _log "            *** modules dependencies"
-            
-            _sudo depmod -a  2>&1 \
-                        || _fail "            !!! failed to depmod -a" 
-            
-            _log "            *** unmounting XFS mounts"
-            
-            _sudo umount -a -t xfs 2>&1
-            
-            _log "            *** removing modules"
-            
-            for m in xfsidbg xfs kdbm_pg kdbm_vm
-            do
-                _sudo rmmod $m 2> /dev/null
-            done
-            
-            _log "            *** installing modules"
+           ;;
+           
+       *restarted)
+           _log "          *** QA reentered after restart"
+           
+           new_state="check"
+           ;;
+         
+       *check)
+           uname=`uname -ar`
+           _log "          *** uname $uname"
+           _log "          *** user tools"
+           ls -l /sbin/*xfs* /usr/sbin/*xfs* 2>&1
+           _log "          *** kernel"
+           ls -l /boot/*$EXTRA*  2>&1
+           _log "          *** kernel modules"
+           ls -l /lib/modules/$SVERSION$EXTRA/kernel/fs/xfs/*
+
+           if [ "$MODULAR" -eq 0 ]
+           then
+               new_state="reset"
+           else
+               new_state="probe"
+           fi
+           ;;
+           
+       *probe)
+           _log "          *** modules dependencies"
+           
+           _sudo depmod -a  2>&1 \
+                       || _fail "          !!! failed to depmod -a" 
+           
+           _log "          *** unmounting XFS mounts"
+           
+           _sudo umount -a -t xfs 2>&1
+           
+           _log "          *** removing modules"
+           
+           for m in xfsidbg xfs kdbm_pg kdbm_vm
+           do
+               _sudo rmmod $m 2> /dev/null
+           done
+           
+           _log "          *** installing modules"
 
            _sudo modprobe xfs 2>&1 \
-                        || _fail "            !!! failed to modprobe xfs"
-
-            new_state="reset"
-            ;;
-            
-        *reset)
-            
-            _log "            *** unmounting TEST_DEV"
-            
-            _sudo umount $TEST_DEV 2>&1
-            
-            _log "            *** unmounting SCRATCH_DEV"
-            
-            _sudo umount $SCRATCH_DEV 2>&1
-            
-            _log "            *** clean TEST_DEV"
-            
-            _sudo mkfs -t xfs -f $MKFS_OPTIONS $TEST_DEV 2>&1 \
-                        || _fail "            !!! failed to mkfs TEST_DEV"
-            
-            _log "            *** mounting TEST_DEV"
-            
-            _sudo mount -t xfs $TEST_DEV $TEST_DIR 2>&1 \
-                        || _fail "            !!! failed to mount"
-                                    
-            new_state="run"
-            ;;
-            
-            
-        soak-run)
-            cd $QADIR
-            
-            _log "            *** run soak test"
-            _sudo ./soak $SOAK_PASSES $SOAK_STRESS $SOAK_PROC\
-                        || _fail "            !!! failed to run soak test"
-
-            new_state="done"
-            ;;
-            
-        *run)
-            cd $QADIR
-            
-            _log "            *** run tests"
-            _sudo ./check -l -g auto 2>&1 | tee $ROOT/qa.out
-            
-            _log ""
-            _log "            *** send status mail"
-            mail -s "xfs qa status report" $EMAIL < $ROOT/qa.out 2>&1
-        
-            new_state="done"
-            ;;
-            
-        *done)
-            _log "*** QA run complete"
-
-            _success
-            ;;
-            
-        *nothing)
-            new_state="done"
-            _log "    *** do nothing"
-            ;;
-            
-        *)
-            _fail "           !!! unknown state $state"
-            ;;
+                       || _fail "          !!! failed to modprobe xfs"
+
+           new_state="reset"
+           ;;
+           
+       *reset)
+           
+           _log "          *** unmounting TEST_DEV"
+           
+           _sudo umount $TEST_DEV 2>&1
+           
+           _log "          *** unmounting SCRATCH_DEV"
+           
+           _sudo umount $SCRATCH_DEV 2>&1
+           
+           _log "          *** clean TEST_DEV"
+           
+           _sudo mkfs -t xfs -f $MKFS_OPTIONS $TEST_DEV 2>&1 \
+                       || _fail "          !!! failed to mkfs TEST_DEV"
+           
+           _log "          *** mounting TEST_DEV"
+           
+           _sudo mount -t xfs $TEST_DEV $TEST_DIR 2>&1 \
+                       || _fail "          !!! failed to mount"
+                                   
+           new_state="run"
+           ;;
+           
+           
+       soak-run)
+           cd $QADIR
+           
+           _log "          *** run soak test"
+           _sudo ./soak $SOAK_PASSES $SOAK_STRESS $SOAK_PROC\
+                       || _fail "          !!! failed to run soak test"
+
+           new_state="done"
+           ;;
+           
+       *run)
+           cd $QADIR
+           
+           _log "          *** run tests"
+           _sudo ./check -l -g auto 2>&1 | tee $ROOT/qa.out
+           
+           _log ""
+           _log "          *** send status mail"
+           mail -s "XFS QA status report" $EMAIL < $ROOT/qa.out 2>&1
+       
+           new_state="done"
+           ;;
+           
+       *done)
+           _log "*** QA run complete"
+
+           _success
+           ;;
+           
+       *nothing)
+           new_state="done"
+           _log "    *** do nothing"
+           ;;
+           
+       *)
+           _fail "        !!! unknown state $state"
+           ;;
     esac
 
     _log "    *** state $state done (`date`)"