Whamcloud - gitweb
Minor change - rename "run" to "test_fail" to match runfailure-mds.
[fs/lustre-release.git] / lustre / tests / common.sh
index 51604eb..d0f835c 100644 (file)
@@ -1,7 +1,7 @@
 export PATH=$PATH:/sbin:/usr/sbin
 
 if [ -d /r ]; then
-  R=/r
+       R=/r
 fi
 
 PTLCTL=$SRCDIR/../../portals/linux/utils/ptlctl
@@ -11,14 +11,13 @@ ACCEPTOR=$SRCDIR/../../portals/linux/utils/acceptor
 
 LOOPNUM=0; export LOOPNUM
 if [ -b /dev/loop0 ]; then
-  LOOP=/dev/loop
+       LOOP=/dev/loop
 else
-  if [ -b /dev/loop/0 ]; then
-    LOOP=/dev/loop/
-  else
-    echo "Cannot find /dev/loop0 or /dev/loop/0";
-    exit -1
-  fi
+       if [ -b /dev/loop/0 ]; then
+               LOOP=/dev/loop/
+       else
+               echo "Cannot find /dev/loop0 or /dev/loop/0" 1>&2 && exit -1
+       fi
 fi
 
 # Return the next unused loop device on stdout and in the $LOOPDEV
