6 # bug number for skipped test: 1768 3192 3192
7 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"4 14b 14c"}
8 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
10 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
13 PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
15 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
16 CREATETEST=${CREATETEST:-createtest}
18 LSTRIPE=${LSTRIPE:-lstripe}
20 MCREATE=${MCREATE:-mcreate}
21 OPENFILE=${OPENFILE:-openfile}
22 OPENUNLINK=${OPENUNLINK:-openunlink}
23 TOEXCL=${TOEXCL:-toexcl}
24 TRUNCATE=${TRUNCATE:-truncate}
25 export TMP=${TMP:-/tmp}
29 if [ $UID -ne 0 ]; then
33 RUNAS_ID=${RUNAS_ID:-500}
34 if [ -z "$RUNAS_GID" ]; then
35 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
37 RUNAS=${RUNAS:-"runas -u $RUNAS_ID -g $RUNAS_GID"}
41 if [ `using_krb5_sec $SECURITY` == 'y' ] ; then
42 start_krb5_kdc || exit 1
43 if [ $RUNAS_ID -ne $UID ]; then
44 $RUNAS ./krb5_refresh_cache.sh || exit 2
52 sh llmountcleanup.sh > /dev/null || exit 20
59 sh llrmount.sh > /dev/null || exit 10
67 lctl mark "$*" 2> /dev/null || true
72 strace -o $TMP/$1.strace -ttt $*
74 log "FINISHED: $*: rc $RC"
80 if ! mount | grep -q $DIR1; then
84 log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)"
85 export TESTNAME=test_$1
86 test_$1 || error "test_$1: exit with rc=$?"
88 pass "($((`date +%s` - $BEFORE))s)"
95 if [ "`echo $1 | grep '\<'$O'[a-z]*\>'`" ]; then
103 for X in $EXCEPT $ALWAYS_EXCEPT; do
104 if [ "`echo $1 | grep '\<'$X'[a-z]*\>'`" ]; then
105 echo "skipping excluded test $1"
109 if [ -z "$ONLY" ]; then
115 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
118 log "FAIL: $TESTNAME $@"
119 if [ "$SANITYLOG" ]; then
120 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
130 export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -n 1`
131 export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -n 1`
132 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
133 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
134 [ `mount| awk '/ lustre/ { print $3 }'| wc -l` -ne 2 ] && \
135 error "NAME=$NAME mounted more than twice"
137 export DIR1=${DIR1:-$MOUNT1}
138 export DIR2=${DIR2:-$MOUNT2}
139 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
140 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
142 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
146 [ -f $DIR2/f1 ] || error
148 run_test 1a "check create on 2 mtpt's =========================="
152 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
155 run_test 1b "check attribute updates on 2 mtpt's ==============="
158 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
160 run_test 1c "check after remount attribute updates on 2 mtpt's ="
164 $CHECKSTAT -a $DIR1/f1 || error
166 run_test 1d "unlink on one mountpoint removes file on other ===="
172 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
174 run_test 2a "check cached attribute updates on 2 mtpt's ========"
180 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
182 run_test 2b "check cached attribute updates on 2 mtpt's ========"
184 # NEED TO SAVE ROOT DIR MODE
187 $CHECKSTAT -t dir -p 0777 $DIR2 || error
189 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
193 $CHECKSTAT -t dir -p 0755 $DIR2 || error
195 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
198 ( cd $DIR1 ; ln -s this/is/good lnk )
199 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
202 run_test 3 "symlink on one mtpt, readlink on another ==========="
205 multifstat $DIR1/f4 $DIR2/f4
207 run_test 4 "fstat validation on multiple mount points =========="
211 truncate $DIR2/f5 100
212 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
215 run_test 5 "create a file on one mount, truncate it on the other"
218 openunlink $DIR1/f6 $DIR2/f6 || error
220 run_test 6 "remove of open file on other node =================="
223 opendirunlink $DIR1/d7 $DIR2/d7 || error
225 run_test 7 "remove of open directory on other node ============="
228 opendevunlink $DIR1/dev8 $DIR2/dev8 || error
230 run_test 8 "remove of open special file on other node =========="
235 for C in a b c d e f g h i j k l; do
236 DIR=`eval echo \\$DIR$MTPT`
237 echo -n $C >> $DIR/f9
238 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
240 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
241 error "`od -a $DIR1/f9` != abcdefghijkl"
243 run_test 9 "append of file with sub-page size on multiple mounts"
249 for C in a b c d e f g h i j k l; do
250 DIR=`eval echo \\$DIR$MTPT`
251 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
252 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
253 OFFSET=`expr $OFFSET + 1`
255 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
256 error "`od -a $DIR1/f10` != abcdefghijkl"
258 run_test 10a "write of file with sub-page size on multiple mounts "
261 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
263 truncate $DIR1/f10b 4096 || error "truncate 4096"
265 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
267 # create a test file locally to compare
268 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
269 truncate $TMP/f10b 4096 || error "truncate 4096"
270 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
272 run_test 10b "write of file with sub-page size on multiple mounts "
276 multiop $DIR1/d11/f O_c &
279 cp -p /bin/ls $DIR1/d11/f
283 wait $MULTIPID || error
284 [ $RC -eq 0 ] && error || true
286 run_test 11 "execution of file opened for write should return error ===="
291 run_test 12 "test lock ordering (link, stat, unlink) ==========="
293 test_13() { # bug 2451 - directory coherency
295 mkdir $DIR1/d13 || error
296 cd $DIR1/d13 || error
298 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
300 rm -f $DIR2/d13/f13 || error
301 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
302 # need to run it twice
303 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
305 rm -f $DIR2/d13/f13 || error
306 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
308 run_test 13 "test directory page revocation ===================="
312 cp -p /bin/ls $DIR1/d14/ls
313 exec 100>> $DIR1/d14/ls
314 $DIR2/d14/ls && error || true
317 run_test 14 "execution of file open for write returns -ETXTBSY ="
321 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
323 $DIR1/d14/multiop $TMP/test14.junk O_c &
326 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
327 kill -USR1 $MULTIPID || return 2
328 wait $MULTIPID || return 3
330 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
332 test_14b() { # bug 3192
334 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
335 $DIR1/d14/multiop $TMP/test14.junk O_c &
338 truncate $DIR2/d14/multiop 0 && error "expected error, got success"
339 kill -USR1 $MULTIPID || return 2
340 wait $MULTIPID || return 3
342 run_test 14b "truncate of executing file returns -ETXTBSY ======"
344 test_14c() { # bug 3430
346 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
347 $DIR1/d14/multiop $TMP/test14.junk O_c &
350 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
351 kill -USR1 $MULTIPID || return 2
352 wait $MULTIPID || return 3
353 #cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
355 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
357 test_15() { # bug 974 - ENOSPC
359 sh oos2.sh $MOUNT1 $MOUNT2
361 run_test 15 "test out-of-space with multiple writers ==========="
364 fsx -c 50 -p 100 -N 2500 $MOUNT1/fsxfile $MOUNT2/fsxfile
366 run_test 16 "2500 iterations of dual-mount fsx ================="
369 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
370 echo clear > $d/lru_size
372 grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
375 test_17() { # bug 3513, 3667
376 [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
378 cp /etc/termcap $DIR1/f17
379 cancel_lru_locks OSC > /dev/null
380 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
381 echo 0x8000030a > /proc/sys/lustre/fail_loc
382 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
383 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
385 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
387 run_test 17 "resource creation/LVB creation race ==============="
390 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
393 run_test 18 "mmap sanity check ================================="
395 test_19() { # bug 2441
399 setfattr -n trusted.name1 -v value1 $DIR1/f2b || error
400 [ "`getfattr -n trusted.name1 $DIR2/f2b 2> /dev/null | \
401 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
403 setfattr -n user.author1 -v author1 $DIR/f2b || error
404 [ "`getfattr -n user.author1 $DIR/f2b 2> /dev/null | \
405 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
408 setfattr -n trusted.name2 -v value2 $DIR2/f2b || error
409 setfattr -n trusted.name3 -v value3 $DIR1/f2b || error
410 [ `getfattr -d -m "^trusted" $DIR2/f2b 2> /dev/null | \
411 grep "trusted" | wc -l` -eq 6 ] || error
413 setfattr -n user.author2 -v author2 $DIR/f2b || error
414 setfattr -n user.author3 -v author3 $DIR/f2b || error
415 [ `getfattr -d -m "^user" $DIR/f2b 2> /dev/null | \
416 grep "user" | wc -l` -eq 3 ] || error
418 setfattr -x trusted.name1 $DIR2/f2b 2> /dev/null || error
419 getfattr -d -m trusted $DIR2/f2b 2> /dev/null | \
420 grep "trusted.name1" && error || true
422 setfattr -x user.author1 $DIR/f2b 2> /dev/null || error
423 getfattr -d -m user $DIR/f2b 2> /dev/null | \
424 grep "user.author1" && error || true
426 run_test 19 "test set/get xattr on multiple mounts ============"
429 log "cleanup: ======================================================"
430 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
432 echo '=========================== finished ==============================='
433 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true