generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tools / auto-qa
index e612ff98a4ca62b05a36e30c360497938e1549fd..1beb2835916504bf08fb49910fb5ec1f03265c94 100755 (executable)
@@ -1,39 +1,13 @@
 #!/bin/sh
-#
+# SPDX-License-Identifier: GPL-2.0
 # 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
-# published by the Free Software Foundation.
-# 
-# This program is distributed in the hope that it would be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# 
-# Further, this software is distributed without any warranty that it is
-# free of the rightful claim of any third person regarding infringement
-# or the like.  Any license provided herein, whether implied or
-# otherwise, applies only to this software file.  Patent licenses, if
-# any, provided herein do not apply to combinations of this program with
-# other software, or any other product whatsoever.
-# 
-# You should have received a copy of the GNU General Public License along
-# with this program; if not, write the Free Software Foundation, Inc., 59
-# Temple Place - Suite 330, Boston MA 02111-1307, USA.
-# 
-# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
-# Mountain View, CA  94043, or:
-# 
-# http://www.sgi.com 
-# 
-# For further information regarding this notice, see: 
-# 
-# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
 #
-
 # automatic qa system. 31/08/00 dxm@sgi.com
-
-# configuration (you could tune this)
+#
+# Usage: auto_qa start-state [stop-state]
+# Do auto_qa from start-state up to stop-state inclusive
+# or if no stop-state given then do it until reach "done" state.
+#
 
 _log()
 {
@@ -66,10 +40,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=]+" }
@@ -80,7 +53,7 @@ _get_kernel_version()
        END { 
            print "VERSION=" a "." b "." c d " ; SVERSION=" a "." b "." c
        }
-   ' < $WORKAREA/linux/Makefile`
+   ' < $KWORKAREA/Makefile`
 }
 
 # this should be constant
@@ -88,18 +61,18 @@ _get_kernel_version()
 ROOT="$HOME/qa"
 HOST=`hostname -s`
 if [ ! -z "$CVSROOT" ]; then
-    export WORKAREA="$ROOT/linux-2.4-xfs"
+    export WORKAREA="$ROOT/xfs-cmds"
 else
-    [ -z "$WORKAREA" ] && export WORKAREA="$ROOT/linux-xfs"
+    [ -z "$WORKAREA" ] && export WORKAREA="$ROOT/xfs-cmds"
 fi
 
 
 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="$QADIR/common/config"
 SH="/bin/sh"
 LOG="$ROOT/qa.log"
 
@@ -140,6 +113,8 @@ _set_state()
 _change_state()
 {
     new=$1
+
+    # if have state XXXX-state then preserve XXXX-newstate
     
     case $state
     in
@@ -170,38 +145,21 @@ _restart()
     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 \
+       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 \
-                       || _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
 }
@@ -229,20 +187,21 @@ _test_mount()
         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
+    _sudo mount -t xfs $TEST_OPTIONS $MOUNT_OPTIONS $* $TEST_DEV $TEST_DIR
 }
 
 _i386_install()
 {
-    _sudo cp -f $WORKAREA/linux/arch/i386/boot/bzImage $IMAGE 2>&1 \
+    _sudo cp -f "$KWORKAREA/arch/i386/boot/bzImage" "$IMAGE" 2>&1 \
                || _fail "          !!! install kernel failed"
-    _sudo cp -f $WORKAREA/linux/System.map $SYSTEMMAP 2>&1 \
+    _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 \
@@ -268,8 +227,14 @@ _ia64_restart()
     echo not yet implemented
 }
 
+_check_kernel()
+{
+    [ -d "$KWORKAREA" ]        || _fail "    !!! QA kernel workarea \"$KWORKAREA\" not found"
+    [ -r "$CONFIG" ]   || _fail "    !!! Can't read config file $CONFIG"
+}
+
 
-_log "*** linux-xfs QA (`date`)"
+_log "*** XFS QA (`date`)"
 
 _get_state
 
@@ -296,15 +261,13 @@ in
        ;;
 esac
 
-if [ "$1" != "" ]
-then
-    _set_state $1
-fi
+[ -n "$1" ] && _set_state $1
+[ -n "$2" ] && stop_state=$2
 
 [ "$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"
+cd $QADIR
 . "$COMMON_CONFIG"     || _fail "    !!! Couldn't source $COMMON_CONFIG"
 
 _get_kernel_version
@@ -325,6 +288,8 @@ do
     _log "     (user=$USER, host=$HOST)"
     new_state=""
 
+    start_state=$state
+
     case $state
     in
        *init)
