6 PATH=$SRCDIR:$SRCDIR/../utils:$PATH
8 CHECKSTAT=${CHECKSTAT:-"./checkstat -v"}
9 CREATETEST=${CREATETEST:-createtest}
11 LSTRIPE=${LSTRIPE:-lstripe}
12 MCREATE=${MCREATE:-mcreate}
13 TOEXCL=${TOEXCL:-toexcl}
15 RUNAS_ID=${RUNAS_ID:-500}
16 RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
18 MOUNT=${MOUNT:-/mnt/lustre}
23 sh llmountcleanup.sh > /dev/null || exit 20
28 sh llrmount.sh > /dev/null || exit 10
47 mount | grep $MOUNT || sh llmount.sh
49 log '== touch .../f ; rm .../f ======================== test 0'
51 $CHECKSTAT -t file $DIR/f || error
53 $CHECKSTAT -a $DIR/f || error
58 log '== mkdir .../d1; mkdir .../d1/d2 ================= test 1'
61 $CHECKSTAT -t dir $DIR/d1/d2 || error
66 log '== rmdir .../d1/d2; rmdir .../d1 ================= test 1b'
69 $CHECKSTAT -a $DIR/d1 || error
74 log '== mkdir .../d2; touch .../d2/f ================== test 2'
77 $CHECKSTAT -t file $DIR/d2/f || error
82 log '== rm -r .../d2; touch .../d2/f ================== test 2b'
84 $CHECKSTAT -a $DIR/d2 || error
89 log '== mkdir .../d3 ================================== test 3'
91 $CHECKSTAT -t dir $DIR/d3 || error
95 log '== touch .../d3/f ================================ test 3b'
97 $CHECKSTAT -t file $DIR/d3/f || error
101 log '== rm -r .../d3 ================================== test 3c'
103 $CHECKSTAT -a $DIR/d3 || error
108 log '== mkdir .../d4 ================================== test 4'
110 $CHECKSTAT -t dir $DIR/d4 || error
114 log '== mkdir .../d4/d2 =============================== test 4b'
116 $CHECKSTAT -t dir $DIR/d4/d2 || error
121 log '== mkdir .../d5; mkdir .../d5/d2; chmod .../d5/d2 = test 5'
124 chmod 0707 $DIR/d5/d2
125 $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
130 log '== touch .../f6; chmod .../f6 ==================== test 6'
133 $CHECKSTAT -t file -p 0666 $DIR/f6 || error
138 log '== mkdir .../d7; mcreate .../d7/f; chmod .../d7/f = test 7'
142 $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
147 log '== mkdir .../d7; mcreate .../d7/f2; echo foo > .../d7/f2 = test 7b'
149 echo -n foo > $DIR/d7/f2
150 [ "`cat $DIR/d7/f2`" = "foo" ] || error
151 $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
156 log '== mkdir .../d8; touch .../d8/f; chmod .../d8/f == test 8'
160 $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
166 log '== mkdir .../d9 .../d9/d2 .../d9/d2/d3 =========== test 9'
170 $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
176 log '== mkdir .../d10 .../d10/d2; touch .../d10/d2/f = test 10'
180 $CHECKSTAT -t file $DIR/d10/d2/f || error
185 log '== mkdir .../d11 d11/d2; chmod .../d11/d2 ======= test 11'
188 chmod 0666 $DIR/d11/d2
189 chmod 0705 $DIR/d11/d2
190 $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
195 log '== mkdir .../d12; touch .../d12/f; chmod .../d12/f == test 12'
198 chmod 0666 $DIR/d12/f
199 chmod 0654 $DIR/d12/f
200 $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
205 log '== mkdir .../d13; creat .../d13/f; .../d13/f; > .../d13/f == test 13'
207 dd if=/dev/zero of=$DIR/d13/f count=10
209 $CHECKSTAT -t file -s 0 $DIR/d13/f || error
214 log '================================================== test 14'
218 $CHECKSTAT -a $DIR/d14/f || error
223 log '================================================== test 15'
226 mv $DIR/d15/f $DIR/d15/f2
227 $CHECKSTAT -t file $DIR/d15/f2 || error
232 log '================================================== test 16'
236 $CHECKSTAT -a $DIR/d16/f || error
241 log '== symlinks: create, remove (dangling and real) == test 17'
244 ln -s $DIR/d17/f $DIR/d17/l-exist
245 ln -s no-such-file $DIR/d17/l-dangle
247 $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
248 $CHECKSTAT -f -t f $DIR/d17/l-exist || error
249 $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
250 $CHECKSTAT -fa $DIR/d17/l-dangle || error
253 $CHECKSTAT -a $DIR/l-dangle || error
254 $CHECKSTAT -a $DIR/l-exist || error
259 log "== touch .../f ; ls ... ========================= test 18"
266 log "== touch .../f ; ls -l ... ====================== test 19"
270 $CHECKSTAT -a $DIR/f || error
275 log "== touch .../f ; ls -l ... ====================== test 20"
285 $CHECKSTAT -a $DIR/f || error
290 log '== write to dangling link ======================== test 21'
292 [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
293 ln -s dangle $DIR/d21/link
294 echo foo >> $DIR/d21/link
296 $CHECKSTAT -t link $DIR/d21/link || error
297 $CHECKSTAT -f -t file $DIR/d21/link || error
302 log '== unpack tar archive as non-root user =========== test 22'
304 [ $UID -ne 0 ] && RUNAS=""
305 [ $UID -ne 0 ] && RUNAS_ID="$UID"
306 chown $RUNAS_ID $DIR/d22
307 $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | $RUNAS tar xfC - $DIR/d22
309 $CHECKSTAT -t dir $DIR/d22/etc || error
310 $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/etc || error
316 log '== O_CREAT|O_EXCL in subdir ====================== test 23'
319 $TOEXCL -e $DIR/d23/f23 || error
324 echo '== rename sanity ================================= test24'
325 echo '-- same directory rename'
326 log '-- test 24-R1: touch a ; rename a b'
329 mv $DIR/R1/f $DIR/R1/g
330 $CHECKSTAT -t file $DIR/R1/g || error
335 log '-- test 24-R2: touch a b ; rename a b;'
338 mv $DIR/R2/f $DIR/R2/g
339 $CHECKSTAT -a $DIR/R2/f || error
340 $CHECKSTAT -t file $DIR/R2/g || error
345 log '-- test 24-R3: mkdir a ; rename a b;'
348 mv $DIR/R3/f $DIR/R3/g
349 $CHECKSTAT -a $DIR/R3/f || error
350 $CHECKSTAT -t dir $DIR/R3/g || error
355 log '-- test 24-R4: mkdir a b ; rename a b;'
358 perl -e "rename \"$DIR/R4/f\", \"$DIR/R4/g\";"
359 $CHECKSTAT -a $DIR/R4/f || error
360 $CHECKSTAT -t dir $DIR/R4/g || error
365 echo '-- cross directory renames --'
366 log '-- test 24-R5: touch a ; rename a b'
369 mv $DIR/R5a/f $DIR/R5b/g
370 $CHECKSTAT -a $DIR/R5a/f || error
371 $CHECKSTAT -t file $DIR/R5b/g || error
376 log '-- test 24-R6: touch a ; rename a b'
378 touch $DIR/R6a/f $DIR/R6b/g
379 mv $DIR/R6a/f $DIR/R6b/g
380 $CHECKSTAT -a $DIR/R6a/f || error
381 $CHECKSTAT -t file $DIR/R6b/g || error
386 log '-- test 24-R7: touch a ; rename a b'
389 mv $DIR/R7a/f $DIR/R7b/g
390 $CHECKSTAT -a $DIR/R7a/f || error
391 $CHECKSTAT -t dir $DIR/R7b/g || error
396 log '-- test 24-R8: touch a ; rename a b'
398 mkdir $DIR/R8a/f $DIR/R8b/g
399 perl -e "rename \"$DIR/R8a/f\", \"$DIR/R8b/g\";"
400 $CHECKSTAT -a $DIR/R8a/f || error
401 $CHECKSTAT -t dir $DIR/R8b/g || error
406 echo "-- rename error cases"
407 log "-- test 24-R9 target error: touch f ; mkdir a ; rename f a"
411 perl -e "rename \"$DIR/R9/f\", \"$DIR/R9/a\";"
412 $CHECKSTAT -t file $DIR/R9/f || error
413 $CHECKSTAT -t dir $DIR/R9/a || error
414 $CHECKSTAT -a file $DIR/R9/a/f || error
419 log "--test 24-R10 source does not exist"
421 perl -e "rename \"$DIR/R10/f\", \"$DIR/R10/g\""
422 $CHECKSTAT -t dir $DIR/R10 || error
423 $CHECKSTAT -a $DIR/R10/f || error
424 $CHECKSTAT -a $DIR/R10/g || error
429 echo '== symlink sanity ================================ test25'
430 log "--test 25.1 create file in symlinked directory"
438 log "--test 25.2 lookup file in symlinked directory"
439 $CHECKSTAT -t file $DIR/s25/foo
444 log "--test 26 multiple component symlink"
447 ln -s d26/d26-2 $DIR/s26
453 log "--test 26.1 multiple component symlink at the end of a lookup"
454 ln -s d26/d26-2/foo $DIR/s26-2
460 log "--test 26.2 a chain of symlinks"
463 ln -s d26.2 $DIR/s26.2-1
464 ln -s s26.2-1 $DIR/s26.2-2
465 ln -s s26.2-2 $DIR/s26.2-3
466 chmod 0666 $DIR/s26.2-3/foo
471 # recursive symlinks (bug 439)
472 log "--test 26.3 create multiple component recursive symlink"
473 ln -s d26-3/foo $DIR/d26-3
478 log "--test 26.3 unlink multiple component recursive symlink"
484 echo '== stripe sanity ================================= test27'
485 log "--test 27.1 create one stripe"
487 $LSTRIPE $DIR/d27/f0 8192 0 1
488 $CHECKSTAT -t file $DIR/d27/f0
489 log "--test 27.2 write to one stripe file"
490 cp /etc/hosts $DIR/d27/f0
493 log "--test 27.3 create two stripe file f01"
494 $LSTRIPE $DIR/d27/f01 8192 0 2
495 log "--test 27.4 write to two stripe file file f01"
496 dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4
499 log "--test 27.5 create file with default settings"
500 $LSTRIPE $DIR/d27/fdef 0 -1 0
501 $CHECKSTAT -t file $DIR/d27/fdef
502 #dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4
504 log "--test 27.6 lstripe existing file (should return error)"
505 $LSTRIPE $DIR/d27/f12 8192 1 2
506 ! $LSTRIPE $DIR/d27/f12 8192 1 2
507 $CHECKSTAT -t file $DIR/d27/f12
508 #dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4
512 log "--test 27.7 lstripe with bad stripe size (should return error on LOV)"
513 $LSTRIPE $DIR/d27/fbad 100 1 2 || /bin/true
514 dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4
519 log "--test 27.8 lfind "
525 log '== create/mknod/mkdir with bad file types ======== test28'
527 $CREATETEST $DIR/d28/ct || error
530 log '== IT_GETATTR regression ======================== test29'
534 MDCDIR=${MDCDIR:-/proc/fs/lustre/ldlm/ldlm/MDC_*}
535 LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
536 LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
538 LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
539 LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
540 if [ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ] || [ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]; then
547 log '== run binary from Lustre (execve) =============== test30'
553 log '== open-unlink file ============================== test31'
554 ./openunlink $DIR/f31 $DIR/f31 || error
557 log '== cleanup ============================================='
558 rm -r $DIR/[Rdfs][1-9]* $DIR/ls
560 echo '======================= finished ======================='