3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
10 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
11 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
14 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
15 export SECURITY=${SECURITY:-"null"}
18 FSTYPE=${FSTYPE:-ext3}
20 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
21 CREATETEST=${CREATETEST:-createtest}
23 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
24 LFIND=${LFIND:-"$LFS find"}
25 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
27 MCREATE=${MCREATE:-mcreate}
28 OPENFILE=${OPENFILE:-openfile}
29 OPENUNLINK=${OPENUNLINK:-openunlink}
30 TOEXCL=${TOEXCL:-toexcl}
31 TRUNCATE=${TRUNCATE:-truncate}
32 MUNLINK=${MUNLINK:-munlink}
33 SOCKETSERVER=${SOCKETSERVER:-socketserver}
34 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
35 IOPENTEST1=${IOPENTEST1:-iopentest1}
36 IOPENTEST2=${IOPENTEST2:-iopentest2}
37 PTLDEBUG=${PTLDEBUG:-0}
41 if [ $UID -ne 0 ]; then
45 RUNAS_ID=${RUNAS_ID:-500}
46 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
49 if [ `using_krb5_sec $SECURITY` == 'y' ] ; then
50 start_krb5_kdc || exit 1
51 if [ $RUNAS_ID -ne $UID ]; then
52 $RUNAS ./krb5_refresh_cache.sh || exit 2
56 export NAME=${NAME:-local}
62 sh llmountcleanup.sh > /dev/null || exit 20
69 sh llrmount.sh > /dev/null || exit 10
77 lctl mark "$*" 2> /dev/null || true
82 strace -o $TMP/$1.strace -ttt $*
84 log "FINISHED: $*: rc $RC"
89 check_kernel_version() {
90 VERSION_FILE=/proc/fs/lustre/kernel_version
92 [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
93 GOT_VER=`cat $VERSION_FILE`
94 [ $GOT_VER -ge $WANT_VER ] && return 0
95 log "test needs at least kernel version $WANT_VER, running $GOT_VER"
100 if ! mount | grep -q $DIR; then
103 echo $PTLDEBUG >/proc/sys/portals/debug
105 export TESTNAME=test_$1
106 test_$1 || error "test_$1: exit with rc=$?"
113 build_test_filter() {
117 for E in $EXCEPT $ALWAYS_EXCEPT; do
118 eval EXCEPT_${E}=true
127 IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
134 if [ ${!testname}x != x ]; then
139 if [ ${!testname}x != x ]; then
147 if [ ${!testname}x != x ]; then
148 echo "skipping excluded test $1"
151 testname=EXCEPT_$base
152 if [ ${!testname}x != x ]; then
153 echo "skipping excluded test $1 (base $base)"
160 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
164 if [ "$SANITYLOG" ]; then
165 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
175 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
176 if [ -z "$MOUNT" ]; then
178 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
179 [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
183 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
186 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
188 rm -rf $DIR/[Rdfs][1-9]*
191 echo preparing for tests involving mounts
192 EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
194 mke2fs -j -F $EXT2_DEV 8000 >/dev/null 2>&1
198 test -b /dev/loop0 &&
199 base="/dev/loop" || base="/dev/loop/"
201 for ((i=0;i<256;i++)); do
202 test -b $base$i || continue
204 losetup $base$i >/dev/null 2>&1 || {
216 dd if=/dev/zero of=$LOOP_FILE bs=1M count=10 2>/dev/null || return $?
218 losetup $LOOP_DEV $LOOP_FILE || {
220 cleanup_loop $LOOP_DEV $LOOP_FILE
224 mke2fs -F $LOOP_DEV >/dev/null 2>&1 || {
226 cleanup_loop $LOOP_DEV $LOOP_FILE
227 echo "cannot create test ext2 fs on $LOOP_DEV"
237 losetup -d $LOOP_DEV >/dev/null 2>&1
238 rm -fr $LOOP_FILE >/dev/null 2>&1
247 test "x$MODE" = "xDEADLOCK" &&
248 INJECTION="touch \$MNTPATH/file"
250 cat > $UPCALL <<- EOF
253 MOUNT=\`which mount 2>/dev/null\`
254 test "x\$MOUNT" = "x" && MOUNT="/bin/mount"
259 test "x\$OPTIONS" = "x" || "x\$MNTPATH" = "x" &&
263 \$MOUNT \$OPTIONS \$MNTPATH > $LOG 2>&1
276 local LOG="/tmp/gns-log"
284 rm -fr $LOG >/dev/null 2>&1
285 UPCALL_PATH="/tmp/gns-upcall-$UPCALL.sh"
287 echo "generating upcall $UPCALL_PATH"
288 setup_upcall $UPCALL_PATH $UPCALL $LOG || return $rc
289 echo "======================== upcall script ==========================="
290 cat $UPCALL_PATH 2>/dev/null || return $?
291 echo "=================================================================="
293 echo "$UPCALL_PATH" > /proc/fs/lustre/llite/fs0/gns_upcall || return $?
294 echo "upcall: $(cat /proc/fs/lustre/llite/fs0/gns_upcall)"
296 echo -n "mount on open $OBJECT/test_file1: "
297 echo -n "test data" > $OBJECT/test_file1 >/dev/null 2>&1 || return $?
299 local ENTRY="`basename $OBJECT`"
301 cat /proc/mounts | grep -q "$ENTRY" || {
304 echo "======================== upcall log ==========================="
306 echo "==============================================================="
308 echo "upcall log file $LOG is not found"
310 cleanup_upcall $UPCALL_PATH
315 local sleep_time=$TIMOUT
316 let sleep_time+=$TICK*2
317 echo -n "waiting for umount ${sleep_time}s (timeout + tick*2): "
320 cat /proc/mounts | grep -q "$ENTRY" && {
322 cleanup_upcall $UPCALL_PATH
326 cleanup_upcall $UPCALL_PATH
335 mkdir -p $OBJPATH || return $?
336 echo -n $CONTENT > $OBJPATH/$OBJECT || return $?
338 echo "======================== mount object ==========================="
341 echo "================================================================="
350 chmod u-s $OBJPATH >/dev/null 2>&1
351 umount $OBJPATH >/dev/null 2>&1
352 rm -fr $OBJPATH >/dev/null 2>&1
360 echo "$OBJECT" > /proc/fs/lustre/llite/fs0/gns_object_name || error
361 echo "$TIMOUT" > /proc/fs/lustre/llite/fs0/gns_timeout || error
362 echo "$TICK" > /proc/fs/lustre/llite/fs0/gns_tick || error
365 echo "timeout: $(cat /proc/fs/lustre/llite/fs0/gns_timeout)s"
366 echo "object: $(cat /proc/fs/lustre/llite/fs0/gns_object_name)"
367 echo "tick: $(cat /proc/fs/lustre/llite/fs0/gns_tick)s"
373 local LOOP_DEV=$(find_free_loop 2>/dev/null)
374 local UPCALL="/tmp/gns-upcall.sh"
375 local LOOP_FILE="/tmp/gns_loop_1a"
376 local OBJECT=".mntinfo"
380 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
381 error "can't find free loop device"
383 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
384 cleanup_loop $LOOP_DEV $LOOP_FILE
385 setup_loop $LOOP_DEV $LOOP_FILE || error
387 echo "setting up GNS timeouts and mount object..."
388 setup_gns $OBJECT $TIMOUT $TICK || error
390 echo "preparing mount object at $DIR/gns_test_1a/$OBJECT..."
391 setup_object $DIR/gns_test_1a $OBJECT "-t ext2 $LOOP_DEV" || error
394 echo "testing GNS with GENERIC upcall 3 times on the row"
395 for ((i=0;i<3;i++)); do
396 check_gns GENERIC $DIR/gns_test_1a $TIMOUT $TICK || {
397 cleanup_object $DIR/gns_test_1a
398 cleanup_loop $LOOP_DEV $LOOP_FILE
403 cleanup_object $DIR/gns_test_1a
404 cleanup_loop $LOOP_DEV $LOOP_FILE
407 run_test 1a " general GNS test - mounting/umount (GENERIC) ============="
410 local LOOP_DEV=$(find_free_loop 2>/dev/null)
411 local UPCALL="/tmp/gns-upcall.sh"
412 local LOOP_FILE="/tmp/gns_loop_2a"
413 local OBJECT=".mntinfo"
417 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
418 error "can't find free loop device"
420 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
421 cleanup_loop $LOOP_DEV $LOOP_FILE
422 setup_loop $LOOP_DEV $LOOP_FILE || error
424 echo "setting up GNS timeouts and mount object..."
425 setup_gns $OBJECT $TIMOUT $TICK || error
427 echo "preparing mount object at $DIR/gns_test_2a/$OBJECT..."
428 setup_object $DIR/gns_test_2a $OBJECT "-t ext2 $LOOP_DEV" || error
431 echo "testing GNS with DEADLOCK upcall 3 times on the row"
432 for ((i=0;i<3;i++)); do
433 check_gns DEADLOCK $DIR/gns_test_2a $TIMOUT $TICK || {
434 cleanup_object $DIR/gns_test_2a
435 cleanup_loop $LOOP_DEV $LOOP_FILE
440 cleanup_object $DIR/gns_test_2a
441 cleanup_loop $LOOP_DEV $LOOP_FILE
444 run_test 2a " general GNS test - mounting/umount (DEADLOCK) ============"
447 local LOOP_DEV=$(find_free_loop 2>/dev/null)
448 local UPCALL="/tmp/gns-upcall.sh"
449 local LOOP_FILE="/tmp/gns_loop_3a"
450 local OBJECT=".mntinfo"
454 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
455 error "can't find free loop device"
457 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
458 cleanup_loop $LOOP_DEV $LOOP_FILE
459 setup_loop $LOOP_DEV $LOOP_FILE || error
461 echo "setting up GNS timeouts and mount object..."
462 setup_gns $OBJECT $TIMOUT $TICK || error
464 echo "preparing mount object at $DIR/gns_test_3a/$OBJECT..."
465 setup_object $DIR/gns_test_3a $OBJECT "-t ext2 $LOOP_DEV" || error
468 echo "testing GNS with DEADLOCK upcall 4 times on the row"
469 for ((i=0;i<4;i++)); do
472 test $(($i%2)) -eq 1 && MODE="DEADLOCK"
474 check_gns $MODE $DIR/gns_test_3a $TIMOUT $TICK || {
475 cleanup_object $DIR/gns_test_3a
476 cleanup_loop $LOOP_DEV $LOOP_FILE
481 cleanup_object $DIR/gns_test_3a
482 cleanup_loop $LOOP_DEV $LOOP_FILE
485 run_test 3a " general GNS test - mounting/umount (GENERIC/DEADLOCK) ====="
488 echo "Not implemented yet!"
491 run_test 4a " general GNS test - concurrent mounting/umount ============="
497 log "cleanup: ==========================================================="
498 if [ "`mount | grep ^$NAME`" ]; then
499 rm -rf $DIR/[Rdfs][1-9]*
500 if [ "$I_MOUNTED" = "yes" ]; then
501 sh llmountcleanup.sh || error
505 echo '=========================== finished ==============================='
506 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true