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}
27 if [ $UID -ne 0 ]; then
31 RUNAS_ID=${RUNAS_ID:-500}
32 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
39 sh llmountcleanup.sh > /dev/null || exit 20
46 sh llrmount.sh > /dev/null || exit 10
54 lctl mark "$*" 2> /dev/null || true
59 strace -o $TMP/$1.strace -ttt $*
61 log "FINISHED: $*: rc $RC"
67 if ! mount | grep -q $DIR1; then
71 log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)"
72 export TESTNAME=test_$1
73 test_$1 || error "test_$1: exit with rc=$?"
75 pass "($((`date +%s` - $BEFORE))s)"
82 if [ "`echo $1 | grep '\<'$O'[a-z]*\>'`" ]; then
90 for X in $EXCEPT $ALWAYS_EXCEPT; do
91 if [ "`echo $1 | grep '\<'$X'[a-z]*\>'`" ]; then
92 echo "skipping excluded test $1"
96 if [ -z "$ONLY" ]; then
102 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
105 log "FAIL: $TESTNAME $@"
106 if [ "$SANITYLOG" ]; then
107 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
117 export MOUNT1=`mount| awk '/ lustre/ { print $3 }'| head -n 1`
118 export MOUNT2=`mount| awk '/ lustre/ { print $3 }'| tail -n 1`
119 [ -z "$MOUNT1" ] && error "NAME=$NAME not mounted once"
120 [ "$MOUNT1" = "$MOUNT2" ] && error "NAME=$NAME not mounted twice"
121 [ `mount| awk '/ lustre/ { print $3 }'| wc -l` -ne 2 ] && \
122 error "NAME=$NAME mounted more than twice"
124 export DIR1=${DIR1:-$MOUNT1}
125 export DIR2=${DIR2:-$MOUNT2}
126 [ -z "`echo $DIR1 | grep $MOUNT1`" ] && echo "$DIR1 not in $MOUNT1" && exit 96
127 [ -z "`echo $DIR2 | grep $MOUNT2`" ] && echo "$DIR2 not in $MOUNT2" && exit 95
129 rm -rf $DIR1/[df][0-9]* $DIR1/lnk
133 [ -f $DIR2/f1 ] || error
135 run_test 1a "check create on 2 mtpt's =========================="
139 $CHECKSTAT -t file -p 0777 $DIR1/f1 || error
142 run_test 1b "check attribute updates on 2 mtpt's ==============="
145 $CHECKSTAT -t file -p 0666 $DIR1/f1 || error
147 run_test 1c "check after remount attribute updates on 2 mtpt's ="
151 $CHECKSTAT -a $DIR1/f1 || error
153 run_test 1d "unlink on one mountpoint removes file on other ===="
159 $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
161 run_test 2a "check cached attribute updates on 2 mtpt's ========"
167 $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
169 run_test 2b "check cached attribute updates on 2 mtpt's ========"
171 # NEED TO SAVE ROOT DIR MODE
174 $CHECKSTAT -t dir -p 0777 $DIR2 || error
176 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
180 $CHECKSTAT -t dir -p 0755 $DIR2 || error
182 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
185 ( cd $DIR1 ; ln -s this/is/good lnk )
186 [ "this/is/good" = "`perl -e 'print readlink("'$DIR2/lnk'");'`" ] || \
189 run_test 3 "symlink on one mtpt, readlink on another ==========="
192 multifstat $DIR1/f4 $DIR2/f4
194 run_test 4 "fstat validation on multiple mount points =========="
198 truncate $DIR2/f5 100
199 $CHECKSTAT -t file -s 100 $DIR1/f5 || error
202 run_test 5 "create a file on one mount, truncate it on the other"
205 openunlink $DIR1/f6 $DIR2/f6 || error
207 run_test 6 "remove of open file on other node =================="
210 opendirunlink $DIR1/d7 $DIR2/d7 || error
212 run_test 7 "remove of open directory on other node ============="
215 opendevunlink $DIR1/dev8 $DIR2/dev8 || error
217 run_test 8 "remove of open special file on other node =========="
222 for C in a b c d e f g h i j k l; do
223 DIR=`eval echo \\$DIR$MTPT`
224 echo -n $C >> $DIR/f9
225 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
227 [ "`cat $DIR1/f9`" = "abcdefghijkl" ] || \
228 error "`od -a $DIR1/f9` != abcdefghijkl"
230 run_test 9 "append of file with sub-page size on multiple mounts"
236 for C in a b c d e f g h i j k l; do
237 DIR=`eval echo \\$DIR$MTPT`
238 echo -n $C | dd of=$DIR/f10 bs=1 seek=$OFFSET count=1
239 [ "$MTPT" -eq 1 ] && MTPT=2 || MTPT=1
240 OFFSET=`expr $OFFSET + 1`
242 [ "`cat $DIR1/f10`" = "abcdefghijkl" ] || \
243 error "`od -a $DIR1/f10` != abcdefghijkl"
245 run_test 10a "write of file with sub-page size on multiple mounts "
248 yes "R" | dd of=$DIR1/f10b bs=3k count=1 || error "dd $DIR1"
250 truncate $DIR1/f10b 4096 || error "truncate 4096"
252 dd if=$DIR2/f10b of=$TMP/f10b-lustre bs=4k count=1 || error "dd $DIR2"
254 # create a test file locally to compare
255 yes "R" | dd of=$TMP/f10b bs=3k count=1 || error "dd random"
256 truncate $TMP/f10b 4096 || error "truncate 4096"
257 cmp $TMP/f10b $TMP/f10b-lustre || error "file miscompare"
259 run_test 10b "write of file with sub-page size on multiple mounts "
263 multiop $DIR1/d11/f O_c &
266 cp -p /bin/ls $DIR1/d11/f
270 wait $MULTIPID || error
271 [ $RC -eq 0 ] && error || true
273 run_test 11 "execution of file opened for write should return error ===="
278 run_test 12 "test lock ordering (link, stat, unlink) ==========="
280 test_13() { # bug 2451 - directory coherency
282 mkdir $DIR1/d13 || error
283 cd $DIR1/d13 || error
285 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
287 rm -f $DIR2/d13/f13 || error
288 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
289 # need to run it twice
290 ( touch $DIR1/d13/f13 ) # needs to be a separate shell
292 rm -f $DIR2/d13/f13 || error
293 ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
295 run_test 13 "test directory page revocation ===================="
299 cp -p /bin/ls $DIR1/d14/ls
300 exec 100>> $DIR1/d14/ls
301 $DIR2/d14/ls && error || true
304 run_test 14 "execution of file open for write returns -ETXTBSY ="
308 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
309 $DIR1/d14/multiop $TMP/test14.junk O_c &
312 multiop $DIR2/d14/multiop Oc && error "expected error, got success"
313 kill -USR1 $MULTIPID || return 2
314 wait $MULTIPID || return 3
316 run_test 14a "open(RDWR) of executing file returns -ETXTBSY ===="
318 test_14b() { # bug 3192
320 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
321 $DIR1/d14/multiop $TMP/test14.junk O_c &
324 truncate $DIR2/d14/multiop 0 && error "expected error, got success"
325 kill -USR1 $MULTIPID || return 2
326 wait $MULTIPID || return 3
328 run_test 14b "truncate of executing file returns -ETXTBSY ======"
330 test_14c() { # bug 3430
332 cp -p `which multiop` $DIR1/d14/multiop || error "cp failed"
333 $DIR1/d14/multiop $TMP/test14.junk O_c &
336 cp /etc/hosts $DIR2/d14/multiop && error "expected error, got success"
337 kill -USR1 $MULTIPID || return 2
338 wait $MULTIPID || return 3
339 #cmp `which multiop` $DIR1/d14/multiop || error "binary changed"
341 run_test 14c "open(O_TRUNC) of executing file return -ETXTBSY =="
343 test_15() { # bug 974 - ENOSPC
345 sh oos2.sh $MOUNT1 $MOUNT2
347 run_test 15 "test out-of-space with multiple writers ==========="
350 fsx -c 50 -p 100 -N 2500 $MOUNT1/fsxfile $MOUNT2/fsxfile
352 run_test 16 "2500 iterations of dual-mount fsx ================="
355 for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
356 echo clear > $d/lru_size
358 grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
361 test_17() { # bug 3513, 3667
362 [ ! -d /proc/fs/lustre/ost ] && echo "skipping OST-only test" && return
364 cp /etc/termcap $DIR1/f17
365 cancel_lru_locks OSC > /dev/null
366 #define OBD_FAIL_ONCE|OBD_FAIL_LDLM_CREATE_RESOURCE 0x30a
367 echo 0x8000030a > /proc/sys/lustre/fail_loc
368 ls -ls $DIR1/f17 | awk '{ print $1,$6 }' > $DIR1/f17-1 & \
369 ls -ls $DIR2/f17 | awk '{ print $1,$6 }' > $DIR2/f17-2
371 diff -u $DIR1/f17-1 $DIR2/f17-2 || error "files are different"
373 run_test 17 "resource creation/LVB creation race ==============="
376 ./mmap_sanity -d $MOUNT1 -m $MOUNT2
379 run_test 18 "mmap sanity check ================================="
381 test_19() { # bug 2441
385 setfattr -n trusted.name1 -v value1 $DIR1/f2b || error
386 [ "`getfattr -n trusted.name1 $DIR2/f2b 2> /dev/null | \
387 grep "trusted.name1"`" == "trusted.name1=\"value1\"" ] || error
389 setfattr -n user.author1 -v author1 $DIR/f2b || error
390 [ "`getfattr -n user.author1 $DIR/f2b 2> /dev/null | \
391 grep "user.author1"`" == "user.author1=\"author1\"" ] || error
394 setfattr -n trusted.name2 -v value2 $DIR2/f2b || error
395 setfattr -n trusted.name3 -v value3 $DIR1/f2b || error
396 [ `getfattr -d -m "^trusted" $DIR2/f2b 2> /dev/null | \
397 grep "trusted" | wc -l` -eq 5 ] || error
399 setfattr -n user.author2 -v author2 $DIR/f2b || error
400 setfattr -n user.author3 -v author3 $DIR/f2b || error
401 [ `getfattr -d -m "^user" $DIR/f2b 2> /dev/null | \
402 grep "user" | wc -l` -eq 3 ] || error
404 setfattr -x trusted.name1 $DIR2/f2b 2> /dev/null || error
405 getfattr -d -m trusted $DIR2/f2b 2> /dev/null | \
406 grep "trusted.name1" && error || true
408 setfattr -x user.author1 $DIR/f2b 2> /dev/null || error
409 getfattr -d -m user $DIR/f2b 2> /dev/null | \
410 grep "user.author1" && error || true
412 run_test 19 "test set/get xattr on multiple mounts ============"
415 log "cleanup: ======================================================"
416 rm -rf $DIR1/[df][0-9]* $DIR1/lnk || true
418 echo '=========================== finished ==============================='
419 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true