cosmetic change to the status email subject line.
[xfstests-dev.git] / tools / auto-qa
index 861c721b78465632643e05e17c409c28014038b9..b51b58145529bae0acdc4b4a021c47fd88d5a6d7 100755 (executable)
 
 # automatic qa system. 31/08/00 dxm@sgi.com
 
+# configuration (you could tune this)
+
+EXTRA="-xfs-qa"
+BOOT="/boot"
+SOAK_PASSES="-1"
+SOAK_STRESS="10000"
+SOAK_PROC="3"
+export MKFS_OPTIONS=${MKFS_OPTIONS:=-bsize=4096}
+export MOUNT_OPTIONS=${MOUNT_OPTIONS:=-ologbufs=2}
+
 _log()
 {
     echo "$*" >&2
@@ -53,7 +63,7 @@ _fail()
     case $state
     in
         cron*)
-            mail -s "xfs qa status report" $ADMINEMAIL \
+            mail -s "XFS QA status report" $ADMINEMAIL \
                 < $LOG 2>&1
        ;;
     esac
@@ -62,32 +72,43 @@ _fail()
     exit 1
 }
 
-# configuration (you could tune this)
-
-EXTRA="-xfs-qa"
-VERSION="2.4.0"
-BOOT="/boot"
-SOAK_PASSES="-1"
-SOAK_STRESS="10000"
-SOAK_PROC="3"
+_get_kernel_version()
+{
+    [ -x "$WORKAREA" ] \
+        || _fail "can't access workarea $WORKAREA"
+    [ -r "$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 }
+       END { 
+           print "VERSION=" a "." b "." c d " ; SVERSION=" a "." b "." c
+        }
+   ' < $WORKAREA/linux/Makefile`
+}
 
 # this should be constant
 
 ROOT="$HOME/qa"
 HOST=`hostname -s`
-export WORKAREA="$ROOT/linux-xfs"
+if [ ! -z "$CVSROOT" ]; then
+    WORKAREA="$ROOT/linux-2.4-xfs"
+else
+    [ -z "$WORKAREA" ] && WORKAREA="$ROOT/linux-xfs"
+fi
+export WORKAREA
+
 
 export PATH="/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin/ptools:/usr/local/bin"
 STATE=$ROOT/qa.state
-QADIR="$WORKAREA/cmd/xfs/stress"
+QADIR="$WORKAREA/cmd/xfstests"
 SUDO="su -c"
-IMAGE="$BOOT/vmlinuz-$VERSION$EXTRA"
-SYSTEMMAP="$BOOT/System.map-$VERSION$EXTRA"
-CONFIG="$ROOT/$HOST-$VERSION$EXTRA.config"
-MODULES="/lib/modules/$VERSION$EXTRA"
-SELF="$ROOT/auto-qa"
-SELF_UPDATE="cmd/xfs/tools/auto-qa"
-COMMON_CONFIG="$WORKAREA/cmd/xfs/stress/common.config"
+CONFIG="$ROOT/$HOST.config"
+COMMON_CONFIG="$WORKAREA/cmd/xfstests/common.config"
 SH="/bin/sh"
 LOG="$ROOT/qa.log"
 
@@ -95,22 +116,22 @@ LOG="$ROOT/qa.log"
 
 case $HOST
 in
-    fuzzy)
-        EMAIL="dxm@larry"
-        ADMINEMAIL="dxm@larry"
-        MODULAR=1
-        ;;
     bruce)
-        EMAIL="dxm@larry"
-        ADMINEMAIL="dxm@larry"
-        MODULAR=1
+        EMAIL="nathans@larry"
+        ADMINEMAIL="nathans@larry"
+        MODULAR=0
         ;;
     sagan)
-        EMAIL="dxm@larry"
-        ADMINEMAIL="dxm@larry"
-        MODULAR=0
+        EMAIL="tes@larry"
+        ADMINEMAIL="tes@larry"
+        MODULAR=1
         ;;
     troppo)
+       EMAIL="kaos@larry"
+       ADMINEMAIL="kaos@larry"
+       MODULAR=0
+       ;;
+    frodo)
        EMAIL="nathans@larry"
        ADMINEMAIL="nathans@larry"
        MODULAR=0
