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 "==============================================================="
286 local LOG="/tmp/gns-log"
296 rm -fr $LOG >/dev/null 2>&1
297 UPCALL_PATH="/tmp/gns-upcall-$UPCALL.sh"
299 echo "generating upcall $UPCALL_PATH"
300 setup_upcall $UPCALL_PATH $UPCALL $LOG || return $rc
301 echo "======================== upcall script ==========================="
302 cat $UPCALL_PATH 2>/dev/null || return $?
303 echo "=================================================================="
305 echo "$UPCALL_PATH" > /proc/fs/lustre/llite/fs0/gns_upcall || return $?
306 echo "upcall: $(cat /proc/fs/lustre/llite/fs0/gns_upcall)"
310 echo -n "mount on open $OBJECT1/test_file1 (generic): "
311 echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 || return $?
317 echo -n "mount on open $OBJECT1/test_file1 ($nr threads): "
318 for ((;i<=$nr;i++)); do
319 echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 &
325 test "x$OBJECT2" = "x" && {
326 echo "not defined object2 for concurrent2 testing"
329 echo -n "mount on open $OBJECT1/test_file1: "
330 echo -n "mount on open $OBJECT2/test_file1: "
331 echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 &
332 echo -n "test data" > $OBJECT2/test_file1 >/dev/null 2>&1 &
335 echo "invalid testing mode $MODE"
339 local ENTRY1="`basename $OBJECT1`"
340 local ENTRY2="`basename $OBJECT2`"
342 cat /proc/mounts | grep -q "$ENTRY1" || {
345 cleanup_upcall $UPCALL_PATH
349 if test "x$MODE" = "xCONCUR2"; then
350 cat /proc/mounts | grep -q "$ENTRY2" || {
353 cleanup_upcall $UPCALL_PATH
360 local sleep_time=$TIMOUT
361 let sleep_time+=$TICK*2
362 echo -n "waiting for umount ${sleep_time}s (timeout + tick*2): "
365 cat /proc/mounts | grep -q "$ENTRY1" && {
367 cleanup_upcall $UPCALL_PATH
371 if test "x$MODE" = "xCONCUR2"; then
372 cat /proc/mounts | grep -q "$ENTRY2" && {
374 cleanup_upcall $UPCALL_PATH
380 cleanup_upcall $UPCALL_PATH
389 mkdir -p $OBJPATH || return $?
390 echo -n $CONTENT > $OBJPATH/$OBJECT || return $?
392 echo "======================== mount object ==========================="
395 echo "================================================================="
404 chmod u-s $OBJPATH >/dev/null 2>&1
405 umount $OBJPATH >/dev/null 2>&1
406 rm -fr $OBJPATH >/dev/null 2>&1
414 echo "$OBJECT" > /proc/fs/lustre/llite/fs0/gns_object_name || error
415 echo "$TIMOUT" > /proc/fs/lustre/llite/fs0/gns_timeout || error
416 echo "$TICK" > /proc/fs/lustre/llite/fs0/gns_tick || error
419 echo "timeout: $(cat /proc/fs/lustre/llite/fs0/gns_timeout)s"
420 echo "object: $(cat /proc/fs/lustre/llite/fs0/gns_object_name)"
421 echo "tick: $(cat /proc/fs/lustre/llite/fs0/gns_tick)s"
427 local LOOP_DEV=$(find_free_loop 2>/dev/null)
428 local LOOP_FILE="/tmp/gns_loop_1a"
429 local OBJECT=".mntinfo"
433 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
434 error "can't find free loop device"
436 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
437 cleanup_loop $LOOP_DEV $LOOP_FILE
438 setup_loop $LOOP_DEV $LOOP_FILE || error
440 echo "setting up GNS timeouts and mount object..."
441 setup_gns $OBJECT $TIMOUT $TICK || error
443 echo "preparing mount object at $DIR/gns_test_1a/$OBJECT..."
444 setup_object $DIR/gns_test_1a $OBJECT "-t ext2 $LOOP_DEV" || error
447 echo "testing GNS with GENERIC upcall 3 times on the row"
448 for ((i=0;i<3;i++)); do
449 check_gns GENERIC $DIR/gns_test_1a $DIR/gns_test_1a $TIMOUT $TICK GENERIC || {
450 cleanup_object $DIR/gns_test_1a
451 cleanup_loop $LOOP_DEV $LOOP_FILE
456 cleanup_object $DIR/gns_test_1a
457 cleanup_loop $LOOP_DEV $LOOP_FILE
460 run_test 1a " general GNS test - mount/umount (GENERIC) ================"
463 local LOOP_DEV=$(find_free_loop 2>/dev/null)
464 local LOOP_FILE="/tmp/gns_loop_1b"
465 local OBJECT=".mntinfo"
469 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
470 error "can't find free loop device"
472 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
473 cleanup_loop $LOOP_DEV $LOOP_FILE
474 setup_loop $LOOP_DEV $LOOP_FILE || error
476 echo "setting up GNS timeouts and mount object..."
477 setup_gns $OBJECT $TIMOUT $TICK || error
479 echo "preparing mount object at $DIR/gns_test_1b/$OBJECT..."
480 setup_object $DIR/gns_test_1b $OBJECT "-t ext2 $LOOP_DEV" || error
483 echo "testing GNS with DEADLOCK upcall 3 times on the row"
484 for ((i=0;i<3;i++)); do
485 check_gns DEADLOCK $DIR/gns_test_1b $DIR/gns_test_1b $TIMOUT $TICK GENERIC || {
486 cleanup_object $DIR/gns_test_1b
487 cleanup_loop $LOOP_DEV $LOOP_FILE
492 cleanup_object $DIR/gns_test_1b
493 cleanup_loop $LOOP_DEV $LOOP_FILE
496 run_test 1b " general GNS test - mount/umount (DEADLOCK) ==============="
499 local LOOP_DEV=$(find_free_loop 2>/dev/null)
500 local LOOP_FILE="/tmp/gns_loop_1c"
501 local OBJECT=".mntinfo"
505 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
506 error "can't find free loop device"
508 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
509 cleanup_loop $LOOP_DEV $LOOP_FILE
510 setup_loop $LOOP_DEV $LOOP_FILE || error
512 echo "setting up GNS timeouts and mount object..."
513 setup_gns $OBJECT $TIMOUT $TICK || error
515 echo "preparing mount object at $DIR/gns_test_1c/$OBJECT..."
516 setup_object $DIR/gns_test_1c $OBJECT "-t ext2 $LOOP_DEV" || error
519 echo "testing GNS with DEADLOCK upcall 4 times on the row"
525 test $(($i%2)) -eq 1 && MODE="DEADLOCK"
527 check_gns $MODE $DIR/gns_test_1c $DIR/gns_test_1c $TIMOUT $TICK GENERIC || {
528 cleanup_object $DIR/gns_test_1c
529 cleanup_loop $LOOP_DEV $LOOP_FILE
534 cleanup_object $DIR/gns_test_1c
535 cleanup_loop $LOOP_DEV $LOOP_FILE
538 run_test 1c " general GNS test - mount/umount (GENERIC/DEADLOCK) ========"
541 local LOOP_DEV=$(find_free_loop 2>/dev/null)
542 local LOOP_FILE="/tmp/gns_loop_1d"
543 local OBJECT=".mntinfo"
547 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
548 error "can't find free loop device"
550 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
551 cleanup_loop $LOOP_DEV $LOOP_FILE
552 setup_loop $LOOP_DEV $LOOP_FILE || error
554 echo "setting up GNS timeouts and mount object..."
555 setup_gns $OBJECT $TIMOUT $TICK || error
557 echo "preparing mount object at $DIR/gns_test_1d/$OBJECT..."
558 setup_object $DIR/gns_test_1d $OBJECT "-t ext2 $LOOP_DEV" || error
561 echo "testing GNS with DEADLOCK upcall 4 times on the row"
567 test $(($i%2)) -eq 1 && MODE="DEADLOCK"
569 check_gns $MODE $DIR/gns_test_1d $DIR/gns_test_1d $TIMOUT $TICK CONCUR1 || {
570 cleanup_object $DIR/gns_test_1d
571 cleanup_loop $LOOP_DEV $LOOP_FILE
576 cleanup_object $DIR/gns_test_1d
577 cleanup_loop $LOOP_DEV $LOOP_FILE
580 run_test 1d " general GNS test - concurrent mount ======================="
583 local LOOP_DEV=$(find_free_loop 2>/dev/null)
584 local LOOP_FILE="/tmp/gns_loop_1e"
585 local OBJECT=".mntinfo"
589 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
590 error "can't find free loop device"
592 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
593 cleanup_loop $LOOP_DEV $LOOP_FILE
594 setup_loop $LOOP_DEV $LOOP_FILE || error
596 echo "setting up GNS timeouts and mount object..."
597 setup_gns $OBJECT $TIMOUT $TICK || error
599 echo "preparing mount object at $DIR/gns_test_1e1/$OBJECT..."
600 setup_object $DIR/gns_test_1e1 $OBJECT "-t ext2 $LOOP_DEV" || error
602 echo "preparing mount object at $DIR/gns_test_1e2/$OBJECT..."
603 setup_object $DIR/gns_test_1e2 $OBJECT "-t ext2 $LOOP_DEV" || error
606 echo "testing GNS with GENERIC upcall"
607 check_gns GENERIC $DIR/gns_test_1e1 $DIR/gns_test_1e2 $TIMOUT $TICK CONCUR2 || {
608 cleanup_object $DIR/gns_test_1e1
609 cleanup_object $DIR/gns_test_1e2
610 cleanup_loop $LOOP_DEV $LOOP_FILE
614 cleanup_object $DIR/gns_test_1e1
615 cleanup_object $DIR/gns_test_1e2
616 cleanup_loop $LOOP_DEV $LOOP_FILE
619 run_test 1e " general GNS test - concurrent mount of 2 GNS mounts ======="
622 local OBJECT=".mntinfo"
626 echo "setting up GNS timeouts and mount object..."
627 setup_gns $OBJECT $TIMOUT $TICK || error
629 echo "preparing mount object at $DIR/gns_test_2a/$OBJECT..."
630 mkdir -p $DIR/gns_test_2a
631 ln -s $DIR/gns_test_2a $DIR/gns_test_2a/$OBJECT
632 chmod u+s $DIR/gns_test_2a
635 echo "testing GNS with GENERIC upcall"
636 check_gns GENERIC $DIR/gns_test_2a $DIR/gns_test_2a $TIMOUT $TICK GENERIC && {
637 chmod u-s $DIR/gns_test_2a
638 rm -fr $DIR/gns_test_2a
639 error "symlink as mount object works?"
642 chmod u-s $DIR/gns_test_2a
643 rm -fr $DIR/gns_test_2a
646 run_test 2a " odd conditions (mount object is symlink) ============="
649 local OBJECT=".mntinfo"
653 echo "setting up GNS timeouts and mount object..."
654 setup_gns $OBJECT $TIMOUT $TICK || error
656 echo "preparing mount object at $DIR/gns_test_2b/$OBJECT..."
657 mkdir -p $DIR/gns_test_2b/$OBJECT
658 chmod u+s $DIR/gns_test_2b
661 echo "testing GNS with GENERIC upcall"
662 check_gns GENERIC $DIR/gns_test_2b $DIR/gns_test_2b $TIMOUT $TICK GENERIC && {
663 chmod u-s $DIR/gns_test_2b
664 rm -fr $DIR/gns_test_2b
665 error "dir as mount object works?"
668 chmod u-s $DIR/gns_test_2b
669 rm -fr $DIR/gns_test_2b
672 run_test 2b " odd conditions (mount object is directory) ==========="
675 local OBJECT=".mntinfo"
679 echo "setting up GNS timeouts and mount object..."
680 setup_gns $OBJECT $TIMOUT $TICK || error
682 echo "preparing mount object at $DIR/gns_test_2c/$OBJECT..."
683 mkdir -p $DIR/gns_test_2c/$OBJECT/$OBJECT/$OBJECT/$OBJECT
684 chmod u+s -R $DIR/gns_test_2c
687 echo "testing GNS with GENERIC upcall"
688 check_gns GENERIC $DIR/gns_test_2c $DIR/gns_test_2c $TIMOUT $TICK GENERIC && {
689 chmod u-s -R $DIR/gns_test_2c
690 rm -fr $DIR/gns_test_2c
691 error "recursive mounting of dir as mount object works?"
694 chmod u-s $DIR/gns_test_2c
695 rm -fr $DIR/gns_test_2c
698 run_test 2c " odd conditions (mount object is recursive dir) ======="
701 local OBJECT=".mntinfo"
705 echo "setting up GNS timeouts and mount object..."
706 setup_gns $OBJECT $TIMOUT $TICK || error
708 echo "preparing mount object at $DIR/gns_test_2d/$OBJECT..."
709 mkdir -p $DIR/gns_test_2d
710 chmod u+s $DIR/gns_test_2d
713 echo "testing GNS with GENERIC upcall"
714 check_gns GENERIC $DIR/gns_test_2d $DIR/gns_test_2d $TIMOUT $TICK GENERIC && {
715 chmod u-s $DIR/gns_test_2d
716 rm -fr $DIR/gns_test_2d
717 error "mount point with absent mount object works?"
720 chmod u-s $DIR/gns_test_2d
721 rm -fr $DIR/gns_test_2d
724 run_test 2d " odd conditions (mount object is absent) =============="
727 local OBJECT=".mntinfo"
731 echo "setting up GNS timeouts and mount object..."
732 setup_gns $OBJECT $TIMOUT $TICK || error
734 echo "." > /proc/fs/lustre/llite/fs0/gns_object_name
735 test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x." &&
736 error "'.' is set as mount object name"
738 echo ".." > /proc/fs/lustre/llite/fs0/gns_object_name
739 test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x.." &&
740 error "'..' is set as mount object name"
742 echo ".a" > /proc/fs/lustre/llite/fs0/gns_object_name
743 test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x.a" ||
744 error "'.a' is not set as mount object name"
746 echo "..a" > /proc/fs/lustre/llite/fs0/gns_object_name
747 test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x..a" ||
748 error "'..a' is not set as mount object name"
751 run_test 2e " odd conditions ('.' and '..' as mount object) ============="
757 log "cleanup: ==========================================================="
758 if [ "`mount | grep ^$NAME`" ]; then
759 rm -rf $DIR/[Rdfs][1-9]*
760 if [ "$I_MOUNTED" = "yes" ]; then
761 sh llmountcleanup.sh || error
765 echo '=========================== finished ==============================='
766 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true