Minor xfstests tweaks - report kernel version in check as in bench.
[xfstests-dev.git] / tools / auto-qa
index aec89afbb5dbe844b77a221a149bf45ffae9d679..f13dd8ec0328d0daa1b87fcb1dce72b0ae60d5e6 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
+# Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
 # 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of version 2 of the GNU General Public License as
@@ -56,8 +56,7 @@ _fail()
     case $state
     in
        cron*)
-           mail -s "XFS QA status report" $EMAIL \
-               < $LOG 2>&1
+           mail -s "XFS QA status report" $EMAIL < $LOG 2>&1
        ;;
     esac
 
@@ -67,10 +66,9 @@ _fail()
 
 _get_kernel_version()
 {
-    [ -x "$WORKAREA" ] \
-       || _fail "can't access workarea $WORKAREA"
-    [ -r "$WORKAREA/linux/Makefile" ] \
-       || _fail "can't read makefile $WORKAREA/linux/Makefile"
+    [ -x "$KWORKAREA" ] || return
+    [ -r "$KWORKAREA/Makefile" ] \
+       || _fail "can't read kernel makefile $KWORKAREA/Makefile"
 
     eval `awk '
        BEGIN { FS = "[ \t=]+" }
@@ -81,7 +79,7 @@ _get_kernel_version()
        END { 
            print "VERSION=" a "." b "." c d " ; SVERSION=" a "." b "." c
        }
-   ' < $WORKAREA/linux/Makefile`
+   ' < $KWORKAREA/Makefile`
 }
 
 # this should be constant
@@ -89,19 +87,18 @@ _get_kernel_version()
 ROOT="$HOME/qa"
 HOST=`hostname -s`
 if [ ! -z "$CVSROOT" ]; then
-    WORKAREA="$ROOT/linux-2.4-xfs"
+    export WORKAREA="$ROOT/xfs-cmds"
 else
-    [ -z "$WORKAREA" ] && WORKAREA="$ROOT/linux-xfs"
+    [ -z "$WORKAREA" ] && export WORKAREA="$ROOT/xfs-cmds"
 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/xfstests"
+QADIR="$WORKAREA/xfstests"
 SUDO="su -c"
 CONFIG="$ROOT/$HOST.config"
-COMMON_CONFIG="$WORKAREA/cmd/xfstests/common.config"
+COMMON_CONFIG="$WORKAREA/xfstests/common.config"
 SH="/bin/sh"
 LOG="$ROOT/qa.log"
 