@@ -184,8 +205,45 @@ _sudo()
 
 _restart()
 {
-    exec $ROOT/su -c "shutdown -r 2 \"auto-qa rebooting\" &" < /dev/null
+    exec $ROOT/su -c "(shutdown -r now \"auto-qa rebooting\" )&" < /dev/null
+}
+
+_update_autoqa_file()
+{
+    SELF="$ROOT/auto-qa"
+    SELF_UPDATE="cmd/xfstests/tools/auto-qa"
+    if [ -z "$CVSROOT" ]; then
+           cmd="p_tupdate $SELF_UPDATE"
+    else
+           cmd="cvs -z3 update $SELF_UPDATE"
+    fi
+    exec $SH -c "cd $WORKAREA ; $cmd; chmod +x $SELF_UPDATE ; exec $SELF"
+}
+
+_update_workarea()
+{
+    if [ -z "$CVSROOT" ]; then
+       _log "        *** p_tupdate"
+       cd $WORKAREA 
+       p_tupdate 2>&1 \
+                       || _fail "            !!! p_tupdate failed"
+
+       _log "        *** p_check/p_purge"
+       cd $WORKAREA 
+       p_check -s | p_purge -yiu 2>&1 \
+                       || _fail "            !!! p_check/p_purge failed"
+
+       _log "        *** non-trunk files"
+       cd $WORKAREA 
+       p_list -c 2>&1 \
+                       || _fail "            !!! p_list failed"
+    else
+       _log "        *** cvs update"
+       cd $WORKAREA
+       cvs -z3 update -d
+    fi
 }
+            
 
 _log "*** linux-xfs QA (`date`)"
 
@@ -207,7 +265,7 @@ in
     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" ]
+        if [ "$state" != "cron-restarted" ]
         then
             _fail "    !!! cron-restarted while not in \"cron-restarted\" state"
         fi
@@ -219,11 +277,16 @@ then
     _set_state $1
 fi
 
-[ $UID -eq 0 ]          && _fail "    !!! QA most be run as a normal user"
-[ -d $ROOT ]            || _fail "    !!! QA root \"$ROOT\" not found"
-[ -d $WORKAREA ]        || _fail "    !!! QA workarea \"$WORKAREA\" not found"
-[ -r $CONFIG ]          || _fail "    !!! Can't read config file $CONFIG"
-. $COMMON_CONFIG       || _fail "    !!! Couldn't source $COMMON_CONFIG"
+[ "$UID" -eq 0 ]       && _fail "    !!! QA most be run as a normal user"
+[ -d "$ROOT" ]         || _fail "    !!! QA root \"$ROOT\" not found"
+[ -d "$WORKAREA" ]     || _fail "    !!! QA workarea \"$WORKAREA\" not found"
+[ -r "$CONFIG" ]       || _fail "    !!! Can't read config file $CONFIG"
+. "$COMMON_CONFIG"     || _fail "    !!! Couldn't source $COMMON_CONFIG"
+
+_get_kernel_version
+IMAGE="$BOOT/vmlinuz$EXTRA"
+SYSTEMMAP="$BOOT/System.map-$VERSION$EXTRA"
+MODULES="/lib/modules/$SVERSION"
 
 cd $ROOT
 
@@ -243,12 +306,14 @@ do
         *init)
             echo "" > $ROOT/qa.log
             echo "" > $ROOT/qa.full
-            _log "******************************************"
-            _log "QA init (`date`)"
-            _log "******************************************"
+            _log "******************************************************"
+            _log "QA init $VERSION (`date`)"
+            _log "******************************************************"
+           _log "--- kernel ($IMAGE)"
+           _log "--- modules ($MODULES)"
 
             _change_state "inited"
-            exec $SH -c "cd $WORKAREA ; p_tupdate $SELF_UPDATE ; chmod +x $SELF_UPDATE ; exec $SELF"
+            _update_autoqa_file
             ;;
             
         *inited)
@@ -257,63 +322,32 @@ do
             ;;
         
         *update)