@@ -45,14 +44,23 @@ new_fs () {
        MKFS="mkfs.$1"
        MKFSOPT="-b 4096"
 
-       [ $# -ne 3 ] && echo "usage: $0 <fstype> <file> <size>" 1>&2 && exit -1
-
        [ "$1" = "ext3" ] && MKFS="mkfs.ext2 -j"
 
        if [ -b "$2" ]; then
-               $MKFS $MKFSOPT $2 || exit -1
+               [ $# -lt 2 -o $# -gt 3 ] && \
+                       echo "usage: $0 <fstype> <file> [size]" 1>&2 && exit -1
+
+               PM="/proc/mounts"
+               [ -f "$PM" ] || PM="/etc/mtab"
+
+               grep "$2 " $PM 1>&2 && echo "$0: $2 is in $PM!" 1>&2 && exit -1
+
+               $MKFS $MKFSOPT $2 $3 || exit -1
                LOOPDEV=$2      # Not really a loop device
        else
+               [ $# -ne 3 ] && \
+                       echo "usage: $0 <fstype> <file> <size>" 1>&2 && exit -1
+
                if [ -f "$EFILE" ]; then
                        echo "using existing filesystem $EFILE for $2"
                        zcat "$EFILE" > $2 || exit -1
@@ -83,56 +91,34 @@ old_fs () {
 
 list_mods() {
        $DEBCTL modules > $R/tmp/ogdb
-       echo "The GDB module script is in /tmp/ogdb.  Press enter to continue"
-       read
-}
-
-setup() {
-    [ -c /dev/portals ] || mknod /dev/portals c 10 240
-
-    insmod $SRCDIR/../../portals/linux/oslib/portals.o || exit -1
-    insmod $SRCDIR/../../portals/linux/qswnal/kqswnal.o
-    insmod $SRCDIR/../../portals/linux/socknal/ksocknal.o || exit -1
-
-    [ "$NETWORK" = "tcp" ] && ($ACCEPTOR $PORT &)
-
-    [ -c /dev/obd ] || mknod /dev/obd c 10 241
-
-    insmod $SRCDIR/../../obd/class/obdclass.o || exit -1
-    insmod $SRCDIR/../../obd/rpc/ptlrpc.o || exit -1
-    insmod $SRCDIR/../../obd/ldlm/ldlm.o || exit -1
-    insmod $SRCDIR/../../obd/ext2obd/obdext2.o || exit -1
-    insmod $SRCDIR/../../obd/filterobd/obdfilter.o || exit -1
-    insmod $SRCDIR/../../obd/ost/ost.o || exit -1
-    insmod $SRCDIR/../../obd/osc/osc.o || exit -1
-    insmod $SRCDIR/../../obd/obdecho/obdecho.o || exit -1
-    insmod $SRCDIR/../../obd/mds/mds.o || exit -1
-    insmod $SRCDIR/../../obd/mdc/mdc.o || exit -1
-    insmod $SRCDIR/../../obd/llight/llight.o || exit -1
-
-    list_mods
-
-    [ -d /mnt/obd ] || mkdir /mnt/obd
+       echo "The GDB module script is in /tmp/ogdb"
 }
 
 setup_portals() {
        if [ -z "$NETWORK" -o -z "$LOCALHOST" -o -z "$SERVER" ]; then
-               echo "$0: NETWORK or LOCALHOST or SERVER is not set"
+               echo "$0: NETWORK or LOCALHOST or SERVER is not set" 1>&2
                exit -1
        fi
 
+       [ -c /dev/portals ] || mknod /dev/portals c 10 240
+
+       insmod $SRCDIR/../../portals/linux/oslib/portals.o || exit -1
+
        case $NETWORK in
        elan)   if [ "$PORT" ]; then
-                       echo "$0: NETWORK is elan but PORT is set"
+                       echo "$0: NETWORK is elan but PORT is set" 1>&2
                        exit -1
                fi
+               insmod $SRCDIR/../../portals/linux/qswnal/kqswnal.o
                ;;
        tcp)    if [ -z "$PORT" ]; then
-                       echo "$0: NETWORK is tcp but PORT is not set"
+                       echo "$0: NETWORK is tcp but PORT is not set" 1>&2
                        exit -1
                fi
+               insmod $SRCDIR/../../portals/linux/socknal/ksocknal.o || exit -1
+               $ACCEPTOR $PORT
                ;;
-       *)      echo "$0: unknown NETWORK \'$NETWORK\'"
+       *)      echo "$0: unknown NETWORK \'$NETWORK\'" 1>&2
                exit -1
                ;;
        esac
@@ -148,13 +134,33 @@ setup_portals() {
        EOF
 }
 
+setup_lustre() {
+       [ -c /dev/obd ] || mknod /dev/obd c 10 241
+
+       insmod $SRCDIR/../../obd/class/obdclass.o || exit -1
+       insmod $SRCDIR/../../obd/rpc/ptlrpc.o || exit -1
+       insmod $SRCDIR/../../obd/ldlm/ldlm.o || exit -1
+       insmod $SRCDIR/../../obd/ext2obd/obdext2.o || exit -1
+       insmod $SRCDIR/../../obd/filterobd/obdfilter.o || exit -1
+       insmod $SRCDIR/../../obd/ost/ost.o || exit -1
+       insmod $SRCDIR/../../obd/osc/osc.o || exit -1
+       insmod $SRCDIR/../../obd/obdecho/obdecho.o || exit -1
+       insmod $SRCDIR/../../obd/mds/mds.o || exit -1
+       insmod $SRCDIR/../../obd/mdc/mdc.o || exit -1
+       insmod $SRCDIR/../../obd/llight/llite.o || exit -1
+
+       list_mods
+
+       [ -d /mnt/lustre ] || mkdir /mnt/lustre
+}
+
 setup_ldlm() {
-    [ -c /dev/portals ] || mknod /dev/portals c 10 240
+       [ -c /dev/portals ] || mknod /dev/portals c 10 240
 
-    insmod $SRCDIR/../../portals/linux/oslib/portals.o || exit -1
+       insmod $SRCDIR/../../portals/linux/oslib/portals.o || exit -1
 
-    insmod $SRCDIR/../../obd/class/obdclass.o || exit -1
-    insmod $SRCDIR/../../obd/ldlm/ldlm.o || exit -1
+       insmod $SRCDIR/../../obd/class/obdclass.o || exit -1
+       insmod $SRCDIR/../../obd/ldlm/ldlm.o || exit -1
 
-    list_mods
+       list_mods
 }