@@ -175,7 +172,7 @@ _restart()
 _update_autoqa_file()
 {
     SELF="$ROOT/auto-qa"
-    SELF_UPDATE="cmd/xfstests/tools/auto-qa"
+    SELF_UPDATE="xfstests/tools/auto-qa"
     if [ -z "$CVSROOT" ]; then
            cmd="p_tupdate $SELF_UPDATE"
     else
@@ -188,28 +185,90 @@ _update_workarea()
 {
     if [ -z "$CVSROOT" ]; then
        _log "  *** p_tupdate"
-       cd $WORKAREA 
-       p_tupdate 2>&1 \
+       cd "$1"
+       WORKAREA="$1" p_tupdate 2>&1 \
                        || _fail "          !!! p_tupdate failed"
 
        _log "  *** p_check/p_purge"
-       cd $WORKAREA 
-       p_check -s | p_purge -yiu 2>&1 \
+       cd "$1"
+       WORKAREA="$1" 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 \
+       cd "$1"
+       WORKAREA="$1" p_list -c 2>&1 \
                        || _fail "          !!! p_list failed"
     else
        _log "  *** cvs update"
-       cd $WORKAREA
+       cd "$1"
        cvs -z3 update -d
     fi
 }
-           
 
-_log "*** linux-xfs QA (`date`)"
+_test_mkfs_xfs()
+{
+    TEST_OPTIONS=""
+    [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
+        TEST_OPTIONS="$TEST_OPTIONS -rrtdev=$TEST_RTDEV"
+    [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+        TEST_OPTIONS="$TEST_OPTIONS -llogdev=$TEST_LOGDEV"
+    _sudo /sbin/mkfs.xfs -f $TEST_OPTIONS $MKFS_OPTIONS $* $TEST_DEV
+    mkfs_status=$?
+    if [ "$USE_BIG_LOOPFS" = yes ]; then
+        [ -z "$RETAIN_AG_BYTES" ] && RETAIN_AG_BYTES=0
+        _sudo $QADIR/tools/ag-wipe -q -r $RETAIN_AG_BYTES $TEST_DEV
+    fi
+    return $mkfs_status
+}
+
+_test_mount()
+{
+    TEST_OPTIONS=""
+    [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_RTDEV" ] && \
+        TEST_OPTIONS="$TEST_OPTIONS -ortdev=$TEST_RTDEV"
+    [ "$USE_EXTERNAL" = yes -a ! -z "$TEST_LOGDEV" ] && \
+        TEST_OPTIONS="$TEST_OPTIONS -ologdev=$TEST_LOGDEV"
+    _sudo mount -t xfs $TEST_OPTIONS $* $TEST_DEV $TEST_DIR
+}
+
+_i386_install()
+{
+    _sudo cp -f "$KWORKAREA/arch/i386/boot/bzImage" "$IMAGE" 2>&1 \
+               || _fail "          !!! install kernel failed"
+    _sudo cp -f "$KWORKAREA/System.map" "$SYSTEMMAP" 2>&1 \
+               || _fail "          !!! install kernel failed"
+    if [ -z "$KMODULES" -o "$KMODULES" = yes ]; then
+       _sudo make EXTRAVERSION=-$EXTRA modules_install 2>&1 \
+               || _fail "          !!! install modules failed"
+    fi
+
+    if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
+       _log "  *** reinit lilo"
+       _sudo /sbin/lilo 2>&1 \
+               || _fail "          !!! reinit lilo failed"
+    fi
+}
+
+_i386_restart()
+{
+    if [ -z "$KINSTALL" -o "$KINSTALL" = lilo ]; then
+       _sudo /sbin/lilo -R $EXTRA $KERNEL_OPTIONS 2>&1 \
+               || _fail "          !!! lilo failed"
+    fi
+}
+
+_ia64_install()
+{
+    echo not yet implemented
+}
+
+_ia64_restart()
+{
+    echo not yet implemented
+}
+
+
+_log "*** XFS QA (`date`)"
 
 _get_state
 
@@ -248,8 +307,8 @@ fi
 . "$COMMON_CONFIG"     || _fail "    !!! Couldn't source $COMMON_CONFIG"
 
 _get_kernel_version
-IMAGE="$BOOT/vmlinuz$EXTRA"
-SYSTEMMAP="$BOOT/System.map-$VERSION$EXTRA"
+IMAGE="$BOOT/vmlinuz-$EXTRA"
+SYSTEMMAP="$BOOT/System.map-$VERSION-$EXTRA"
 MODULES="/lib/modules/$SVERSION"
 
 cd $ROOT
@@ -274,7 +333,8 @@ do
            _log "QA init $VERSION (`date`)"
            _log "******************************************************"
            _log "--- kernel ($IMAGE)"
-           _log "--- modules ($MODULES)"
+           [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
+               _log "--- modules ($MODULES)"
 
            _change_state "inited"
            _update_autoqa_file
@@ -286,27 +346,57 @@ do
            ;;
        
        *update)
-           _update_workarea
-           new_state="clean"
+           _update_workarea "$KWORKAREA"
+           _update_workarea "$WORKAREA"
+           new_state="cleantools"
            ;;
 
-       *clean)
+       *cleantools)
            # 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
+               [ -d $WORKAREA/$pkg ] || continue
+               cd $WORKAREA/$pkg
                _log "  *** clean $pkg tools"
                make realclean 2>&1 \
                        || _fail "          !!! clean $pkg failed"
            done
+           new_state="buildtools"
+           ;;
+
+       *buildtools)
+           _log "      *** build and install tools"
+           for pkg in attr acl xfsprogs dmapi xfsdump xfstests 
+           do
+               [ -d $WORKAREA/$pkg ] || continue
+               cd $WORKAREA/$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
 
-           _log "      *** clean linux"
-           cd $WORKAREA/linux
+           new_state="cleankernel"
+           ;;
+
+       *cleankernel)
+           _log "      *** clean kernel"
+           cd "$KWORKAREA"
            make mrproper 2>&1 \
