From 52c583046beccb1751d48d17f5f39f37b45a5fdc Mon Sep 17 00:00:00 2001 From: adilger Date: Wed, 13 Aug 2003 17:00:05 +0000 Subject: [PATCH] First test for io sanity - force a zero-length read from a sparse stripe. --- lustre/tests/iosanity.sh | 149 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 lustre/tests/iosanity.sh diff --git a/lustre/tests/iosanity.sh b/lustre/tests/iosanity.sh new file mode 100644 index 0000000..8fc483e --- /dev/null +++ b/lustre/tests/iosanity.sh @@ -0,0 +1,149 @@ +#!/bin/bash +# +# Run select tests by setting ONLY, or as arguments to the script. +# Skip specific tests by setting EXCEPT. +# +# e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31" +set -e + +ONLY=${ONLY:-"$*"} +# bug number for skipped test: +ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""} + +SRCDIR=`dirname $0` +PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH + +CHECKSTAT=${CHECKSTAT:-"checkstat -v"} +CREATETEST=${CREATETEST:-createtest} +LFIND=${LFIND:-lfind} +LSTRIPE=${LSTRIPE:-lstripe} +LCTL=${LCTL:-lctl} +MCREATE=${MCREATE:-mcreate} +OPENFILE=${OPENFILE:-openfile} +OPENUNLINK=${OPENUNLINK:-openunlink} +TOEXCL=${TOEXCL:-toexcl} +TRUNCATE=${TRUNCATE:-truncate} +MUNLINK=${MUNLINK:-munlink} + +export NAME=${NAME:-local} + +SAVE_PWD=$PWD + +clean() { + echo -n "cln.." + sh llmountcleanup.sh > /dev/null || exit 20 +} +CLEAN=${CLEAN:-clean} + +start() { + echo -n "mnt.." + sh llrmount.sh > /dev/null || exit 10 + echo "done" +} +START=${START:-start} + +log() { + echo "$*" + lctl mark "$*" 2> /dev/null || true +} + +run_one() { + if ! mount | grep -q $DIR; then + $START + fi + log "== test $1: $2" + test_$1 || error "test_$1: $?" + pass + cd $SAVE_PWD + $CLEAN +} + +build_test_filter() { + for O in $ONLY; do + eval ONLY_${O}=true + done + for E in $EXCEPT $ALWAYS_EXCEPT; do + eval EXCEPT_${E}=true + done +} + +_basetest() { + echo $* +} + +basetest() { + IFS=abcdefghijklmnopqrstuvwxyz _basetest $1 +} + +run_test() { + base=`basetest $1` + if [ "$ONLY" ]; then + testname=ONLY_$1 + if [ ${!testname}x != x ]; then + run_one $1 "$2" + return $? + fi + testname=ONLY_$base + if [ ${!testname}x != x ]; then + run_one $1 "$2" + return $? + fi + echo -n "." + return 0 + fi + testname=EXCEPT_$1 + if [ ${!testname}x != x ]; then + echo "skipping excluded test $1" + return 0 + fi + testname=EXCEPT_$base + if [ ${!testname}x != x ]; then + echo "skipping excluded test $1 (base $base)" + return 0 + fi + run_one $1 "$2" + return $? +} + +error() { + log "FAIL: $@" + exit 1 +} + +pass() { + echo PASS +} + +MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`" +if [ -z "$MOUNT" ]; then + sh llmount.sh + MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`" + [ -z "$MOUNT" ] && error "NAME=$NAME not mounted" + I_MOUNTED=yes +fi + +[ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once" + +DIR=${DIR:-$MOUNT} +[ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99 + +[ `ls -d /proc/fs/lustre/osc/OSC* 2> /dev/null | wc -l` -gt 1 ] && LOV=yes + +rm -rf $DIR/[df][1-9]* + +build_test_filter + +test_1() { + [ "$LOV" != "yes" ] && echo "skipping LOV-only test" && return + dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=127 + dd if=$DIR/f1 bs=4k count=1 +} +run_test 0 "zero length read from a sparse stripe ==============" + +log "cleanup: ======================================================" +rm -rf $DIR/[df][1-9]* +if [ "$I_MOUNTED" = "yes" -a "`mount | grep ^$NAME`" ]; then + sh llmountcleanup.sh || error +fi + +echo '=========================== finished ===============================' -- 1.8.3.1