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 &
330 test "x$OBJECT2" = "x" && {
331 echo "not defined object2 for concurrent2 testing"
334 echo -n "mount on open $OBJECT1/test_file1: "
335 echo -n "mount on open $OBJECT2/test_file1: "
336 echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 &
337 echo -n "test data" > $OBJECT2/test_file1 >/dev/null 2>&1 &
347 echo -n "mount on open $OBJECT1/test_file1: "
352 for ((;i<$nr;i++)); do
353 touch $OBJECT1/file$i &
354 echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 &
355 mkdir $OBJECT1/dir$i &
366 echo "invalid testing mode $MODE"
370 local ENTRY1="`basename $OBJECT1`"
371 local ENTRY2="`basename $OBJECT2`"
373 cat /proc/mounts | grep -q "$ENTRY1" || {
379 if test "x$MODE" = "xCONCUR2"; then
380 cat /proc/mounts | grep -q "$ENTRY2" || {
389 local sleep_time=$TIMOUT
390 let sleep_time+=$TICK*2
391 echo -n "waiting for umount ${sleep_time}s (timeout + tick*2): "
394 cat /proc/mounts | grep -q "$ENTRY1" && {
399 if test "x$MODE" = "xCONCUR2"; then
400 cat /proc/mounts | grep -q "$ENTRY2" && {
407 cleanup_upcall $UPCALL_PATH
416 mkdir -p $OBJPATH || return $?
417 echo -n $CONTENT > $OBJPATH/$OBJECT || return $?
419 echo "======================== mount object ==========================="
422 echo "================================================================="
431 chmod u-s $OBJPATH >/dev/null 2>&1
432 umount $OBJPATH >/dev/null 2>&1
433 rm -fr $OBJPATH >/dev/null 2>&1
441 echo "$OBJECT" > /proc/fs/lustre/llite/fs0/gns_object_name || error
442 echo "$TIMOUT" > /proc/fs/lustre/llite/fs0/gns_timeout || error
443 echo "$TICK" > /proc/fs/lustre/llite/fs0/gns_tick || error
446 echo "timeout: $(cat /proc/fs/lustre/llite/fs0/gns_timeout)s"
447 echo "object: $(cat /proc/fs/lustre/llite/fs0/gns_object_name)"
448 echo "tick: $(cat /proc/fs/lustre/llite/fs0/gns_tick)s"
454 local LOOP_DEV=$(find_free_loop 2>/dev/null)
455 local LOOP_FILE="/tmp/gns_loop_1a"
456 local OBJECT=".mntinfo"
460 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
461 error "can't find free loop device"
463 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
464 cleanup_loop $LOOP_DEV $LOOP_FILE
465 setup_loop $LOOP_DEV $LOOP_FILE || error
467 echo "setting up GNS timeouts and mount object..."
468 setup_gns $OBJECT $TIMOUT $TICK || error
470 echo "preparing mount object at $DIR/gns_test_1a/$OBJECT..."
471 setup_object $DIR/gns_test_1a $OBJECT "-t ext2 $LOOP_DEV" || error
474 echo "testing GNS with GENERIC upcall 3 times on the row"
475 for ((i=0;i<3;i++)); do
476 check_gns GENERIC $DIR/gns_test_1a $DIR/gns_test_1a $TIMOUT $TICK GENERIC || {
477 cleanup_object $DIR/gns_test_1a
478 cleanup_loop $LOOP_DEV $LOOP_FILE
483 cleanup_object $DIR/gns_test_1a
484 cleanup_loop $LOOP_DEV $LOOP_FILE
487 run_test 1a " general GNS test - mount/umount (GENERIC) ================"
490 local LOOP_DEV=$(find_free_loop 2>/dev/null)
491 local LOOP_FILE="/tmp/gns_loop_1b"
492 local OBJECT=".mntinfo"
496 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
497 error "can't find free loop device"
499 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
500 cleanup_loop $LOOP_DEV $LOOP_FILE
501 setup_loop $LOOP_DEV $LOOP_FILE || error
503 echo "setting up GNS timeouts and mount object..."
504 setup_gns $OBJECT $TIMOUT $TICK || error
506 echo "preparing mount object at $DIR/gns_test_1b/$OBJECT..."
507 setup_object $DIR/gns_test_1b $OBJECT "-t ext2 $LOOP_DEV" || error
510 echo "testing GNS with DEADLOCK upcall 3 times on the row"
511 for ((i=0;i<3;i++)); do
512 check_gns DEADLOCK $DIR/gns_test_1b $DIR/gns_test_1b $TIMOUT $TICK GENERIC || {
513 cleanup_object $DIR/gns_test_1b
514 cleanup_loop $LOOP_DEV $LOOP_FILE
519 cleanup_object $DIR/gns_test_1b
520 cleanup_loop $LOOP_DEV $LOOP_FILE
523 run_test 1b " general GNS test - mount/umount (DEADLOCK) ==============="
526 local LOOP_DEV=$(find_free_loop 2>/dev/null)
527 local LOOP_FILE="/tmp/gns_loop_1c"
528 local OBJECT=".mntinfo"
532 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
533 error "can't find free loop device"
535 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
536 cleanup_loop $LOOP_DEV $LOOP_FILE
537 setup_loop $LOOP_DEV $LOOP_FILE || error
539 echo "setting up GNS timeouts and mount object..."
540 setup_gns $OBJECT $TIMOUT $TICK || error
542 echo "preparing mount object at $DIR/gns_test_1c/$OBJECT..."
543 setup_object $DIR/gns_test_1c $OBJECT "-t ext2 $LOOP_DEV" || error
546 echo "testing GNS with DEADLOCK upcall 4 times on the row"
552 test $(($i%2)) -eq 1 && MODE="DEADLOCK"
554 check_gns $MODE $DIR/gns_test_1c $DIR/gns_test_1c $TIMOUT $TICK GENERIC || {
555 cleanup_object $DIR/gns_test_1c
556 cleanup_loop $LOOP_DEV $LOOP_FILE
561 cleanup_object $DIR/gns_test_1c
562 cleanup_loop $LOOP_DEV $LOOP_FILE
565 run_test 1c " general GNS test - mount/umount (GENERIC/DEADLOCK) ========"
568 local LOOP_DEV=$(find_free_loop 2>/dev/null)
569 local LOOP_FILE="/tmp/gns_loop_1d"
570 local OBJECT=".mntinfo"
574 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
575 error "can't find free loop device"
577 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
578 cleanup_loop $LOOP_DEV $LOOP_FILE
579 setup_loop $LOOP_DEV $LOOP_FILE || error
581 echo "setting up GNS timeouts and mount object..."
582 setup_gns $OBJECT $TIMOUT $TICK || error
584 echo "preparing mount object at $DIR/gns_test_1d/$OBJECT..."
585 setup_object $DIR/gns_test_1d $OBJECT "-t ext2 $LOOP_DEV" || error
588 echo "testing GNS with GENERIC/DEADLOCK upcall 4 times on the row in CONCUR1 mode"
594 test $(($i%2)) -eq 1 && MODE="DEADLOCK"
596 check_gns $MODE $DIR/gns_test_1d $DIR/gns_test_1d $TIMOUT $TICK CONCUR1 || {
597 cleanup_object $DIR/gns_test_1d
598 cleanup_loop $LOOP_DEV $LOOP_FILE
603 cleanup_object $DIR/gns_test_1d
604 cleanup_loop $LOOP_DEV $LOOP_FILE
607 run_test 1d " general GNS test - concurrent mount ======================="
610 local LOOP_DEV=$(find_free_loop 2>/dev/null)
611 local LOOP_FILE="/tmp/gns_loop_1e"
612 local OBJECT=".mntinfo"
616 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
617 error "can't find free loop device"
619 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
620 cleanup_loop $LOOP_DEV $LOOP_FILE
621 setup_loop $LOOP_DEV $LOOP_FILE || error
623 echo "setting up GNS timeouts and mount object..."
624 setup_gns $OBJECT $TIMOUT $TICK || error
626 echo "preparing mount object at $DIR/gns_test_1e1/$OBJECT..."
627 setup_object $DIR/gns_test_1e1 $OBJECT "-t ext2 $LOOP_DEV" || error
629 echo "preparing mount object at $DIR/gns_test_1e2/$OBJECT..."
630 setup_object $DIR/gns_test_1e2 $OBJECT "-t ext2 $LOOP_DEV" || error
633 echo "testing GNS with GENERIC upcall in CONCUR2 mode"
634 check_gns GENERIC $DIR/gns_test_1e1 $DIR/gns_test_1e2 $TIMOUT $TICK CONCUR2 || {
635 cleanup_object $DIR/gns_test_1e1
636 cleanup_object $DIR/gns_test_1e2
637 cleanup_loop $LOOP_DEV $LOOP_FILE
641 cleanup_object $DIR/gns_test_1e1
642 cleanup_object $DIR/gns_test_1e2
643 cleanup_loop $LOOP_DEV $LOOP_FILE
646 run_test 1e " general GNS test - concurrent mount of 2 GNS mounts ======="
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_2a/$OBJECT..."
657 mkdir -p $DIR/gns_test_2a
658 ln -s $DIR/gns_test_2a $DIR/gns_test_2a/$OBJECT
659 chmod u+s $DIR/gns_test_2a
662 echo "testing GNS with GENERIC upcall"
663 check_gns GENERIC $DIR/gns_test_2a $DIR/gns_test_2a $TIMOUT $TICK GENERIC && {
664 chmod u-s $DIR/gns_test_2a
665 rm -fr $DIR/gns_test_2a
666 error "symlink as mount object works?"
669 chmod u-s $DIR/gns_test_2a
670 rm -fr $DIR/gns_test_2a
673 run_test 2a " odd conditions (mount object is symlink) ============="
676 local OBJECT=".mntinfo"
680 echo "setting up GNS timeouts and mount object..."
681 setup_gns $OBJECT $TIMOUT $TICK || error
683 echo "preparing mount object at $DIR/gns_test_2b/$OBJECT..."
684 mkdir -p $DIR/gns_test_2b/$OBJECT
685 chmod u+s $DIR/gns_test_2b
688 echo "testing GNS with GENERIC upcall"
689 check_gns GENERIC $DIR/gns_test_2b $DIR/gns_test_2b $TIMOUT $TICK GENERIC && {
690 chmod u-s $DIR/gns_test_2b
691 rm -fr $DIR/gns_test_2b
692 error "dir as mount object works?"
695 chmod u-s $DIR/gns_test_2b
696 rm -fr $DIR/gns_test_2b
699 run_test 2b " odd conditions (mount object is directory) ==========="
702 local OBJECT=".mntinfo"
706 echo "setting up GNS timeouts and mount object..."
707 setup_gns $OBJECT $TIMOUT $TICK || error
709 echo "preparing mount object at $DIR/gns_test_2c/$OBJECT..."
710 mkdir -p $DIR/gns_test_2c/$OBJECT/$OBJECT/$OBJECT/$OBJECT
711 chmod u+s -R $DIR/gns_test_2c
714 echo "testing GNS with GENERIC upcall"
715 check_gns GENERIC $DIR/gns_test_2c $DIR/gns_test_2c $TIMOUT $TICK GENERIC && {
716 chmod u-s -R $DIR/gns_test_2c
717 rm -fr $DIR/gns_test_2c
718 error "recursive mounting of dir as mount object works?"
721 chmod u-s $DIR/gns_test_2c
722 rm -fr $DIR/gns_test_2c
725 run_test 2c " odd conditions (mount object is recursive dir) ======="
728 local OBJECT=".mntinfo"
732 echo "setting up GNS timeouts and mount object..."
733 setup_gns $OBJECT $TIMOUT $TICK || error
735 echo "preparing mount object at $DIR/gns_test_2d/$OBJECT..."
736 mkdir -p $DIR/gns_test_2d
737 chmod u+s $DIR/gns_test_2d
740 echo "testing GNS with GENERIC upcall"
741 check_gns GENERIC $DIR/gns_test_2d $DIR/gns_test_2d $TIMOUT $TICK GENERIC && {
742 chmod u-s $DIR/gns_test_2d
743 rm -fr $DIR/gns_test_2d
744 error "mount point with absent mount object works?"
747 chmod u-s $DIR/gns_test_2d
748 rm -fr $DIR/gns_test_2d
751 run_test 2d " odd conditions (mount object is absent) =============="
754 local OBJECT=".mntinfo"
758 echo "setting up GNS timeouts and mount object..."
759 setup_gns $OBJECT $TIMOUT $TICK || error
761 echo "." > /proc/fs/lustre/llite/fs0/gns_object_name
762 test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x." &&
763 error "'.' is set as mount object name"
765 echo ".." > /proc/fs/lustre/llite/fs0/gns_object_name
766 test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x.." &&
767 error "'..' is set as mount object name"
769 echo ".a" > /proc/fs/lustre/llite/fs0/gns_object_name
770 test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x.a" ||
771 error "'.a' is not set as mount object name"
773 echo "..a" > /proc/fs/lustre/llite/fs0/gns_object_name
774 test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x..a" ||
775 error "'..a' is not set as mount object name"
778 run_test 2e " odd conditions ('.' and '..' as mount object) ============="
781 local LOOP_DEV=$(find_free_loop 2>/dev/null)
782 local LOOP_FILE="/tmp/gns_loop_3a"
783 local OBJECT=".mntinfo"
787 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
788 error "can't find free loop device"
790 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
791 cleanup_loop $LOOP_DEV $LOOP_FILE
792 setup_loop $LOOP_DEV $LOOP_FILE || error
794 echo "setting up GNS timeouts and mount object..."
795 setup_gns $OBJECT $TIMOUT $TICK || error
797 echo "preparing mount object at $DIR/gns_test_3a/$OBJECT..."
798 setup_object $DIR/gns_test_3a $OBJECT "-t ext2 $LOOP_DEV" || error
801 echo "testing GNS with DEADLOCK upcall in CONCUR3 mode"
803 local MODE="DEADLOCK"
805 check_gns $MODE $DIR/gns_test_3a $DIR/gns_test_3a $TIMOUT $TICK CONCUR3 || {
806 cleanup_object $DIR/gns_test_3a
807 cleanup_loop $LOOP_DEV $LOOP_FILE
811 cleanup_object $DIR/gns_test_3a
812 cleanup_loop $LOOP_DEV $LOOP_FILE
815 run_test 3a " odd conditions (mount point is modifying during mount) ===="
821 log "cleanup: ==========================================================="
822 if [ "`mount | grep ^$NAME`" ]; then
823 rm -rf $DIR/[Rdfs][1-9]*
824 if [ "$I_MOUNTED" = "yes" ]; then
825 sh llmountcleanup.sh || error
829 echo '=========================== finished ==============================='
830 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true