-                       || _fail "          !!! clean linux failed"
+                       || _fail "          !!! clean kernel failed"
 
            _log "      *** install configuration file"
-           cp -f $CONFIG $WORKAREA/linux/.config 2>&1 \
+           cp -f $CONFIG "$KWORKAREA/.config" 2>&1 \
                        || _fail "          !!! failed to install config"
            
            _log "      *** remove version file"
@@ -320,79 +410,61 @@ do
        
            _log "      *** reconfig kernel"
            
-           _change_state "clean" ; # we better start from scratch if this fails
+           # we better start from scratch if this fails
+           _change_state "cleankernel"
            
-           cd $WORKAREA/linux
+           cd "$KWORKAREA"
            # 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 \
+               make EXTRAVERSION=-$EXTRA oldconfig 2>&1 \
                        || _fail "          !!! reconfig oldconfig failed"
-           make EXTRAVERSION=$EXTRA dep 2>&1 \
+           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
-               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"
+           cd "$KWORKAREA"
+           [ -z "$KTARGET" ] && KTARGET=bzImage
+           [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
+               KTARGET="$KTARGET modules"
+           make -j4 EXTRAVERSION=-$EXTRA $KTARGET 2>&1 \
+                       || _fail "          !!! build $KTARGET 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"
+           cd "$KWORKAREA"
+           case `uname -m`
+           in
+               i386|i686)      _i386_install ;;
+               ia64)           _ia64_install ;;
+           esac
+
+           if [ -z "$KRESTART" -o "$KRESTART" = yes ]; then
+               new_state="restart"
+           else
+               new_state="done"
+           fi
            ;;
            
        *restart)
            _log "          *** select qa kernel"
-           _sudo /sbin/lilo -R linux-xfs-qa $KERNEL_OPTIONS 2>&1 \
-                       || _fail "          !!! lilo failed"
-           
+           case `uname -m`
+           in
+               i386|i686)      _i386_restart ;;
+               ia64)           _ia64_restart ;;
+           esac
+
            _log "          *** prepare to restart"
            _change_state "restarted"
            
@@ -408,17 +480,10 @@ do
            ;;
          
        *check)
-           uname=`uname -ar`
+           uname=`uname -a`
            _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
+
+           if [ "$MODULAR" -eq 0 ]; then
                new_state="reset"
            else
                new_state="probe"
@@ -427,23 +492,19 @@ do
            
        *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"
 
@@ -453,21 +514,17 @@ do
        *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 \
+           _test_mkfs_xfs 2>&1 \
                        || _fail "          !!! failed to mkfs TEST_DEV"
            
            _log "          *** mounting TEST_DEV"
-           
-           _sudo mount -t xfs $TEST_DEV $TEST_DIR 2>&1 \
+           _test_mount 2>&1 \
                        || _fail "          !!! failed to mount"
                                    
            new_state="run"
@@ -486,8 +543,10 @@ do
        bench-run)
            cd $QADIR
            
+           # $BENCHMARK is typically unset, which equates to "all"
+           #
            _log "          *** run benchmarks"
-           _sudo ./bench $BENCH_PASSES `id -nu && id -ng` \
+           _sudo ./bench $BENCH_PASSES `id -nu && id -ng` $BENCHMARK \
                        || _fail "          !!! failed to run benchmarks"
 
            _log ""
@@ -500,8 +559,8 @@ do
        *run)
            cd $QADIR
            
-           _log "          *** run tests"
-           _sudo ./check -l -g auto 2>&1 | tee $ROOT/qa.out
+           _log "          *** run tests ($CHECK_OPTIONS)"
+           _sudo ./check -l $CHECK_OPTIONS 2>&1 | tee $ROOT/qa.out
            
            _log ""
            _log "          *** send status mail"