@@ -333,30 +298,20 @@ do
            _log "******************************************************"
            _log "QA init $VERSION (`date`)"
            _log "******************************************************"
-           _log "--- kernel ($IMAGE)"
-           [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
-               _log "--- modules ($MODULES)"
-
-           _change_state "inited"
-           _update_autoqa_file
-           ;;
-           
-       *inited)
-           _log "      *** QA initialized"
-           new_state="update"
+           new_state="updatetools"
            ;;
        
-       *update)
-           _update_workarea
+       *updatetools)
+           _update_workarea "$WORKAREA"
            new_state="cleantools"
            ;;
 
        *cleantools)
            # we need to configure or else we might fail to clean
-           for pkg in attr acl xfsprogs dmapi xfsdump xfstests
+           for pkg in attr acl xfsprogs xfsdump xfstests
            do
-               [ -d $WORKAREA/cmd/$pkg ] || continue
-               cd $WORKAREA/cmd/$pkg
+               [ -d $WORKAREA/$pkg ] || continue
+               cd $WORKAREA/$pkg
                _log "  *** clean $pkg tools"
                make realclean 2>&1 \
                        || _fail "          !!! clean $pkg failed"
@@ -366,12 +321,11 @@ do
 
        *buildtools)
            _log "      *** build and install tools"
-           for pkg in attr acl xfsprogs dmapi xfsdump xfstests 
+           for pkg in attr acl xfsprogs xfsdump xfstests 
            do
-               [ -d $WORKAREA/cmd/$pkg ] || continue
-               cd $WORKAREA/cmd/$pkg
+               [ -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 \
@@ -386,17 +340,24 @@ do
                        || _fail "          !!! install $pkg failed"
            done
 
+           new_state="updatekernel"
+           ;;
+
+       *updatekernel)
+           _check_kernel
+           _update_workarea "$KWORKAREA"
            new_state="cleankernel"
            ;;
 
        *cleankernel)
-           _log "      *** clean linux"
-           cd $WORKAREA/linux
+           _check_kernel
+           _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"
@@ -407,13 +368,13 @@ do
            ;;
            
        *reconfig)
-       
+           _check_kernel
            _log "      *** reconfig kernel"
            
            # 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 \
@@ -425,11 +386,15 @@ do
            ;;
            
        *buildkernel)
+           _check_kernel
            _log "      *** build kernel"
+           _log "          --- kernel ($IMAGE)"
+           [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
+            _log "          --- modules ($MODULES)"
            
-           _change_state "clean" ; # we better start from scratch if this fails
+           _change_state "cleankernel" ; # we better start from scratch if this fails
            
-           cd $WORKAREA/linux
+           cd "$KWORKAREA"
            [ -z "$KTARGET" ] && KTARGET=bzImage
            [ -z "$KMODULES" -o "$KMODULES" = yes ] && \
                KTARGET="$KTARGET modules"
@@ -439,22 +404,19 @@ do
            ;;
 
        *install)
+           _check_kernel
            _log "      *** blat old modules"
            _sudo rm -rf $MODULES
            
            _log "      *** install kernel"
-           cd $WORKAREA/linux
+           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
+           new_state="restart"
            ;;
            
        *restart)
@@ -482,12 +444,6 @@ do
        *check)
            uname=`uname -a`
            _log "          *** uname $uname"
-           _log "          *** kernel"
-           [ -n "/boot/*$EXTRA*" ] && \
-               ls -l /boot/*$EXTRA*  2>&1
-           _log "          *** kernel modules"
-           [ -d /lib/modules/$SVERSION-$EXTRA/kernel/fs/xfs ] && \
-               ls -l /lib/modules/$SVERSION-$EXTRA/kernel/fs/xfs/*
 
            if [ "$MODULAR" -eq 0 ]; then
                new_state="reset"
@@ -576,7 +532,7 @@ do
            ;;
            
        *done)
-           _log "*** QA run complete"
+           _log "*** requested QA state transitions complete"
 
            _success
            ;;
@@ -593,6 +549,20 @@ do
 
     _log "    *** state $state done (`date`)"
     [ "$new_state" = "" ] && _fail "    !!! no new state set"
+
+    if [ -n "$stop_state" ]
+    then
+        # remove hyphen prefixes
+       s1=`echo $start_state | sed 's/.*-//'`
+       s2=`echo $stop_state | sed 's/.*-//'`
+
+       if [ $s1 = $s2 ]
+       then
+           # we have been requested to stop here and not go on
+           new_state="done"
+       fi
+    fi
+
     _change_state $new_state
     
 done