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 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
37 if [ `using_krb5_sec $SECURITY` == 'y' ] ; then
38 start_krb5_kdc || exit 1
39 if [ $RUNAS_ID -ne $UID ]; then
40 $RUNAS ./krb5_refresh_cache.sh || exit 2
48 sh llmountcleanup.sh > /dev/null || exit 20
55 sh llrmount.sh > /dev/null || exit 10
63 lctl mark "$*" 2> /dev/null || true
68 strace -o $TMP/$1.strace -ttt $*
70 log "FINISHED: $*: rc $RC"
76 if ! mount | grep -q $DIR1; then
80 log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)"
81 export TESTNAME=test_$1
82 test_$1 || error "test_$1: exit with rc=$?"
84 pass "($((`date +%s` - $BEFORE))s)"
91 if [ "`echo $1 | grep '\<'$O'[a-z]*\>'`" ]; then
99 for X in $EXCEPT $ALWAYS_EXCEPT; do
100 if [ "`echo $1 | grep '\<'$X'[a-z]*\>'`" ]; then
101 echo "skipping excluded test $1"
105 if [ -z "$ONLY" ]; then
111 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
114 log "FAIL: $TESTNAME $@"
115 if [ "$SANITYLOG" ]; then
116 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
126 export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -n 1`
127 export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -n 1`
128 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
129 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
130 [ `mount| awk '/ lustre/ { print $3 }'| wc -l` -ne 2 ] && \
131 error "NAME=$NAME mounted more than twice"
133 export DIR1=${DIR1:-$MOUNT1}
134 export DIR2=${DIR2:-$MOUNT2}
135 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
136 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
138 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
142 [ -f $DIR2/f1 ] || error
144 run_test 1a "check create on 2 mtpt's =========================="
148 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
151 run_test 1b "check attribute updates on 2 mtpt's ==============="
154 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
156 run_test 1c "check after remount attribute updates on 2 mtpt's ="
160 $CHECKSTAT -a $DIR1/f1 || error
162 run_test 1d "unlink on one mountpoint removes file on other ===="
168 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
170 run_test 2a "check cached attribute updates on 2 mtpt's ========"
176 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
178 run_test 2b "check cached attribute updates on 2 mtpt's ========"
180 # NEED TO SAVE ROOT DIR MODE
183 $CHECKSTAT -t dir -p 0777 $DIR2 || error
185 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
189 $CHECKSTAT -t dir -p 0755 $DIR2 || error
191 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
194 ( cd $DIR1 ; ln -s this/is/good lnk )
195 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
198 run_test 3 "symlink on one mtpt, readlink on another ==========="
201 multifstat $DIR1/f4 $DIR2/f4
203 run_test 4 "fstat validation on multiple mount points =========="
207 truncate $DIR2/f5 100
208 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
211 run_test 5 "create a file on one mount, truncate it on the other"
214 openunlink $DIR1/f6 $DIR2/f6 || error
216 run_test 6 "remove of open file on other node =================="
219 opendirunlink $DIR1/d7 $DIR2/d7 || error
221 run_test 7 "remove of open directory on other node ============="
224 opendevunlink $DIR1/dev8 $DIR2/dev8 || error
226 run_test 8 "remove of open special file on other node =========="
231 for C in a b c d e f g h i j k l; do
232 DIR=`eval echo \\$DIR$MTPT`
233 echo -n $C >> $DIR/f9
234 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
236 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
237 error "`od -a $DIR1/f9` != abcdefghijkl"
239 run_test 9 "append of file with sub-page size on multiple mounts"
245 for C in a b c d e f g h i j k l; do
246 DIR=`eval echo \\$DIR$MTPT`
247 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
248 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
249 OFFSET=`expr $OFFSET + 1`
251 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
252 error "`od -a $DIR1/f10` != abcdefghijkl"
254 run_test 10a "write of file with sub-page size on multiple mounts "
257 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
259 truncate $DIR1/f10b 4096 || error "truncate 4096"
261 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
263 # create a test file locally to compare
264 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
265 truncate $TMP/f10b 4096 || error "truncate 4096"
266 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
268 run_test 10b "write of file with sub-page size on multiple mounts "
272 multiop $DIR1/d11/f O_c &
275 cp -p /bin/ls $DIR1/d11/f
279 wait $MULTIPID || error
280 [ $RC -eq 0 ] && error || true
282 run_test 11 "execution of file opened for write should return error ===="
287 run_test 12 "test lock ordering (link, stat, unlink) ==========="
289 test_13() { # bug 2451 - directory coherency
291 mkdir $DIR1/d13 || error
292 cd $DIR1/d13 || error
294 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
296 rm -f $DIR2/d13/f13 || error
297 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
298 # need to run it twice
299 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
301 rm -f $DIR2/d13/f13 || error
302 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
304 run_test 13 "test directory page revocation ===================="
308 cp -p /bin/ls $DIR1/d14/ls
309 exec 100>> $DIR1/d14/ls
310 $DIR2/d14/ls && error || true
313 run_test 14 "execution of file open for write returns -ETXTBSY ="
317 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
318 $DIR1/d14/multiop $TMP/test14.junk O_c &
321 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
322 kill -USR1 $MULTIPID || return 2
323 wait $MULTIPID || return 3
325 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
327 test_14b() { # bug 3192
329 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
330 $DIR1/d14/multiop $TMP/test14.junk O_c &
333 truncate $DIR2/d14/multiop 0 && error "expected error, got success"
334 kill -USR1 $MULTIPID || return 2
335 wait $MULTIPID || return 3
337 run_test 14b "truncate of executing file returns -ETXTBSY ======"
339 test_14c() { # bug 3430
341 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
342 $DIR1/d14/multiop $TMP/test14.junk O_c &
345 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
346 kill -USR1 $MULTIPID || return 2
347 wait $MULTIPID || return 3
348 #cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
350 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
352 test_15() { # bug 974 - ENOSPC
354 sh oos2.sh $MOUNT1 $MOUNT2
356 run_test 15 "test out-of-space with multiple writers ==========="
359 fsx -c 50 -p 100 -N 2500 $MOUNT1/fsxfile $MOUNT2/fsxfile
361 run_test 16 "2500 iterations of dual-mount fsx ================="
364 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
365 echo clear > $d/lru_size
367 grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
370 test_17() { # bug 3513, 3667
371 [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
373 cp /etc/termcap $DIR1/f17
374 cancel_lru_locks OSC > /dev/null
375 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
376 echo 0x8000030a > /proc/sys/lustre/fail_loc
377 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
378 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
380 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
382 run_test 17 "resource creation/LVB creation race ==============="
385 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
388 run_test 18 "mmap sanity check ================================="
390 test_19() { # bug 2441
394 setfattr -n trusted.name1 -v value1 $DIR1/f2b || error
395 [ "`getfattr -n trusted.name1 $DIR2/f2b 2> /dev/null | \
396 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
398 setfattr -n user.author1 -v author1 $DIR/f2b || error
399 [ "`getfattr -n user.author1 $DIR/f2b 2> /dev/null | \
400 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
403 setfattr -n trusted.name2 -v value2 $DIR2/f2b || error
404 setfattr -n trusted.name3 -v value3 $DIR1/f2b || error
405 [ `getfattr -d -m "^trusted" $DIR2/f2b 2> /dev/null | \
406 grep "trusted" | wc -l` -eq 5 ] || error
408 setfattr -n user.author2 -v author2 $DIR/f2b || error
409 setfattr -n user.author3 -v author3 $DIR/f2b || error
410 [ `getfattr -d -m "^user" $DIR/f2b 2> /dev/null | \
411 grep "user" | wc -l` -eq 3 ] || error
413 setfattr -x trusted.name1 $DIR2/f2b 2> /dev/null || error
414 getfattr -d -m trusted $DIR2/f2b 2> /dev/null | \
415 grep "trusted.name1" && error || true
417 setfattr -x user.author1 $DIR/f2b 2> /dev/null || error
418 getfattr -d -m user $DIR/f2b 2> /dev/null | \
419 grep "user.author1" && error || true
421 run_test 19 "test set/get xattr on multiple mounts ============"
424 log "cleanup: ======================================================"
425 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
427 echo '=========================== finished ==============================='
428 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true