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 || {
217 chmod u-s $LOOP_MNTPT >/dev/null 2>&1
218 umount $LOOP_MNTPT >/dev/null 2>&1
219 losetup -d $LOOP_DEV >/dev/null 2>&1
220 rm -fr $LOOP_FILE >/dev/null 2>&1
221 rm -fr $LOOP_MNTPT >/dev/null 2>&1
228 dd if=/dev/zero of=$LOOP_FILE bs=1M count=10 2>/dev/null || return $?
230 losetup $LOOP_DEV $LOOP_FILE || {
232 cleanup_mount $LOOP_DEV $LOOP_FILE $DIR/gns_test_1a
236 mke2fs -F $LOOP_DEV >/dev/null 2>&1 || {
238 cleanup_mount $LOOP_DEV $LOOP_FILE $DIR/gns_test_1a
239 echo "cannot create test ext2 fs on $LOOP_DEV"
251 test "x$MODE" = "xDEADLOCK" &&
252 INJECTION="touch \$MNTPATH/file"
254 cat > $UPCALL <<- EOF
257 MOUNT=\`which mount 2>/dev/null\`
258 test "x\$MOUNT" = "x" && MOUNT="/bin/mount"
263 test "x\$OPTIONS" = "x" || "x\$MNTPATH" = "x" &&
267 \$MOUNT \$OPTIONS \$MNTPATH > $LOG 2>&1
275 local LOG="/tmp/gns-log"
283 rm -fr $LOG >/dev/null 2>&1
284 UPCALL_PATH="/tmp/gns-upcall-$UPCALL.sh"
286 echo "generating upcall $UPCALL_PATH"
287 prep_upcall $UPCALL_PATH $UPCALL $LOG || return $rc
288 echo "======================== upcall script ==========================="
289 cat $UPCALL_PATH 2>/dev/null || return $?
290 echo "=================================================================="
292 echo "$UPCALL_PATH" > /proc/fs/lustre/llite/fs0/gns_upcall || return $?
293 echo "upcall: $(cat /proc/fs/lustre/llite/fs0/gns_upcall)"
295 echo -n "mount on open $OBJECT/test_file1: "
296 echo -n "test data" > $OBJECT/test_file1 >/dev/null 2>&1 || return $?
298 local ENTRY="`basename $OBJECT`"
300 cat /proc/mounts | grep -q "$ENTRY" || {
303 echo "======================== upcall log ==========================="
305 echo "==============================================================="
307 echo "upcall log file $LOG is not found"
313 local sleep_time=$TIMOUT
314 let sleep_time+=$TICK*2
315 echo -n "waiting for umount ${sleep_time}s (timeout + tick*2): "
318 cat /proc/mounts | grep -q "$ENTRY" && {
327 local LOOP_DEV=$(find_free_loop 2>/dev/null)
328 local UPCALL="/tmp/gns-upcall.sh"
329 local LOOP_FILE="/tmp/gns_loop"
330 local OBJECT=".mntinfo"
334 test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
335 error "can't find free loop device"
337 echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
338 cleanup_loop $LOOP_DEV $LOOP_FILE $DIR/gns_test_1a
339 setup_loop $LOOP_DEV $LOOP_FILE || error
341 echo "setting up GNS timeouts and mount object..."
342 echo "$OBJECT" > /proc/fs/lustre/llite/fs0/gns_object_name || error
343 echo "$TIMOUT" > /proc/fs/lustre/llite/fs0/gns_timeout || error
344 echo "$TICK" > /proc/fs/lustre/llite/fs0/gns_tick || error
347 echo "timeout: $(cat /proc/fs/lustre/llite/fs0/gns_timeout)s"
348 echo "object: $(cat /proc/fs/lustre/llite/fs0/gns_object_name)"
349 echo "tick: $(cat /proc/fs/lustre/llite/fs0/gns_tick)s"
352 echo "preparing mount object at $DIR/gns_test_1a/$OBJECT..."
353 mkdir -p $DIR/gns_test_1a || error
354 echo -n "-t ext2 $LOOP_DEV" > $DIR/gns_test_1a/$OBJECT
355 echo "======================== mount object ==========================="
356 cat $DIR/gns_test_1a/$OBJECT
358 echo "================================================================="
359 chmod u+s $DIR/gns_test_1a || error
362 echo "testing GNS with GENERIC upcall 2 times on the row"
363 for ((i=0;i<2;i++)); do
364 check_gns GENERIC $DIR/gns_test_1a $TIMOUT $TICK || {
365 cleanup_loop $LOOP_DEV $LOOP_FILE $DIR/gns_test_1a
371 echo "testing GNS with DEADLOCK upcall 2 times on the row"
372 for ((i=0;i<2;i++)); do
373 check_gns DEADLOCK $DIR/gns_test_1a $TIMOUT $TICK || {
374 cleanup_loop $LOOP_DEV $LOOP_FILE $DIR/gns_test_1a
379 cleanup_loop $LOOP_DEV $LOOP_FILE $DIR/gns_test_1a
382 run_test 1a " general GNS test - mounting/umount ===================="
388 log "cleanup: ==========================================================="
389 if [ "`mount | grep ^$NAME`" ]; then
390 rm -rf $DIR/[Rdfs][1-9]*
391 if [ "$I_MOUNTED" = "yes" ]; then
392 sh llmountcleanup.sh || error
396 echo '=========================== finished ==============================='
397 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true