Whamcloud - gitweb
Add new simple test script "runtests" which automates a bunch of the basic
authoradilger <adilger>
Fri, 29 Mar 2002 22:20:34 +0000 (22:20 +0000)
committeradilger <adilger>
Fri, 29 Mar 2002 22:20:34 +0000 (22:20 +0000)
tests which I do before committing stuff to CVS (copy some files, check
they are OK, shutdown+restart, check files again, etc).

Add support in "new_fs" for using pre-built filesystems for testing (this
is considerably faster than building a new fs each time on loopback).

lustre/tests/common.sh
lustre/tests/runtests [new file with mode: 0755]

index d1a2c0d..51604eb 100644 (file)
@@ -21,6 +21,8 @@ else
   fi
 fi
 
+# Return the next unused loop device on stdout and in the $LOOPDEV
+# environment variable.
 next_loop_dev() {
        NEXT=
        while [ -b ${LOOP}${LOOPNUM} ]; do
@@ -31,23 +33,58 @@ next_loop_dev() {
        done
 }
 
-list_mods() {
-    $DEBCTL modules > $R/tmp/ogdb
-    echo "The GDB module script is in /tmp/ogdb.  Press enter to continue"
-    read
-}
-
+# Create a new filesystem.  If we are using a loopback device, we check
+# for existing "template" filesystems instead of creating a new one,
+# because it is _much_ faster to gunzip the empty filesystem instead of
+# creating a new one from scratch.  Conversely, if we are creating a
+# filesystem on a device we use mkfs, because that only writes sparsely
+# to the device.  The empty filesystems are also highly compressed (1000:1)
+# so they don't take too much space.
 new_fs () {
-    dd if=/dev/zero of=$2 bs=1k count=$3 1>&2 || exit -1
-    mkfs.$1 -b 4096 -F $2 1>&2 || exit -1
-    LOOPDEV=`next_loop_dev`
-    losetup ${LOOPDEV} $2 1>&2 || exit -1
+       EFILE="$1_$3.gz"
+       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
+               LOOPDEV=$2      # Not really a loop device
+       else
+               if [ -f "$EFILE" ]; then
+                       echo "using existing filesystem $EFILE for $2"
+                       zcat "$EFILE" > $2 || exit -1
+                       sync
+               else
+                       echo "creating new filesystem on $2"
+                       dd if=/dev/zero of=$2 bs=1k count=$3 1>&2 || exit -1
+                       $MKFS $MKFSOPT -F $2 1>&2 || exit -1
+               fi
+               LOOPDEV=`next_loop_dev`
+               losetup ${LOOPDEV} $2 1>&2 || exit -1
+       fi
 }
 
+# Set up to use an existing filesystem.  We take the same parameters as
+# new_fs, even though we only use the <file> parameter, to make it easy
+# to convert between new_fs and old_fs in testing scripts.
 old_fs () {
-    [ -e $2 ] || exit -1
-    LOOPDEV=`next_loop_dev`
-    losetup ${LOOPDEV} $2 1>&2 || exit -1
+       [ -e $2 ] || exit -1
+
+       if [ -b "$2" ]; then
+               LOOPDEV=$2      # Not really a loop device
+       else
+               LOOPDEV=`next_loop_dev`
+               losetup ${LOOPDEV} $2 1>&2 || exit -1
+       fi
+}
+
+list_mods() {
+       $DEBCTL modules > $R/tmp/ogdb
+       echo "The GDB module script is in /tmp/ogdb.  Press enter to continue"
+       read
 }
 
 setup() {
diff --git a/lustre/tests/runtests b/lustre/tests/runtests
new file mode 100755 (executable)
index 0000000..239aa50
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# Script which does some basic tests to ensure we haven't regressed.
+# Probably a good idea to run this before doing any checkins.
+# In the future this can become more fancy, but it's OK for now.
+
+RUNDIR=`dirname $0`
+
+PATH=$PATH:$RUNDIR
+
+ERROR=
+
+llmount.sh || exit 1
+
+# let's start slowly here...
+touch /mnt/obd || exit 2
+cp /etc/hosts /mnt/obd || exit 3
+diff -u /etc/hosts /mnt/obd/hosts || exit 4
+
+# ok, that hopefully worked, so let's do a little more
+FILES=`find /etc -type f`
+echo "copying files from /etc to /mnt/obd"
+tar cf - $FILES | tar xf - -C /mnt/obd || exit 10
+
+echo "comparing newly copied files"
+for f in $FILES; do
+       diff -q $f /mnt/obd/$f || ERROR=11
+done
+
+[ "$ERROR" ] && exit $ERROR
+
+llmountcleanup.sh
+
+llrmount.sh || exit 20
+echo "comparing previously copied files"
+diff -u /etc/hosts /mnt/obd/hosts || exit 21
+
+for f in $FILES; do
+       diff -q $f /mnt/obd/$f || ERROR=22
+done
+
+[ "$ERROR" ] && exit $ERROR
+
+rm /mnt/obd/hosts || exit 23
+
+rm -r /mnt/obd/etc || exit 24
+
+llmountcleanup.sh