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"
285 rm -fr $LOG >/dev/null 2>&1
286 UPCALL_PATH="/tmp/gns-upcall-$UPCALL.sh"
288 echo "generating upcall $UPCALL_PATH"
289 setup_upcall $UPCALL_PATH $UPCALL $LOG || return $rc
290 echo "======================== upcall script ==========================="
291 cat $UPCALL_PATH 2>/dev/null || return $?
292 echo "=================================================================="
294 echo "$UPCALL_PATH" > /proc/fs/lustre/llite/fs0/gns_upcall || return $?
295 echo "upcall: $(cat /proc/fs/lustre/llite/fs0/gns_upcall)"
297 test "x$MODE" = "xGENERIC" && {
298 echo -n "mount on open $OBJECT/test_file1 (generic): "
300 echo -n "test data" > $OBJECT/test_file1 >/dev/null 2>&1 || return $?
305 echo -n "mount on open $OBJECT/test_file1 ($nr threads): "
307 for ((;i<=$nr;i++)); do
308 echo -n "test data" > $OBJECT/test_file$i >/dev/null 2>&1 &
314 local ENTRY="`basename $OBJECT`"
316 cat /proc/mounts | grep -q "$ENTRY" || {
319 echo "======================== upcall log ==========================="
321 echo "==============================================================="
323 echo "upcall log file $LOG is not found"
325 cleanup_upcall $UPCALL_PATH
330 local sleep_time=$TIMOUT
331 let sleep_time+=$TICK*2
332 echo -n "waiting for umount ${sleep_time}s (timeout + tick*2): "
335 cat /proc/mounts | grep -q "$ENTRY" && {
337 cleanup_upcall $UPCALL_PATH
341 cleanup_upcall $UPCALL_PATH
350 mkdir -p $OBJPATH || return $?
351 echo -n $CONTENT > $OBJPATH/$OBJECT || return $?
353 echo "======================== mount object ==========================="
356 echo "================================================================="
365 chmod u-s $OBJPATH >/dev/null 2>&1
366 umount $OBJPATH >/dev/null 2>&1
367 rm -fr $OBJPATH >/dev/null 2>&1
375 echo "$OBJECT" > /proc/fs/lustre/llite/fs0/gns_object_name || error
376 echo "$TIMOUT" > /proc/fs/lustre/llite/fs0/gns_timeout || error
377 echo "$TICK" > /proc/fs/lustre/llite/fs0/gns_tick || error
380 echo "timeout: $(cat /proc/fs/lustre/llite/fs0/gns_timeout)s"
381 echo "object: $(cat /proc/fs/lustre/llite/fs0/gns_object_name)"
382 echo "tick: $(cat /proc/fs/lustre/llite/fs0/gns_tick)s"
388 local LOOP_DEV=$(find_free_loop 2>/dev/null)
389 local UPCALL="/tmp/gns-upcall.sh"
390 local LOOP_FILE="/tmp/gns_loop_1a"
391 local OBJECT=".mntinfo"
395 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
396 error "can't find free loop device"
398 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
399 cleanup_loop $LOOP_DEV $LOOP_FILE
400 setup_loop $LOOP_DEV $LOOP_FILE || error
402 echo "setting up GNS timeouts and mount object..."
403 setup_gns $OBJECT $TIMOUT $TICK || error
405 echo "preparing mount object at $DIR/gns_test_1a/$OBJECT..."
406 setup_object $DIR/gns_test_1a $OBJECT "-t ext2 $LOOP_DEV" || error
409 echo "testing GNS with GENERIC upcall 3 times on the row"
410 for ((i=0;i<3;i++)); do
411 check_gns GENERIC $DIR/gns_test_1a $TIMOUT $TICK GENERIC || {
412 cleanup_object $DIR/gns_test_1a
413 cleanup_loop $LOOP_DEV $LOOP_FILE
418 cleanup_object $DIR/gns_test_1a
419 cleanup_loop $LOOP_DEV $LOOP_FILE
422 run_test 1a " general GNS test - mount/umount (GENERIC) ================"
425 local LOOP_DEV=$(find_free_loop 2>/dev/null)
426 local UPCALL="/tmp/gns-upcall.sh"
427 local LOOP_FILE="/tmp/gns_loop_2a"
428 local OBJECT=".mntinfo"
432 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
433 error "can't find free loop device"
435 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
436 cleanup_loop $LOOP_DEV $LOOP_FILE
437 setup_loop $LOOP_DEV $LOOP_FILE || error
439 echo "setting up GNS timeouts and mount object..."
440 setup_gns $OBJECT $TIMOUT $TICK || error
442 echo "preparing mount object at $DIR/gns_test_2a/$OBJECT..."
443 setup_object $DIR/gns_test_2a $OBJECT "-t ext2 $LOOP_DEV" || error
446 echo "testing GNS with DEADLOCK upcall 3 times on the row"
447 for ((i=0;i<3;i++)); do
448 check_gns DEADLOCK $DIR/gns_test_2a $TIMOUT $TICK GENERIC || {
449 cleanup_object $DIR/gns_test_2a
450 cleanup_loop $LOOP_DEV $LOOP_FILE
455 cleanup_object $DIR/gns_test_2a
456 cleanup_loop $LOOP_DEV $LOOP_FILE
459 run_test 2a " general GNS test - mount/umount (DEADLOCK) ==============="
462 local LOOP_DEV=$(find_free_loop 2>/dev/null)
463 local UPCALL="/tmp/gns-upcall.sh"
464 local LOOP_FILE="/tmp/gns_loop_3a"
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_3a/$OBJECT..."
480 setup_object $DIR/gns_test_3a $OBJECT "-t ext2 $LOOP_DEV" || error
483 echo "testing GNS with DEADLOCK upcall 4 times on the row"
489 test $(($i%2)) -eq 1 && MODE="DEADLOCK"
491 check_gns $MODE $DIR/gns_test_3a $TIMOUT $TICK GENERIC || {
492 cleanup_object $DIR/gns_test_3a
493 cleanup_loop $LOOP_DEV $LOOP_FILE
498 cleanup_object $DIR/gns_test_3a
499 cleanup_loop $LOOP_DEV $LOOP_FILE
502 run_test 3a " general GNS test - mount/umount (GENERIC/DEADLOCK) ========"
505 local LOOP_DEV=$(find_free_loop 2>/dev/null)
506 local UPCALL="/tmp/gns-upcall.sh"
507 local LOOP_FILE="/tmp/gns_loop_4a"
508 local OBJECT=".mntinfo"
512 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
513 error "can't find free loop device"
515 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
516 cleanup_loop $LOOP_DEV $LOOP_FILE
517 setup_loop $LOOP_DEV $LOOP_FILE || error
519 echo "setting up GNS timeouts and mount object..."
520 setup_gns $OBJECT $TIMOUT $TICK || error
522 echo "preparing mount object at $DIR/gns_test_4a/$OBJECT..."
523 setup_object $DIR/gns_test_4a $OBJECT "-t ext2 $LOOP_DEV" || error
526 echo "testing GNS with DEADLOCK upcall 4 times on the row"
532 test $(($i%2)) -eq 1 && MODE="DEADLOCK"
534 check_gns $MODE $DIR/gns_test_4a $TIMOUT $TICK CONCURRENT || {
535 cleanup_object $DIR/gns_test_4a
536 cleanup_loop $LOOP_DEV $LOOP_FILE
541 cleanup_object $DIR/gns_test_4a
542 cleanup_loop $LOOP_DEV $LOOP_FILE
545 run_test 4a " general GNS test - concurrent mount ======================="
548 echo "Not implemented yet!"
551 run_test 5a " general GNS test - concurrent mount of 2 GNS mounts ======="
557 log "cleanup: ==========================================================="
558 if [ "`mount | grep ^$NAME`" ]; then
559 rm -rf $DIR/[Rdfs][1-9]*
560 if [ "$I_MOUNTED" = "yes" ]; then
561 sh llmountcleanup.sh || error
565 echo '=========================== finished ==============================='
566 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true