-            _log "        *** p_tupdate"
-            cd $WORKAREA 
-            p_tupdate 2>&1 \
-                                    || _fail "            !!! p_tupdate failed"
-
-            _log "        *** p_check/p_purge"
-            cd $WORKAREA 
-            p_check -s | p_purge -yiu 2>&1 \
-                                    || _fail "            !!! p_check/p_purge failed"
-
-            _log "        *** non-trunk files"
-            cd $WORKAREA 
-            p_list -c 2>&1 \
-                                    || _fail "            !!! p_list failed"
-
+            _update_workarea
             new_state="clean"
             ;;
-            
+
         *clean)
-            # we need to configure or else we might fail to clean stress/src
-            _log "        *** configure for clean"
-            cd $WORKAREA/cmd/xfs
-            make configure 2>&1 \
-                                    || _fail "            !!! configure for clean failed"
-                                    
-            _log "        *** clean stress/src"
-            cd $WORKAREA/cmd/xfs/stress/src
-            make clobber 2>&1 \
-                                    || _fail "            !!! clean stress/src failed"
-
-            _log "        *** clean xfs tools"
-            cd $WORKAREA/cmd/xfs
-            make realclean 2>&1 \
-                                    || _fail "            !!! clean tools failed"
-
-            _log "        *** clean quota tools"
-            cd $WORKAREA/cmd/quota
-            ( rm -f configure ; autoconf ; sh configure ; make clean ) 2>&1 \
-                                    || _fail "            !!! clean quota failed"
-
-            _log "        *** clean qa"
-            cd $WORKAREA/cmd/xfs/stress
-            rm -f *.full *.bad *.log *.time *.core core 2>&1 \
-                                    || _fail "            !!! clean qa failed"
+            # 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"
+                        || _fail "            !!! clean linux failed"
 
             _log "        *** install configuration file"
             cp -f $CONFIG $WORKAREA/linux/.config 2>&1 \
-                                    || _fail "            !!! failed to install config"
+                        || _fail "            !!! failed to install config"
             
             _log "        *** remove version file"
             rm -f include/linux/version.h 2>&1 \
-                                    || _fail "            !!! failed to clean version"
+                        || _fail "            !!! failed to clean version"
 
             new_state="reconfig"
             ;;
@@ -322,57 +356,55 @@ do
         
             _log "        *** reconfig kernel"
             
-            _change_state "clean" ;# if this fails, we'd better start from scratch
+            _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"
+                        || _fail "            !!! reconfig oldconfig failed"
             make EXTRAVERSION=$EXTRA dep 2>&1 \
-                                    || _fail "            !!! reconfig dep failed"
+                        || _fail "            !!! reconfig dep failed"
 
-            new_state="build"
+            new_state="buildtools"
             ;;
             
-        *build)
+        *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"
+
+               # 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" ;# if this fails, we'd better start from scratch
+            _change_state "clean" ; # we better start from scratch if this fails
             
             cd $WORKAREA/linux
-            make -j2 EXTRAVERSION=$EXTRA bzImage 2>&1 \
-                                    || _fail "            !!! build bzImage failed"
-            make -j2 EXTRAVERSION=$EXTRA modules 2>&1 \
-                                    || _fail "            !!! build modules failed"
-                                    
-            _log "        *** build tools"
-            cd $WORKAREA/cmd/xfs
-            
-            # use e-fence - but this will only take effect on configure
-            export MALLOCLIB=/usr/lib/libefence.a
-            make configure 2>&1 \
-                                    || _fail "            !!! configure tools failed"
-            make default 2>&1 \
-                                    || _fail "            !!! build tools failed"
-
-            _log "        *** build quota tools"
-            cd $WORKAREA/cmd/quota
-            
-            # use e-fence - but this will only take effect on configure
-            export MALLOCLIB=/usr/lib/libefence.a
-            ( rm -f configure ; autoconf ; sh configure ; make all ) 2>&1 \
-                                    || _fail "            !!! build quota failed"
-
-            _log "        *** build stress/src"
-            cd $WORKAREA/cmd/xfs/stress/src
-            
-            make default 2>&1 \
-                                    || _fail "            !!! build stress/src failed"
-
+            make -j4 EXTRAVERSION=$EXTRA bzImage modules 2>&1 \
+                        || _fail "            !!! build bzImage/modules failed"
             new_state="install"
             ;;
-            
+
         *install)
             _log "        *** blat old modules"
             
@@ -381,32 +413,22 @@ do
             _log "        *** install kernel"
             cd $WORKAREA/linux
             _sudo cp -f $WORKAREA/linux/arch/i386/boot/bzImage $IMAGE 2>&1 \
