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
279 echo "======================== upcall log ==========================="
281 echo "==============================================================="
283 echo "upcall log file $LOG is not found"
288 local LOG="/tmp/gns-log"
298 rm -fr $LOG >/dev/null 2>&1
299 UPCALL_PATH="/tmp/gns-upcall-$UPCALL.sh"
301 echo "generating upcall $UPCALL_PATH"
302 setup_upcall $UPCALL_PATH $UPCALL $LOG || return $rc
303 echo "======================== upcall script ==========================="
304 cat $UPCALL_PATH 2>/dev/null || return $?
305 echo "=================================================================="
307 echo "$UPCALL_PATH" > /proc/fs/lustre/llite/fs0/gns_upcall || return $?
308 echo "upcall: $(cat /proc/fs/lustre/llite/fs0/gns_upcall)"
312 echo -n "mount on open $OBJECT1/test_file1 (generic): "
313 echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 || return $?
319 echo -n "mount on open $OBJECT1/test_file1 ($nr threads): "
320 for ((;i<=$nr;i++)); do
321 echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 &
327 test "x$OBJECT2" = "x" && {
328 echo "not defined object2 for concurrent2 testing"
331 echo -n "mount on open $OBJECT1/test_file1: "
332 echo -n "mount on open $OBJECT2/test_file1: "
333 echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 &
334 echo -n "test data" > $OBJECT2/test_file1 >/dev/null 2>&1 &
337 echo "invalid testing mode $MODE"
341 local ENTRY1="`basename $OBJECT1`"
342 local ENTRY2="`basename $OBJECT2`"
344 cat /proc/mounts | grep -q "$ENTRY1" || {
347 cleanup_upcall $UPCALL_PATH
351 if test "x$MODE" = "xCONCUR2"; then
352 cat /proc/mounts | grep -q "$ENTRY2" || {
355 cleanup_upcall $UPCALL_PATH
362 local sleep_time=$TIMOUT
363 let sleep_time+=$TICK*2
364 echo -n "waiting for umount ${sleep_time}s (timeout + tick*2): "
367 cat /proc/mounts | grep -q "$ENTRY1" && {
369 cleanup_upcall $UPCALL_PATH
373 if test "x$MODE" = "xCONCUR2"; then
374 cat /proc/mounts | grep -q "$ENTRY2" && {
376 cleanup_upcall $UPCALL_PATH
382 cleanup_upcall $UPCALL_PATH
391 mkdir -p $OBJPATH || return $?
392 echo -n $CONTENT > $OBJPATH/$OBJECT || return $?
394 echo "======================== mount object ==========================="
397 echo "================================================================="
406 chmod u-s $OBJPATH >/dev/null 2>&1
407 umount $OBJPATH >/dev/null 2>&1
408 rm -fr $OBJPATH >/dev/null 2>&1
416 echo "$OBJECT" > /proc/fs/lustre/llite/fs0/gns_object_name || error
417 echo "$TIMOUT" > /proc/fs/lustre/llite/fs0/gns_timeout || error
418 echo "$TICK" > /proc/fs/lustre/llite/fs0/gns_tick || error
421 echo "timeout: $(cat /proc/fs/lustre/llite/fs0/gns_timeout)s"
422 echo "object: $(cat /proc/fs/lustre/llite/fs0/gns_object_name)"
423 echo "tick: $(cat /proc/fs/lustre/llite/fs0/gns_tick)s"
429 local LOOP_DEV=$(find_free_loop 2>/dev/null)
430 local UPCALL="/tmp/gns-upcall.sh"
431 local LOOP_FILE="/tmp/gns_loop_1a"
432 local OBJECT=".mntinfo"
436 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
437 error "can't find free loop device"
439 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
440 cleanup_loop $LOOP_DEV $LOOP_FILE
441 setup_loop $LOOP_DEV $LOOP_FILE || error
443 echo "setting up GNS timeouts and mount object..."
444 setup_gns $OBJECT $TIMOUT $TICK || error
446 echo "preparing mount object at $DIR/gns_test_1a/$OBJECT..."
447 setup_object $DIR/gns_test_1a $OBJECT "-t ext2 $LOOP_DEV" || error
450 echo "testing GNS with GENERIC upcall 3 times on the row"
451 for ((i=0;i<3;i++)); do
452 check_gns GENERIC $DIR/gns_test_1a $DIR/gns_test_1a $TIMOUT $TICK GENERIC || {
453 cleanup_object $DIR/gns_test_1a
454 cleanup_loop $LOOP_DEV $LOOP_FILE
459 cleanup_object $DIR/gns_test_1a
460 cleanup_loop $LOOP_DEV $LOOP_FILE
463 run_test 1a " general GNS test - mount/umount (GENERIC) ================"
466 local LOOP_DEV=$(find_free_loop 2>/dev/null)
467 local UPCALL="/tmp/gns-upcall.sh"
468 local LOOP_FILE="/tmp/gns_loop_2a"
469 local OBJECT=".mntinfo"
473 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
474 error "can't find free loop device"
476 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
477 cleanup_loop $LOOP_DEV $LOOP_FILE
478 setup_loop $LOOP_DEV $LOOP_FILE || error
480 echo "setting up GNS timeouts and mount object..."
481 setup_gns $OBJECT $TIMOUT $TICK || error
483 echo "preparing mount object at $DIR/gns_test_2a/$OBJECT..."
484 setup_object $DIR/gns_test_2a $OBJECT "-t ext2 $LOOP_DEV" || error
487 echo "testing GNS with DEADLOCK upcall 3 times on the row"
488 for ((i=0;i<3;i++)); do
489 check_gns DEADLOCK $DIR/gns_test_2a $DIR/gns_test_2a $TIMOUT $TICK GENERIC || {
490 cleanup_object $DIR/gns_test_2a
491 cleanup_loop $LOOP_DEV $LOOP_FILE
496 cleanup_object $DIR/gns_test_2a
497 cleanup_loop $LOOP_DEV $LOOP_FILE
500 run_test 2a " general GNS test - mount/umount (DEADLOCK) ==============="
503 local LOOP_DEV=$(find_free_loop 2>/dev/null)
504 local UPCALL="/tmp/gns-upcall.sh"
505 local LOOP_FILE="/tmp/gns_loop_3a"
506 local OBJECT=".mntinfo"
510 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
511 error "can't find free loop device"
513 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
514 cleanup_loop $LOOP_DEV $LOOP_FILE
515 setup_loop $LOOP_DEV $LOOP_FILE || error
517 echo "setting up GNS timeouts and mount object..."
518 setup_gns $OBJECT $TIMOUT $TICK || error
520 echo "preparing mount object at $DIR/gns_test_3a/$OBJECT..."
521 setup_object $DIR/gns_test_3a $OBJECT "-t ext2 $LOOP_DEV" || error
524 echo "testing GNS with DEADLOCK upcall 4 times on the row"
530 test $(($i%2)) -eq 1 && MODE="DEADLOCK"
532 check_gns $MODE $DIR/gns_test_3a $DIR/gns_test_3a $TIMOUT $TICK GENERIC || {
533 cleanup_object $DIR/gns_test_3a
534 cleanup_loop $LOOP_DEV $LOOP_FILE
539 cleanup_object $DIR/gns_test_3a
540 cleanup_loop $LOOP_DEV $LOOP_FILE
543 run_test 3a " general GNS test - mount/umount (GENERIC/DEADLOCK) ========"
546 local LOOP_DEV=$(find_free_loop 2>/dev/null)
547 local UPCALL="/tmp/gns-upcall.sh"
548 local LOOP_FILE="/tmp/gns_loop_4a"
549 local OBJECT=".mntinfo"
553 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
554 error "can't find free loop device"
556 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
557 cleanup_loop $LOOP_DEV $LOOP_FILE
558 setup_loop $LOOP_DEV $LOOP_FILE || error
560 echo "setting up GNS timeouts and mount object..."
561 setup_gns $OBJECT $TIMOUT $TICK || error
563 echo "preparing mount object at $DIR/gns_test_4a/$OBJECT..."
564 setup_object $DIR/gns_test_4a $OBJECT "-t ext2 $LOOP_DEV" || error
567 echo "testing GNS with DEADLOCK upcall 4 times on the row"
573 test $(($i%2)) -eq 1 && MODE="DEADLOCK"
575 check_gns $MODE $DIR/gns_test_4a $DIR/gns_test_4a $TIMOUT $TICK CONCUR1 || {
576 cleanup_object $DIR/gns_test_4a
577 cleanup_loop $LOOP_DEV $LOOP_FILE
582 cleanup_object $DIR/gns_test_4a
583 cleanup_loop $LOOP_DEV $LOOP_FILE
586 run_test 4a " general GNS test - concurrent mount ======================="
589 local LOOP_DEV=$(find_free_loop 2>/dev/null)
590 local UPCALL="/tmp/gns-upcall.sh"
591 local LOOP_FILE="/tmp/gns_loop_5a"
592 local OBJECT=".mntinfo"
596 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
597 error "can't find free loop device"
599 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
600 cleanup_loop $LOOP_DEV $LOOP_FILE
601 setup_loop $LOOP_DEV $LOOP_FILE || error
603 echo "setting up GNS timeouts and mount object..."
604 setup_gns $OBJECT $TIMOUT $TICK || error
606 echo "preparing mount object at $DIR/gns_test_5a1/$OBJECT..."
607 setup_object $DIR/gns_test_5a1 $OBJECT "-t ext2 $LOOP_DEV" || error
609 echo "preparing mount object at $DIR/gns_test_5a2/$OBJECT..."
610 setup_object $DIR/gns_test_5a2 $OBJECT "-t ext2 $LOOP_DEV" || error
613 echo "testing GNS with GENERIC upcall"
614 check_gns GENERIC $DIR/gns_test_5a1 $DIR/gns_test_5a2 $TIMOUT $TICK CONCUR2 || {
615 cleanup_object $DIR/gns_test_5a1
616 cleanup_object $DIR/gns_test_5a2
617 cleanup_loop $LOOP_DEV $LOOP_FILE
621 cleanup_object $DIR/gns_test_5a1
622 cleanup_object $DIR/gns_test_5a2
623 cleanup_loop $LOOP_DEV $LOOP_FILE
626 run_test 5a " general GNS test - concurrent mount of 2 GNS mounts ======="
632 log "cleanup: ==========================================================="
633 if [ "`mount | grep ^$NAME`" ]; then
634 rm -rf $DIR/[Rdfs][1-9]*
635 if [ "$I_MOUNTED" = "yes" ]; then
636 sh llmountcleanup.sh || error
640 echo '=========================== finished ==============================='
641 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true