-                                    || _fail "            !!! install kernel failed"
+                        || _fail "            !!! install kernel failed"
             _sudo cp -f $WORKAREA/linux/System.map $SYSTEMMAP 2>&1 \
-                                    || _fail "            !!! install kernel failed"
+                        || _fail "            !!! install kernel failed"
             _sudo make EXTRAVERSION=$EXTRA modules_install 2>&1 \
-                                    || _fail "            !!! install modules failed"
-
-            _log "        *** install xfs tools"
-            cd $WORKAREA/cmd/xfs
-            _sudo make install 2>&1 \
-                                    || _fail "            !!! install tools failed"
-
-            _log "        *** install quota tools"
-            cd $WORKAREA/cmd/quota
-            _sudo make install 2>&1 \
-                                    || _fail "            !!! install quota failed"
+                        || _fail "            !!! install modules failed"
 
             _log "        *** reinit lilo"
             _sudo /sbin/lilo 2>&1 \
-                                    || _fail "            !!! reinit lilo failed"
+                        || _fail "            !!! reinit lilo failed"
             new_state="restart"
             ;;
             
         *restart)
             _log "            *** select qa kernel"
             _sudo /sbin/lilo -R linux-xfs-qa 2>&1 \
-                                    || _fail "            !!! lilo failed"
+                        || _fail "            !!! lilo failed"
             
             _log "            *** prepare to restart"
             _change_state "restarted"
@@ -430,11 +452,10 @@ do
             _log "            *** kernel"
             ls -l /boot/*$EXTRA*  2>&1
             _log "            *** kernel modules"
-            ls -l /lib/modules/$VERSION$EXTRA/kernel/fs/pagebuf/* \
-                  /lib/modules/$VERSION$EXTRA/kernel/fs/xfs/*     \
-                  /lib/modules/$VERSION$EXTRA/kernel/fs/xfs/support/* 
+            ls -l /lib/modules/$SVERSION$EXTRA/kernel/fs/xfs/* \
+                  /lib/modules/$SVERSION$EXTRA/kernel/fs/xfs_support/* 
             
-            if [ $MODULAR -eq 0 ]
+            if [ "$MODULAR" -eq 0 ]
             then
                 new_state="reset"
             else
@@ -446,7 +467,7 @@ do
             _log "            *** modules dependencies"
             
             _sudo depmod -a  2>&1 \
-                                    || _fail "            !!! failed to depmod -a" 
+                        || _fail "            !!! failed to depmod -a" 
             
             _log "            *** unmounting XFS mounts"
             
@@ -454,7 +475,7 @@ do
             
             _log "            *** removing modules"
             
-            for m in xfsidbg xfs pagebuf kdbm_pg kdbm_vm
+            for m in xfsidbg xfs kdbm_pg kdbm_vm
             do
                 _sudo rmmod $m 2> /dev/null
             done
@@ -462,7 +483,7 @@ do
             _log "            *** installing modules"
 
            _sudo modprobe xfs 2>&1 \
-                                    || _fail "            !!! failed to modprobe xfs"
+                        || _fail "            !!! failed to modprobe xfs"
 
             new_state="reset"
             ;;
@@ -479,13 +500,13 @@ do
             
             _log "            *** clean TEST_DEV"
             
-            _sudo mkfs -t xfs -f $TEST_DEV 2>&1 \
-                                    || _fail "            !!! failed to mkfs 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"
+                        || _fail "            !!! failed to mount"
                                     
             new_state="run"
             ;;
@@ -496,7 +517,7 @@ do
             
             _log "            *** run soak test"
             _sudo ./soak $SOAK_PASSES $SOAK_STRESS $SOAK_PROC\
-                                    || _fail "            !!! failed to run soak test"
+                        || _fail "            !!! failed to run soak test"
 
             new_state="done"
             ;;
@@ -509,7 +530,7 @@ do
             
             _log ""
             _log "            *** send status mail"
-            mail -s "xfs qa status report" $EMAIL < $ROOT/qa.out 2>&1
+            mail -s "XFS QA status report" $EMAIL < $ROOT/qa.out 2>&1
         
             new_state="done"
             ;;