Whamcloud - gitweb
- landing of b_fid after merge with b_hd_cleanup_merge.
[fs/lustre-release.git] / lustre / tests / sanity.sh
1 #!/bin/bash
2 #
3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
5 #
6 # e.g. ONLY="22 23" or ONLY="`seq 32 39`" or EXCEPT="31"
7 set -e
8
9 ONLY=${ONLY:-"$*"}
10 # bug number for skipped test: 2739
11 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"65a 65b 65c 65d 65e 65f"}
12 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
13
14 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
15
16 SRCDIR=`dirname $0`
17 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
18
19 TMP=${TMP:-/tmp}
20 FSTYPE=${FSTYPE:-ext3}
21
22 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
23 CREATETEST=${CREATETEST:-createtest}
24 LFS=${LFS:-lfs}
25 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
26 LFIND=${LFIND:-"$LFS find"}
27 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
28 LCTL=${LCTL:-lctl}
29 MCREATE=${MCREATE:-mcreate}
30 OPENFILE=${OPENFILE:-openfile}
31 OPENUNLINK=${OPENUNLINK:-openunlink}
32 TOEXCL=${TOEXCL:-toexcl}
33 TRUNCATE=${TRUNCATE:-truncate}
34 MUNLINK=${MUNLINK:-munlink}
35 SOCKETSERVER=${SOCKETSERVER:-socketserver}
36 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
37 IOPENTEST1=${IOPENTEST1:-iopentest1}
38 IOPENTEST2=${IOPENTEST2:-iopentest2}
39 MEMHOG=${MEMHOG:-memhog}
40
41 if [ $UID -ne 0 ]; then
42         RUNAS_ID="$UID"
43         RUNAS=""
44 else
45         RUNAS_ID=${RUNAS_ID:-500}
46         RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
47 fi
48
49 export NAME=${NAME:-local}
50
51 SAVE_PWD=$PWD
52
53 clean() {
54         echo -n "cln.."
55         sh llmountcleanup.sh > /dev/null || exit 20
56         I_MOUNTED=no
57 }
58 CLEAN=${CLEAN:-:}
59
60 start() {
61         echo -n "mnt.."
62         sh llrmount.sh > /dev/null || exit 10
63         I_MOUNTED=yes
64         echo "done"
65 }
66 START=${START:-}
67
68 log() {
69         echo "$*"
70         lctl mark "$*" 2> /dev/null || true
71 }
72
73 trace() {
74         log "STARTING: $*"
75         strace -o $TMP/$1.strace -ttt $*
76         RC=$?
77         log "FINISHED: $*: rc $RC"
78         return 1
79 }
80 TRACE=${TRACE:-""}
81
82 check_kernel_version() {
83         VERSION_FILE=/proc/fs/lustre/kernel_version
84         WANT_VER=$1
85         [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
86         GOT_VER=`cat $VERSION_FILE`
87         [ $GOT_VER -ge $WANT_VER ] && return 0
88         log "test needs at least kernel version $WANT_VER, running $GOT_VER"
89         return 1
90 }
91
92 run_one() {
93         if ! mount | grep -q $DIR; then
94                 $START
95         fi
96         echo -1 >/proc/sys/portals/debug        
97         log "== test $1: $2= `date +%H:%M:%S`"
98         export TESTNAME=test_$1
99         test_$1 || error "test_$1: exit with rc=$?"
100         unset TESTNAME
101         pass
102         cd $SAVE_PWD
103         $CLEAN
104 }
105
106 build_test_filter() {
107         for O in $ONLY; do
108             eval ONLY_${O}=true
109         done
110         for E in $EXCEPT $ALWAYS_EXCEPT; do
111             eval EXCEPT_${E}=true
112         done
113 }
114
115 _basetest() {
116     echo $*
117 }
118
119 basetest() {
120     IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
121 }
122
123 run_test() {
124          base=`basetest $1`
125          if [ "$ONLY" ]; then
126                  testname=ONLY_$1
127                  if [ ${!testname}x != x ]; then
128                         run_one $1 "$2"
129                         return $?
130                  fi
131                  testname=ONLY_$base
132                  if [ ${!testname}x != x ]; then
133                          run_one $1 "$2"
134                          return $?
135                  fi
136                  echo -n "."
137                  return 0
138         fi
139         testname=EXCEPT_$1
140         if [ ${!testname}x != x ]; then
141                  echo "skipping excluded test $1"
142                  return 0
143         fi
144         testname=EXCEPT_$base
145         if [ ${!testname}x != x ]; then
146                  echo "skipping excluded test $1 (base $base)"
147                  return 0
148         fi
149         run_one $1 "$2"
150         return $?
151 }
152
153 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
154
155 error() { 
156         log "FAIL: $@"
157         if [ "$SANITYLOG" ]; then
158                 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
159         else
160                 exit 1
161         fi
162 }
163
164 pass() { 
165         echo PASS
166 }
167
168 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
169 if [ -z "$MOUNT" ]; then
170         sh llmount.sh
171         MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
172         [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
173         I_MOUNTED=yes
174 fi
175
176 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
177
178 DIR=${DIR:-$MOUNT}
179 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
180
181 OSTCOUNT=`cat /proc/fs/lustre/llite/fs0/lov/numobd`
182 STRIPECOUNT=`cat /proc/fs/lustre/llite/fs0/lov/stripecount`
183 STRIPESIZE=`cat /proc/fs/lustre/llite/fs0/lov/stripesize`
184
185 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
186 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
187 rm -rf $DIR/[Rdfs][1-9]*
188
189 build_test_filter
190
191 echo preparing for tests involving mounts
192 EXT2_DEV=${EXT2_DEV:-/tmp/SANITY.LOOP}
193 touch $EXT2_DEV
194 mke2fs -j -F $EXT2_DEV 8000 > /dev/null
195
196 umask 077
197
198 test_0() {
199         touch $DIR/f
200         $CHECKSTAT -t file $DIR/f || error
201         rm $DIR/f
202         $CHECKSTAT -a $DIR/f || error
203 }
204 run_test 0 "touch .../f ; rm .../f ============================="
205
206 test_0b() {
207        chmod 0755 $DIR || error
208        $CHECKSTAT -p 0755 $DIR || error
209 }
210 run_test 0b "chmod 0755 $DIR ============================="
211
212
213 test_1a() {
214         mkdir $DIR/d1
215         mkdir $DIR/d1/d2
216         $CHECKSTAT -t dir $DIR/d1/d2 || error
217 }
218 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
219
220 test_1b() {
221         rmdir $DIR/d1/d2
222         rmdir $DIR/d1
223         $CHECKSTAT -a $DIR/d1 || error
224 }
225 run_test 1b "rmdir .../d1/d2; rmdir .../d1 ====================="
226
227 test_2a() {
228         mkdir $DIR/d2
229         touch $DIR/d2/f
230         $CHECKSTAT -t file $DIR/d2/f || error
231 }
232 run_test 2a "mkdir .../d2; touch .../d2/f ======================"
233
234 test_2b() {
235         rm -r $DIR/d2
236         $CHECKSTAT -a $DIR/d2 || error
237 }
238 run_test 2b "rm -r .../d2; checkstat .../d2/f ======================"
239
240 test_3a() {
241         mkdir $DIR/d3
242         $CHECKSTAT -t dir $DIR/d3 || error
243 }
244 run_test 3a "mkdir .../d3 ======================================"
245
246 test_3b() {
247         if [ ! -d $DIR/d3 ]; then
248                 mkdir $DIR/d3
249         fi
250         touch $DIR/d3/f
251         $CHECKSTAT -t file $DIR/d3/f || error
252 }
253 run_test 3b "touch .../d3/f ===================================="
254
255 test_3c() {
256         rm -r $DIR/d3
257         $CHECKSTAT -a $DIR/d3 || error
258 }
259 run_test 3c "rm -r .../d3 ======================================"
260
261 test_4a() {
262         mkdir $DIR/d4
263         $CHECKSTAT -t dir $DIR/d4 || error
264 }
265 run_test 4a "mkdir .../d4 ======================================"
266
267 test_4b() {
268         if [ ! -d $DIR/d4 ]; then
269                 mkdir $DIR/d4
270         fi
271         mkdir $DIR/d4/d2
272         $CHECKSTAT -t dir $DIR/d4/d2 || error
273 }
274 run_test 4b "mkdir .../d4/d2 ==================================="
275
276 test_5() {
277         mkdir $DIR/d5
278         mkdir $DIR/d5/d2
279         chmod 0707 $DIR/d5/d2
280         $CHECKSTAT -t dir -p 0707 $DIR/d5/d2 || error
281 }
282 run_test 5 "mkdir .../d5 .../d5/d2; chmod .../d5/d2 ============"
283
284 test_6a() {
285         touch $DIR/f6a
286         chmod 0666 $DIR/f6a || error
287         $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
288 }
289 run_test 6a "touch .../f6a; chmod .../f6a ======================"
290
291 test_6b() {
292         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6b" && return
293         if [ ! -f $DIR/f6a ]; then
294                 touch $DIR/f6a
295                 chmod 0666 $DIR/f6a
296         fi
297         $RUNAS chmod 0444 $DIR/f6a && error
298         $CHECKSTAT -t file -p 0666 -u \#$UID $DIR/f6a || error
299 }
300 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
301
302 test_6c() {
303         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6c" && return
304         touch $DIR/f6c
305         chown $RUNAS_ID $DIR/f6c || error
306         $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
307 }
308 run_test 6c "touch .../f6c; chown .../f6c ======================"
309
310 test_6d() {
311         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6d" && return
312         if [ ! -f $DIR/f6c ]; then
313                 touch $DIR/f6c
314                 chown $RUNAS_ID $DIR/f6c
315         fi
316         $RUNAS chown $UID $DIR/f6c && error
317         $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
318 }
319 run_test 6d "$RUNAS chown .../f6c (should return error) =="
320
321 test_6e() {
322         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6e" && return
323         touch $DIR/f6e
324         chgrp $RUNAS_ID $DIR/f6e || error
325         $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
326 }
327 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
328
329 test_6f() {
330         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6f" && return
331         if [ ! -f $DIR/f6e ]; then
332                 touch $DIR/f6e
333                 chgrp $RUNAS_ID $DIR/f6e
334         fi
335         $RUNAS chgrp $UID $DIR/f6e && error
336         $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
337 }
338 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
339
340 test_6g() {
341         [ $RUNAS_ID -eq $UID ] && echo "skipping test 6g" && return
342         mkdir $DIR/d6g || error
343         chmod 777 $DIR/d6g || error
344         $RUNAS mkdir $DIR/d6g/d || error
345         chmod g+s $DIR/d6g/d || error
346         mkdir $DIR/d6g/d/subdir
347         $CHECKSTAT -g \#$RUNAS_ID $DIR/d6g/d/subdir || error
348 }
349 run_test 6g "Is new dir in sgid dir inheriting group?"
350
351 test_7a() {
352         mkdir $DIR/d7
353         $MCREATE $DIR/d7/f
354         chmod 0666 $DIR/d7/f
355         $CHECKSTAT -t file -p 0666 $DIR/d7/f || error
356 }
357 run_test 7a "mkdir .../d7; mcreate .../d7/f; chmod .../d7/f ===="
358
359 test_7b() {
360         if [ ! -d $DIR/d7 ]; then
361                 mkdir $DIR/d7
362         fi
363         $MCREATE $DIR/d7/f2
364         echo -n foo > $DIR/d7/f2
365         [ "`cat $DIR/d7/f2`" = "foo" ] || error
366         $CHECKSTAT -t file -s 3 $DIR/d7/f2 || error
367 }
368 run_test 7b "mkdir .../d7; mcreate d7/f2; echo foo > d7/f2 ====="
369
370 test_8() {
371         mkdir $DIR/d8
372         touch $DIR/d8/f
373         chmod 0666 $DIR/d8/f
374         $CHECKSTAT -t file -p 0666 $DIR/d8/f || error
375 }
376 run_test 8 "mkdir .../d8; touch .../d8/f; chmod .../d8/f ======="
377
378 test_9() {
379         mkdir $DIR/d9
380         mkdir $DIR/d9/d2
381         mkdir $DIR/d9/d2/d3
382         $CHECKSTAT -t dir $DIR/d9/d2/d3 || error
383 }
384 run_test 9 "mkdir .../d9 .../d9/d2 .../d9/d2/d3 ================"
385
386 test_10() {
387         mkdir $DIR/d10
388         mkdir $DIR/d10/d2
389         touch $DIR/d10/d2/f
390         $CHECKSTAT -t file $DIR/d10/d2/f || error
391 }
392 run_test 10 "mkdir .../d10 .../d10/d2; touch .../d10/d2/f ======"
393
394 test_11() {
395         mkdir $DIR/d11
396         mkdir $DIR/d11/d2
397         chmod 0666 $DIR/d11/d2
398         chmod 0705 $DIR/d11/d2
399         $CHECKSTAT -t dir -p 0705 $DIR/d11/d2 || error
400 }
401 run_test 11 "mkdir .../d11 d11/d2; chmod .../d11/d2 ============"
402
403 test_12() {
404         mkdir $DIR/d12
405         touch $DIR/d12/f
406         chmod 0666 $DIR/d12/f
407         chmod 0654 $DIR/d12/f
408         $CHECKSTAT -t file -p 0654 $DIR/d12/f || error
409 }
410 run_test 12 "touch .../d12/f; chmod .../d12/f .../d12/f ========"
411
412 test_13() {
413         mkdir $DIR/d13
414         dd if=/dev/zero of=$DIR/d13/f count=10
415         >  $DIR/d13/f
416         $CHECKSTAT -t file -s 0 $DIR/d13/f || error
417 }
418 run_test 13 "creat .../d13/f; dd .../d13/f; > .../d13/f ========"
419
420 test_14() {
421         mkdir $DIR/d14
422         touch $DIR/d14/f
423         rm $DIR/d14/f
424         $CHECKSTAT -a $DIR/d14/f || error
425 }
426 run_test 14 "touch .../d14/f; rm .../d14/f; rm .../d14/f ======="
427
428 test_15() {
429         mkdir $DIR/d15
430         touch $DIR/d15/f
431         mv $DIR/d15/f $DIR/d15/f2
432         $CHECKSTAT -t file $DIR/d15/f2 || error
433 }
434 run_test 15 "touch .../d15/f; mv .../d15/f .../d15/f2 =========="
435
436 test_16() {
437         mkdir $DIR/d16
438         touch $DIR/d16/f
439         rm -rf $DIR/d16/f
440         $CHECKSTAT -a $DIR/d16/f || error
441 }
442 run_test 16 "touch .../d16/f; rm -rf .../d16/f ================="
443
444 test_17a() {
445         mkdir $DIR/d17
446         touch $DIR/d17/f
447         ln -s $DIR/d17/f $DIR/d17/l-exist
448         ls -l $DIR/d17
449         $CHECKSTAT -l $DIR/d17/f $DIR/d17/l-exist || error
450         $CHECKSTAT -f -t f $DIR/d17/l-exist || error
451         rm -f $DIR/l-exist
452         $CHECKSTAT -a $DIR/l-exist || error
453 }
454 run_test 17a "symlinks: create, remove (real) =================="
455
456 test_17b() {
457         if [ ! -d $DIR/d17 ]; then
458                 mkdir $DIR/d17
459         fi
460         ln -s no-such-file $DIR/d17/l-dangle
461         ls -l $DIR/d17
462         $CHECKSTAT -l no-such-file $DIR/d17/l-dangle || error
463         $CHECKSTAT -fa $DIR/d17/l-dangle || error
464         rm -f $DIR/l-dangle
465         $CHECKSTAT -a $DIR/l-dangle || error
466 }
467 run_test 17b "symlinks: create, remove (dangling) =============="
468
469 test_18() {
470         touch $DIR/f
471         ls $DIR || error
472 }
473 run_test 18 "touch .../f ; ls ... =============================="
474
475 test_19a() {
476         touch $DIR/f19
477         ls -l $DIR
478         rm $DIR/f19
479         $CHECKSTAT -a $DIR/f19 || error
480 }
481 run_test 19a "touch .../f19 ; ls -l ... ; rm .../f19 ==========="
482
483 test_19b() {
484         ls -l $DIR/f19 && error || true
485 }
486 run_test 19b "ls -l .../f19 (should return error) =============="
487
488 test_19c() {
489         [ $RUNAS_ID -eq $UID ] && echo "skipping test 19c" && return
490         $RUNAS touch $DIR/f19 && error || true
491 }
492 run_test 19c "$RUNAS touch .../f19 (should return error) =="
493
494 test_19d() {
495         cat $DIR/f19 && error || true
496 }
497 run_test 19d "cat .../f19 (should return error) =============="
498
499 test_20() {
500         touch $DIR/f
501         rm $DIR/f
502         log "1 done"
503         touch $DIR/f
504         rm $DIR/f
505         log "2 done"
506         touch $DIR/f
507         rm $DIR/f
508         log "3 done"
509         $CHECKSTAT -a $DIR/f || error
510 }
511 run_test 20 "touch .../f ; ls -l ... ==========================="
512
513 test_21() {
514         mkdir $DIR/d21
515         [ -f $DIR/d21/dangle ] && rm -f $DIR/d21/dangle
516         ln -s dangle $DIR/d21/link
517         echo foo >> $DIR/d21/link
518         cat $DIR/d21/dangle
519         $CHECKSTAT -t link $DIR/d21/link || error
520         $CHECKSTAT -f -t file $DIR/d21/link || error
521 }
522 run_test 21 "write to dangling link ============================"
523
524 test_22() {
525         mkdir $DIR/d22
526         chown $RUNAS_ID $DIR/d22
527         # Tar gets pissy if it can't access $PWD *sigh*
528         (cd /tmp;
529         $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
530         $RUNAS tar xfC - $DIR/d22)
531         ls -lR $DIR/d22/etc
532         $CHECKSTAT -t dir $DIR/d22/etc || error
533         $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/etc || error
534 }
535 run_test 22 "unpack tar archive as non-root user ==============="
536
537 test_23() {
538         mkdir $DIR/d23
539         $TOEXCL $DIR/d23/f23
540         $TOEXCL -e $DIR/d23/f23 || error
541 }
542 run_test 23 "O_CREAT|O_EXCL in subdir =========================="
543
544 test_24a() {
545         echo '== rename sanity =============================================='
546         echo '-- same directory rename'
547         mkdir $DIR/R1
548         touch $DIR/R1/f
549         mv $DIR/R1/f $DIR/R1/g
550         $CHECKSTAT -t file $DIR/R1/g || error
551 }
552 run_test 24a "touch .../R1/f; rename .../R1/f .../R1/g ========="
553
554 test_24b() {
555         mkdir $DIR/R2
556         touch $DIR/R2/{f,g}
557         mv $DIR/R2/f $DIR/R2/g
558         $CHECKSTAT -a $DIR/R2/f || error
559         $CHECKSTAT -t file $DIR/R2/g || error
560 }
561 run_test 24b "touch .../R2/{f,g}; rename .../R2/f .../R2/g ====="
562
563 test_24c() {
564         mkdir $DIR/R3
565         mkdir $DIR/R3/f
566         mv $DIR/R3/f $DIR/R3/g
567         $CHECKSTAT -a $DIR/R3/f || error
568         $CHECKSTAT -t dir $DIR/R3/g || error
569 }
570 run_test 24c "mkdir .../R3/f; rename .../R3/f .../R3/g ========="
571
572 test_24d() {
573         mkdir $DIR/R4
574         mkdir $DIR/R4/{f,g}
575         mrename $DIR/R4/f $DIR/R4/g
576         $CHECKSTAT -a $DIR/R4/f || error
577         $CHECKSTAT -t dir $DIR/R4/g || error
578 }
579 run_test 24d "mkdir .../R4/{f,g}; rename .../R4/f .../R4/g ====="
580
581 test_24e() {
582         echo '-- cross directory renames --' 
583         mkdir $DIR/R5{a,b}
584         touch $DIR/R5a/f
585         mv $DIR/R5a/f $DIR/R5b/g
586         $CHECKSTAT -a $DIR/R5a/f || error
587         $CHECKSTAT -t file $DIR/R5b/g || error
588 }
589 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
590
591 test_24f() {
592         mkdir $DIR/R6{a,b}
593         touch $DIR/R6a/f $DIR/R6b/g
594         mv $DIR/R6a/f $DIR/R6b/g
595         $CHECKSTAT -a $DIR/R6a/f || error
596         $CHECKSTAT -t file $DIR/R6b/g || error
597 }
598 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
599
600 test_24g() {
601         mkdir $DIR/R7{a,b}
602         mkdir $DIR/R7a/d
603         mv $DIR/R7a/d $DIR/R7b/e
604         $CHECKSTAT -a $DIR/R7a/d || error
605         $CHECKSTAT -t dir $DIR/R7b/e || error
606 }
607 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R5b/e ======"
608
609 test_24h() {
610         mkdir $DIR/R8{a,b}
611         mkdir $DIR/R8a/d $DIR/R8b/e
612         mrename $DIR/R8a/d $DIR/R8b/e
613         $CHECKSTAT -a $DIR/R8a/d || error
614         $CHECKSTAT -t dir $DIR/R8b/e || error
615 }
616 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
617
618 test_24i() {
619         echo "-- rename error cases"
620         mkdir $DIR/R9
621         mkdir $DIR/R9/a
622         touch $DIR/R9/f
623         mrename $DIR/R9/f $DIR/R9/a
624         $CHECKSTAT -t file $DIR/R9/f || error
625         $CHECKSTAT -t dir  $DIR/R9/a || error
626         $CHECKSTAT -a file $DIR/R9/a/f || error
627 }
628 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
629
630 test_24j() {
631         mkdir $DIR/R10
632         mrename $DIR/R10/f $DIR/R10/g
633         $CHECKSTAT -t dir $DIR/R10 || error
634         $CHECKSTAT -a $DIR/R10/f || error
635         $CHECKSTAT -a $DIR/R10/g || error
636 }
637 run_test 24j "source does not exist ============================" 
638
639 test_24k() {
640         mkdir $DIR/R11a $DIR/R11a/d
641         touch $DIR/R11a/f
642         mv $DIR/R11a/f $DIR/R11a/d
643         $CHECKSTAT -a $DIR/R11a/f || error
644         $CHECKSTAT -t file $DIR/R11a/d/f || error
645 }
646 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
647
648 # bug 2429 - rename foo foo foo creates invalid file
649 test_24l() {
650         f="$DIR/f24l"
651         multiop $f OcNs || error
652 }
653 run_test 24l "Renaming a file to itself ========================"
654
655 test_24m() {
656         f="$DIR/f24m"
657         multiop $f OcLN ${f}2 ${f}2 || error
658 }
659 run_test 24m "Renaming a file to a hard link to itself ========="
660
661 test_24n() {
662     f="$DIR/f24n"
663     # this stats the old file after it was renamed, so it should fail
664     touch ${f}
665     $CHECKSTAT ${f}
666     mv ${f} ${f}.rename
667     $CHECKSTAT ${f}.rename
668     $CHECKSTAT -a ${f}
669 }
670 run_test 24n "Statting the old file after renameing (Posix rename 2)"
671
672 test_24o() {
673         check_kernel_version 37 || return 0
674         rename_many -s random -v -n 10 $DIR
675 }
676 run_test 24o "rename of files during htree split ==============="
677
678 test_24p() {
679        mkdir $DIR/R12{a,b}
680        DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
681        mrename $DIR/R12a $DIR/R12b
682        $CHECKSTAT -a $DIR/R12a || error
683        $CHECKSTAT -t dir $DIR/R12b || error
684        DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
685        [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
686 }
687 run_test 24p "mkdir .../R12{a,b}; rename .../R12a .../R12b"
688
689 test_24q() {
690        mkdir $DIR/R13{a,b}
691        DIRINO=`ls -lid $DIR/R13a | awk '{ print $1 }'`
692        multiop $DIR/R13b D_c &
693        MULTIPID=$!
694
695        mrename $DIR/R13a $DIR/R13b
696        $CHECKSTAT -a $DIR/R13a || error
697        $CHECKSTAT -t dir $DIR/R13b || error
698        DIRINO2=`ls -lid $DIR/R13b | awk '{ print $1 }'`
699        [ "$DIRINO" = "$DIRINO2" ] || error "R13a $DIRINO != R13b $DIRINO2"
700        kill -USR1 $MULTIPID
701        wait $MULTIPID || error "multiop close failed"
702 }
703 run_test 24q "mkdir .../R13{a,b}; open R13b rename R13a R13b ==="
704
705 test_24r() { #bug 3789
706        mkdir $DIR/R14a $DIR/R14a/b
707        mrename $DIR/R14a $DIR/R14a/b && error "rename to subdir worked!"
708        $CHECKSTAT -t dir $DIR/R14a || error "$DIR/R14a missing"
709        $CHECKSTAT -t dir $DIR/R14a/b || error "$DIR/R14a/b missing"
710 }
711 run_test 24r "mkdir .../R14a/b; rename .../R14a .../R14a/b ====="
712
713 test_24s() {
714        mkdir $DIR/R15a $DIR/R15a/b $DIR/R15a/b/c
715        mrename $DIR/R15a $DIR/R15a/b/c && error "rename to sub-subdir worked!"
716        $CHECKSTAT -t dir $DIR/R15a || error "$DIR/R15a missing"
717        $CHECKSTAT -t dir $DIR/R15a/b/c || error "$DIR/R15a/b/c missing"
718 }
719 run_test 24s "mkdir .../R15a/b/c; rename .../R15a .../R15a/b/c ="
720 test_24t() {
721        mkdir $DIR/R16a $DIR/R16a/b $DIR/R16a/b/c
722        mrename $DIR/R16a/b/c $DIR/R16a && error "rename to sub-subdir worked!"
723        $CHECKSTAT -t dir $DIR/R16a || error "$DIR/R16a missing"
724        $CHECKSTAT -t dir $DIR/R16a/b/c || error "$DIR/R16a/b/c missing"
725 }
726 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
727
728 test_25a() {
729         echo '== symlink sanity ============================================='
730         mkdir $DIR/d25
731         ln -s d25 $DIR/s25
732         touch $DIR/s25/foo || error
733 }
734 run_test 25a "create file in symlinked directory ==============="
735
736 test_25b() {
737         [ ! -d $DIR/d25 ] && test_25a
738         $CHECKSTAT -t file $DIR/s25/foo || error
739 }
740 run_test 25b "lookup file in symlinked directory ==============="
741
742 test_26a() {
743         mkdir $DIR/d26
744         mkdir $DIR/d26/d26-2
745         ln -s d26/d26-2 $DIR/s26
746         touch $DIR/s26/foo || error
747 }
748 run_test 26a "multiple component symlink ======================="
749
750 test_26b() {
751         mkdir -p $DIR/d26b/d26-2
752         ln -s d26b/d26-2/foo $DIR/s26-2
753         touch $DIR/s26-2 || error
754 }
755 run_test 26b "multiple component symlink at end of lookup ======"
756
757 test_26c() {
758         mkdir $DIR/d26.2
759         touch $DIR/d26.2/foo
760         ln -s d26.2 $DIR/s26.2-1
761         ln -s s26.2-1 $DIR/s26.2-2
762         ln -s s26.2-2 $DIR/s26.2-3
763         chmod 0666 $DIR/s26.2-3/foo
764 }
765 run_test 26c "chain of symlinks ================================"
766
767 # recursive symlinks (bug 439)
768 test_26d() {
769         ln -s d26-3/foo $DIR/d26-3
770 }
771 run_test 26d "create multiple component recursive symlink ======"
772
773 test_26e() {
774         [ ! -h $DIR/d26-3 ] && test_26d
775         rm $DIR/d26-3
776 }
777 run_test 26e "unlink multiple component recursive symlink ======"
778
779 test_27a() {
780         echo '== stripe sanity =============================================='
781         mkdir $DIR/d27
782         $LSTRIPE $DIR/d27/f0 65536 0 1 || error "lstripe failed"
783         $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
784         pass
785         log "== test_27b: write to one stripe file ========================="
786         cp /etc/hosts $DIR/d27/f0 || error
787 }
788 run_test 27a "one stripe file =================================="
789
790 test_27c() {
791         [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
792         if [ ! -d $DIR/d27 ]; then
793                 mkdir $DIR/d27
794         fi
795         $LSTRIPE $DIR/d27/f01 65536 0 2 || error "lstripe failed"
796         [ `$LFIND $DIR/d27/f01 --quiet | grep [^[:blank:]*] | wc -l` -eq 2 ] ||
797                 error "two-stripe file doesn't have two stripes"
798         pass
799         log "== test_27d: write to two stripe file file f01 ================"
800         dd if=/dev/zero of=$DIR/d27/f01 bs=4k count=4 || error "dd failed"
801 }
802 run_test 27c "create two stripe file f01 ======================="
803
804 test_27d() {
805         if [ ! -d $DIR/d27 ]; then
806                 mkdir $DIR/d27
807         fi
808         $LSTRIPE $DIR/d27/fdef 0 -1 0 || error "lstripe failed"
809         $CHECKSTAT -t file $DIR/d27/fdef || error "checkstat failed"
810         #dd if=/dev/zero of=$DIR/d27/fdef bs=4k count=4 || error
811 }
812 run_test 27d "create file with default settings ================"
813
814 test_27e() {
815         if [ ! -d $DIR/d27 ]; then
816                 mkdir $DIR/d27
817         fi
818         $LSTRIPE $DIR/d27/f12 65536 0 2 || error "lstripe failed"
819         $LSTRIPE $DIR/d27/f12 65536 0 2 && error "lstripe succeeded twice"
820         $CHECKSTAT -t file $DIR/d27/f12 || error "checkstat failed"
821 }
822 run_test 27e "lstripe existing file (should return error) ======"
823
824 test_27f() {
825         if [ ! -d $DIR/d27 ]; then
826                 mkdir $DIR/d27
827         fi
828         $LSTRIPE $DIR/d27/fbad 100 0 1 && error "lstripe failed"
829         dd if=/dev/zero of=$DIR/d27/f12 bs=4k count=4 || error "dd failed"
830         $LFIND $DIR/d27/fbad || error "lfind failed"
831
832 }
833 run_test 27f "lstripe with bad stripe size (should return error)"
834
835 test_27g() {
836         if [ ! -d $DIR/d27 ]; then
837                 mkdir $DIR/d27
838         fi
839         $MCREATE $DIR/d27/fnone || error "mcreate failed"
840         pass
841         log "== test 27h: lfind with no objects ============================"
842         $LFIND $DIR/d27/fnone 2>&1 | grep "no stripe info" || error "has object"
843         pass
844         log "== test 27i: lfind with some objects =========================="
845         touch $DIR/d27/fsome || error "touch failed"
846         $LFIND $DIR/d27/fsome | grep obdidx || error "missing objects"
847
848 }
849 run_test 27g "test lfind ======================================="
850
851 test_27j() {
852         if [ ! -d $DIR/d27 ]; then
853                 mkdir $DIR/d27
854         fi
855         $LSTRIPE $DIR/d27/f27j 65536 $OSTCOUNT 1 && error "lstripe failed"||true
856 }
857 run_test 27j "lstripe with bad stripe offset (should return error)"
858
859 test_27k() { # bug 2844
860         FILE=$DIR/d27/f27k
861         LL_MAX_BLKSIZE=$((4 * 1024 * 1024))
862         [ ! -d $DIR/d27 ] && mkdir -p $DIR/d27
863         $LSTRIPE $FILE 67108864 -1 0 || error "lstripe failed"
864         BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
865         [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
866         dd if=/dev/zero of=$FILE bs=4k count=1
867         BLKSIZE=`stat $FILE | awk '/IO Block:/ { print $7 }'`
868         [ $BLKSIZE -le $LL_MAX_BLKSIZE ] || error "$BLKSIZE > $LL_MAX_BLKSIZE"
869 }
870 run_test 27k "limit i_blksize for broken user apps ============="
871
872 test_27l() {
873         mcreate $DIR/f27l || error "creating file"
874         $RUNAS $LSTRIPE $DIR/f27l 65536 -1 1 && \
875                 error "lstripe should have failed" || true
876 }
877 run_test 27l "check setstripe permissions (should return error)"
878
879 test_28() {
880         mkdir $DIR/d28
881         $CREATETEST $DIR/d28/ct || error
882 }
883 run_test 28 "create/mknod/mkdir with bad file types ============"
884
885 cancel_lru_locks() {
886         for d in /proc/fs/lustre/ldlm/namespaces/$1*; do
887                 echo clear > $d/lru_size
888         done
889         grep [0-9] /proc/fs/lustre/ldlm/namespaces/$1*/lock_unused_count /dev/null
890 }
891
892 test_29() {
893         cancel_lru_locks MDC
894         mkdir $DIR/d29
895         touch $DIR/d29/foo
896         log 'first d29'
897         ls -l $DIR/d29
898         MDCDIR=${MDCDIR:-/proc/fs/lustre/ldlm/namespaces/MDC_*}
899         LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
900         LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
901         log 'second d29'
902         ls -l $DIR/d29
903         log 'done'
904         LOCKCOUNTCURRENT=`cat $MDCDIR/lock_count`
905         LOCKUNUSEDCOUNTCURRENT=`cat $MDCDIR/lock_unused_count`
906         if [ $LOCKCOUNTCURRENT -gt $LOCKCOUNTORIG ]; then
907                 echo "CURRENT: $LOCKCOUNTCURRENT > $LOCKCOUNTORIG"
908                 error
909         fi
910         if [ $LOCKUNUSEDCOUNTCURRENT -gt $LOCKUNUSEDCOUNTORIG ]; then
911                 echo "UNUSED: $LOCKUNUSEDCOUNTCURRENT > $LOCKUNUSEDCOUNTORIG"
912                 error
913         fi
914 }
915 run_test 29 "IT_GETATTR regression  ============================"
916
917 test_30() {
918         cp `which ls` $DIR
919         $DIR/ls /
920         rm $DIR/ls
921 }
922 run_test 30 "run binary from Lustre (execve) ==================="
923
924 test_31a() {
925         $OPENUNLINK $DIR/f31 $DIR/f31 || error
926         $CHECKSTAT -a $DIR/f31 || error
927 }
928 run_test 31a "open-unlink file =================================="
929
930 test_31b() {
931         touch $DIR/f31 || error
932         ln $DIR/f31 $DIR/f31b || error
933         multiop $DIR/f31b Ouc || error
934         $CHECKSTAT -t file $DIR/f31 || error
935 }
936 run_test 31b "unlink file with multiple links while open ======="
937
938 test_31c() {
939         touch $DIR/f31 || error
940         ln $DIR/f31 $DIR/f31c || error
941         multiop $DIR/f31 O_uc &
942         MULTIPID=$!
943         multiop $DIR/f31c Ouc
944         usleep 500
945         kill -USR1 $MULTIPID
946         wait $MULTIPID
947 }
948 run_test 31c "open-unlink file with multiple links ============="
949
950 test_31d() {
951         opendirunlink $DIR/d31d $DIR/d31d || error
952         $CHECKSTAT -a $DIR/d31d || error
953 }
954 run_test 31d "remove of open directory ========================="
955
956 test_31e() { # bug 2904
957         check_kernel_version 34 || return 0
958         openfilleddirunlink $DIR/d31e || error
959 }
960 run_test 31e "remove of open non-empty directory ==============="
961
962 test_32a() {
963         echo "== more mountpoints and symlinks ================="
964         [ -e $DIR/d32a ] && rm -fr $DIR/d32a
965         mkdir -p $DIR/d32a/ext2-mountpoint 
966         mount -t ext2 -o loop $EXT2_DEV $DIR/d32a/ext2-mountpoint || error
967         $CHECKSTAT -t dir $DIR/d32a/ext2-mountpoint/.. || error  
968         umount $DIR/d32a/ext2-mountpoint || error
969 }
970 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
971
972 test_32b() {
973         [ -e $DIR/d32b ] && rm -fr $DIR/d32b
974         mkdir -p $DIR/d32b/ext2-mountpoint 
975         mount -t ext2 -o loop $EXT2_DEV $DIR/d32b/ext2-mountpoint || error
976         ls -al $DIR/d32b/ext2-mountpoint/.. || error
977         umount $DIR/d32b/ext2-mountpoint || error
978 }
979 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
980  
981 test_32c() {
982         [ -e $DIR/d32c ] && rm -fr $DIR/d32c
983         mkdir -p $DIR/d32c/ext2-mountpoint 
984         mount -t ext2 -o loop $EXT2_DEV $DIR/d32c/ext2-mountpoint || error
985         mkdir -p $DIR/d32c/d2/test_dir    
986         $CHECKSTAT -t dir $DIR/d32c/ext2-mountpoint/../d2/test_dir || error
987         umount $DIR/d32c/ext2-mountpoint || error
988 }
989 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
990
991 test_32d() {
992         [ -e $DIR/d32d ] && rm -fr $DIR/d32d
993         mkdir -p $DIR/d32d/ext2-mountpoint 
994         mount -t ext2 -o loop $EXT2_DEV $DIR/d32d/ext2-mountpoint || error
995         mkdir -p $DIR/d32d/d2/test_dir    
996         ls -al $DIR/d32d/ext2-mountpoint/../d2/test_dir || error
997         umount $DIR/d32d/ext2-mountpoint || error
998 }
999 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir ========="
1000
1001 test_32e() {
1002         [ -e $DIR/d32e ] && rm -fr $DIR/d32e
1003         mkdir -p $DIR/d32e/tmp    
1004         TMP_DIR=$DIR/d32e/tmp       
1005         ln -s $DIR/d32e $TMP_DIR/symlink11 
1006         ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 
1007         $CHECKSTAT -t link $DIR/d32e/tmp/symlink11 || error
1008         $CHECKSTAT -t link $DIR/d32e/symlink01 || error
1009 }
1010 run_test 32e "stat d32e/symlink->tmp/symlink->lustre-subdir ===="
1011
1012 test_32f() {
1013         [ -e $DIR/d32f ] && rm -fr $DIR/d32f
1014         mkdir -p $DIR/d32f/tmp    
1015         TMP_DIR=$DIR/d32f/tmp       
1016         ln -s $DIR/d32f $TMP_DIR/symlink11 
1017         ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 
1018         ls $DIR/d32f/tmp/symlink11  || error
1019         ls $DIR/d32f/symlink01 || error
1020 }
1021 run_test 32f "open d32f/symlink->tmp/symlink->lustre-subdir ===="
1022
1023 test_32g() {
1024         [ -e $DIR/d32g ] && rm -fr $DIR/d32g
1025         [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
1026         mkdir -p $DIR/test_dir 
1027         mkdir -p $DIR/d32g/tmp    
1028         TMP_DIR=$DIR/d32g/tmp       
1029         ln -s $DIR/test_dir $TMP_DIR/symlink12 
1030         ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 
1031         $CHECKSTAT -t link $DIR/d32g/tmp/symlink12 || error
1032         $CHECKSTAT -t link $DIR/d32g/symlink02 || error
1033         $CHECKSTAT -t dir -f $DIR/d32g/tmp/symlink12 || error
1034         $CHECKSTAT -t dir -f $DIR/d32g/symlink02 || error
1035 }
1036 run_test 32g "stat d32g/symlink->tmp/symlink->lustre-subdir/test_dir"
1037
1038 test_32h() {
1039         [ -e $DIR/d32h ] && rm -fr $DIR/d32h
1040         [ -e $DIR/test_dir ] && rm -fr $DIR/test_dir
1041         mkdir -p $DIR/test_dir 
1042         mkdir -p $DIR/d32h/tmp    
1043         TMP_DIR=$DIR/d32h/tmp       
1044         ln -s $DIR/test_dir $TMP_DIR/symlink12 
1045         ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 
1046         ls $DIR/d32h/tmp/symlink12 || error
1047         ls $DIR/d32h/symlink02  || error
1048 }
1049 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/test_dir"
1050
1051 test_32i() {
1052         [ -e $DIR/d32i ] && rm -fr $DIR/d32i
1053         mkdir -p $DIR/d32i/ext2-mountpoint 
1054         mount -t ext2 -o loop $EXT2_DEV $DIR/d32i/ext2-mountpoint || error
1055         touch $DIR/d32i/test_file
1056         $CHECKSTAT -t file $DIR/d32i/ext2-mountpoint/../test_file || error  
1057         umount $DIR/d32i/ext2-mountpoint || error
1058 }
1059 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
1060
1061 test_32j() {
1062         [ -e $DIR/d32j ] && rm -fr $DIR/d32j
1063         mkdir -p $DIR/d32j/ext2-mountpoint 
1064         mount -t ext2 -o loop $EXT2_DEV $DIR/d32j/ext2-mountpoint || error
1065         touch $DIR/d32j/test_file
1066         cat $DIR/d32j/ext2-mountpoint/../test_file || error
1067         umount $DIR/d32j/ext2-mountpoint || error
1068 }
1069 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
1070
1071 test_32k() {
1072         rm -fr $DIR/d32k
1073         mkdir -p $DIR/d32k/ext2-mountpoint 
1074         mount -t ext2 -o loop $EXT2_DEV $DIR/d32k/ext2-mountpoint  
1075         mkdir -p $DIR/d32k/d2
1076         touch $DIR/d32k/d2/test_file || error
1077         $CHECKSTAT -t file $DIR/d32k/ext2-mountpoint/../d2/test_file || error
1078         umount $DIR/d32k/ext2-mountpoint || error
1079 }
1080 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
1081
1082 test_32l() {
1083         rm -fr $DIR/d32l
1084         mkdir -p $DIR/d32l/ext2-mountpoint 
1085         mount -t ext2 -o loop $EXT2_DEV $DIR/d32l/ext2-mountpoint || error
1086         mkdir -p $DIR/d32l/d2
1087         touch $DIR/d32l/d2/test_file
1088         cat  $DIR/d32l/ext2-mountpoint/../d2/test_file || error
1089         umount $DIR/d32l/ext2-mountpoint || error
1090 }
1091 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
1092
1093 test_32m() {
1094         rm -fr $DIR/d32m
1095         mkdir -p $DIR/d32m/tmp    
1096         TMP_DIR=$DIR/d32m/tmp       
1097         ln -s $DIR $TMP_DIR/symlink11 
1098         ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 
1099         $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
1100         $CHECKSTAT -t link $DIR/d32m/symlink01 || error
1101 }
1102 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
1103
1104 test_32n() {
1105         rm -fr $DIR/d32n
1106         mkdir -p $DIR/d32n/tmp    
1107         TMP_DIR=$DIR/d32n/tmp       
1108         ln -s $DIR $TMP_DIR/symlink11 
1109         ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01 
1110         ls -l $DIR/d32n/tmp/symlink11  || error
1111         ls -l $DIR/d32n/symlink01 || error
1112 }
1113 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
1114
1115 test_32o() {
1116         rm -fr $DIR/d32o
1117         rm -f $DIR/test_file
1118         touch $DIR/test_file 
1119         mkdir -p $DIR/d32o/tmp    
1120         TMP_DIR=$DIR/d32o/tmp       
1121         ln -s $DIR/test_file $TMP_DIR/symlink12 
1122         ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 
1123         $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
1124         $CHECKSTAT -t link $DIR/d32o/symlink02 || error
1125         $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
1126         $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
1127 }
1128 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/test_file"
1129
1130 test_32p() {
1131     log 32p_1
1132         rm -fr $DIR/d32p
1133     log 32p_2
1134         rm -f $DIR/test_file
1135     log 32p_3
1136         touch $DIR/test_file 
1137     log 32p_4
1138         mkdir -p $DIR/d32p/tmp    
1139     log 32p_5
1140         TMP_DIR=$DIR/d32p/tmp       
1141     log 32p_6
1142         ln -s $DIR/test_file $TMP_DIR/symlink12 
1143     log 32p_7
1144         ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02 
1145     log 32p_8
1146         cat $DIR/d32p/tmp/symlink12 || error
1147     log 32p_9
1148         cat $DIR/d32p/symlink02 || error
1149     log 32p_10
1150 }
1151 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/test_file"
1152
1153 test_32q() {
1154         [ -e $DIR/d32q ] && rm -fr $DIR/d32q
1155         mkdir -p $DIR/d32q
1156         touch $DIR/d32q/under_the_mount
1157         mount -t ext2 -o loop $EXT2_DEV $DIR/d32q
1158         ls $DIR/d32q/under_the_mount && error || true
1159         umount $DIR/d32q || error
1160 }
1161 run_test 32q "stat follows mountpoints in Lustre (should return error)"
1162
1163 test_32r() {
1164         [ -e $DIR/d32r ] && rm -fr $DIR/d32r
1165         mkdir -p $DIR/d32r
1166         touch $DIR/d32r/under_the_mount
1167         mount -t ext2 -o loop $EXT2_DEV $DIR/d32r
1168         ls $DIR/d32r | grep -q under_the_mount && error || true
1169         umount $DIR/d32r || error
1170 }
1171 run_test 32r "opendir follows mountpoints in Lustre (should return error)"
1172
1173 #   chmod 444 /mnt/lustre/somefile
1174 #   open(/mnt/lustre/somefile, O_RDWR)
1175 #   Should return -1
1176 test_33() {
1177         rm -f $DIR/test_33_file
1178         touch $DIR/test_33_file
1179         chmod 444 $DIR/test_33_file
1180         chown $RUNAS_ID $DIR/test_33_file
1181         log 33_1
1182         $RUNAS $OPENFILE -f O_RDWR $DIR/test_33_file && error || true
1183         log 33_2
1184 }
1185 run_test 33 "write file with mode 444 (should return error) ===="
1186                                                                                                                                                
1187 test_33a() {
1188         rm -fr $DIR/d33
1189         mkdir -p $DIR/d33
1190         chown $RUNAS_ID $DIR/d33
1191         $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 || error
1192         $RUNAS $OPENFILE -f O_RDWR:O_CREAT -m 0444 $DIR/d33/f33 && error || true
1193 }
1194 run_test 33a "test open file(mode=0444) with O_RDWR (should return error)"
1195
1196 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
1197 test_34a() {
1198         rm -f $DIR/f34
1199         $MCREATE $DIR/f34 || error
1200         $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1201         $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
1202         $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1203         $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1204 }
1205 run_test 34a "truncate file that has not been opened ==========="
1206
1207 test_34b() {
1208         [ ! -f $DIR/f34 ] && test_34a
1209         $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1210         $OPENFILE -f O_RDONLY $DIR/f34
1211         $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" || error
1212         $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1213 }
1214 run_test 34b "O_RDONLY opening file doesn't create objects ====="
1215
1216 test_34c() {
1217         [ ! -f $DIR/f34 ] && test_34a 
1218         $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1219         $OPENFILE -f O_RDWR $DIR/f34
1220         $LFIND $DIR/f34 2>&1 | grep -q "no stripe info" && error
1221         $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1222 }
1223 run_test 34c "O_RDWR opening file-with-size works =============="
1224
1225 test_34d() {
1226         [ ! -f $DIR/f34 ] && test_34a 
1227         dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
1228         $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
1229         rm $DIR/f34
1230 }
1231 run_test 34d "write to sparse file ============================="
1232
1233 test_34e() {
1234         rm -f $DIR/f34e
1235         $MCREATE $DIR/f34e || error
1236         $TRUNCATE $DIR/f34e 1000 || error
1237         $CHECKSTAT -s 1000 $DIR/f34e || error
1238         $OPENFILE -f O_RDWR $DIR/f34e
1239         $CHECKSTAT -s 1000 $DIR/f34e || error
1240 }
1241 run_test 34e "create objects, some with size and some without =="
1242
1243 test_35a() {
1244         cp /bin/sh $DIR/f35a
1245         chmod 444 $DIR/f35a
1246         chown $RUNAS_ID $DIR/f35a
1247         $RUNAS $DIR/f35a && error || true
1248         rm $DIR/f35a
1249 }
1250 run_test 35a "exec file with mode 444 (should return and not leak) ====="
1251
1252 test_36a() {
1253         rm -f $DIR/f36
1254         utime $DIR/f36 || error
1255 }
1256 run_test 36a "MDS utime check (mknod, utime) ==================="
1257
1258 test_36b() {
1259         echo "" > $DIR/f36
1260         utime $DIR/f36 || error
1261 }
1262 run_test 36b "OST utime check (open, utime) ===================="
1263
1264 test_36c() {
1265         rm -f $DIR/d36/f36
1266         mkdir $DIR/d36
1267         chown $RUNAS_ID $DIR/d36
1268         $RUNAS utime $DIR/d36/f36 || error
1269 }
1270 run_test 36c "non-root MDS utime check (mknod, utime) =========="
1271
1272 test_36d() {
1273         [ ! -d $DIR/d36 ] && test_36c
1274         echo "" > $DIR/d36/f36
1275         $RUNAS utime $DIR/d36/f36 || error
1276 }
1277 run_test 36d "non-root OST utime check (open, utime) ==========="
1278
1279 test_36e() {
1280         [ $RUNAS_ID -eq $UID ] && echo "skipping test 36e" && return
1281         [ ! -d $DIR/d36 ] && mkdir $DIR/d36
1282         touch $DIR/d36/f36e
1283         $RUNAS utime $DIR/d36/f36e && error "utime worked, want failure" || true
1284 }
1285 run_test 36e "utime on non-owned file (should return error) ===="
1286
1287 test_37() {
1288         mkdir -p $DIR/dextra
1289         echo f > $DIR/dextra/fbugfile
1290         mount -t ext2 -o loop $EXT2_DEV $DIR/dextra
1291         ls $DIR/dextra | grep "\<fbugfile\>" && error
1292         umount $DIR/dextra || error
1293         rm -f $DIR/dextra/fbugfile || error
1294 }
1295 run_test 37 "ls a mounted file system to check old content ====="
1296
1297 test_38() {
1298         o_directory $DIR/test38
1299 }
1300 run_test 38 "open a regular file with O_DIRECTORY =============="
1301
1302 test_39() {
1303         touch $DIR/test_39_file
1304         touch $DIR/test_39_file2
1305 #       ls -l  $DIR/test_39_file $DIR/test_39_file2
1306 #       ls -lu  $DIR/test_39_file $DIR/test_39_file2
1307 #       ls -lc  $DIR/test_39_file $DIR/test_39_file2
1308         sleep 2
1309         $OPENFILE -f O_CREAT:O_TRUNC:O_WRONLY $DIR/test_39_file2
1310 #       ls -l  $DIR/test_39_file $DIR/test_39_file2
1311 #       ls -lu  $DIR/test_39_file $DIR/test_39_file2
1312 #       ls -lc  $DIR/test_39_file $DIR/test_39_file2
1313         [ $DIR/test_39_file2 -nt $DIR/test_39_file ] || error
1314 }
1315 run_test 39 "mtime changed on create ==========================="
1316
1317 test_40() {
1318         dd if=/dev/zero of=$DIR/f40 bs=4096 count=1
1319         $RUNAS $OPENFILE -f O_WRONLY:O_TRUNC $DIR/f40 && error
1320         $CHECKSTAT -t file -s 4096 $DIR/f40 || error
1321 }
1322 run_test 40 "failed open(O_TRUNC) doesn't truncate ============="
1323
1324 test_41() {
1325         # bug 1553
1326         small_write $DIR/f41 18
1327 }
1328 run_test 41 "test small file write + fstat ====================="
1329
1330 count_ost_writes() {
1331         cat /proc/fs/lustre/osc/*/stats |
1332             awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
1333 }
1334
1335 # decent default
1336 WRITEBACK_SAVE=500
1337
1338 start_writeback() {
1339         # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs
1340         if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1341                 echo $WRITEBACK_SAVE > /proc/sys/vm/dirty_writeback_centisecs
1342         else
1343                 # if file not here, we are a 2.4 kernel
1344                 kill -CONT `pidof kupdated`
1345         fi
1346 }
1347 stop_writeback() {
1348         # setup the trap first, so someone cannot exit the test at the
1349         # exact wrong time and mess up a machine
1350         trap start_writeback EXIT
1351         # in 2.6, save and 0 /proc/sys/vm/dirty_writeback_centisecs
1352         if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
1353                 WRITEBACK_SAVE=`cat /proc/sys/vm/dirty_writeback_centisecs`
1354                 echo 0 > /proc/sys/vm/dirty_writeback_centisecs
1355         else
1356                 # if file not here, we are a 2.4 kernel
1357                 kill -STOP `pidof kupdated`
1358         fi
1359 }
1360
1361 # ensure that all stripes have some grant before we test client-side cache
1362 setup_test42() {
1363         [ "$SETUP_TEST42" ] && return
1364         for i in `seq -f $DIR/f42-%g 1 $OSTCOUNT`; do
1365                 dd if=/dev/zero of=$i bs=4k count=1
1366                 rm $i
1367         done
1368         SETUP_TEST42=DONE
1369 }
1370
1371 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
1372 # file truncation, and file removal.
1373 test_42a() {
1374         setup_test42
1375         cancel_lru_locks OSC
1376         stop_writeback
1377         sync; sleep 1; sync # just to be safe
1378         BEFOREWRITES=`count_ost_writes`
1379         grep [0-9] /proc/fs/lustre/osc/OSC*MNT*/cur_grant_bytes
1380         dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
1381         AFTERWRITES=`count_ost_writes`
1382         [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1383                 error "$BEFOREWRITES < $AFTERWRITES"
1384         start_writeback
1385 }
1386 run_test 42a "ensure that we don't flush on close =============="
1387
1388 test_42b() {
1389         setup_test42
1390         cancel_lru_locks OSC
1391         stop_writeback
1392         sync
1393         dd if=/dev/zero of=$DIR/f42b bs=1024 count=100
1394         BEFOREWRITES=`count_ost_writes`
1395         $MUNLINK $DIR/f42b || error "$MUNLINK $DIR/f42b: $?"
1396         AFTERWRITES=`count_ost_writes`
1397         [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1398             error "$BEFOREWRITES < $AFTERWRITES on unlink"
1399         BEFOREWRITES=`count_ost_writes`
1400         sync || error "sync: $?"
1401         AFTERWRITES=`count_ost_writes`
1402         [ $BEFOREWRITES -eq $AFTERWRITES ] ||
1403             error "$BEFOREWRITES < $AFTERWRITES on sync"
1404         dmesg | grep 'error from obd_brw_async' && error 'error writing back'
1405         start_writeback
1406         return 0
1407 }
1408 run_test 42b "test destroy of file with cached dirty data ======"
1409
1410 # if these tests just want to test the effect of truncation,
1411 # they have to be very careful.  consider:
1412 # - the first open gets a {0,EOF}PR lock
1413 # - the first write conflicts and gets a {0, count-1}PW
1414 # - the rest of the writes are under {count,EOF}PW
1415 # - the open for truncate tries to match a {0,EOF}PR
1416 #   for the filesize and cancels the PWs.
1417 # any number of fixes (don't get {0,EOF} on open, match
1418 # composite locks, do smarter file size management) fix
1419 # this, but for now we want these tests to verify that
1420 # the cancellation with truncate intent works, so we
1421 # start the file with a full-file pw lock to match against
1422 # until the truncate.
1423 trunc_test() {
1424         test=$1
1425         file=$DIR/$test
1426         offset=$2
1427         cancel_lru_locks OSC
1428         stop_writeback
1429         # prime the file with 0,EOF PW to match
1430         touch $file
1431         $TRUNCATE $file 0
1432         sync; sync
1433         # now the real test..
1434         dd if=/dev/zero of=$file bs=1024 count=100
1435         BEFOREWRITES=`count_ost_writes`
1436         $TRUNCATE $file $offset
1437         cancel_lru_locks OSC
1438         AFTERWRITES=`count_ost_writes`
1439         start_writeback
1440 }
1441
1442 test_42c() {
1443         trunc_test 42c 1024
1444         [ $BEFOREWRITES -eq $AFTERWRITES ] && \
1445                 error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
1446         rm $file
1447 }
1448 run_test 42c "test partial truncate of file with cached dirty data"
1449
1450 test_42d() {
1451         trunc_test 42d 0
1452         [ $BEFOREWRITES -eq $AFTERWRITES ] || \
1453             error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
1454         rm $file
1455 }
1456 run_test 42d "test complete truncate of file with cached dirty data"
1457
1458 test_43() {
1459         mkdir $DIR/d43
1460         cp -p /bin/ls $DIR/d43/f
1461         exec 100>> $DIR/d43/f
1462         $DIR/d43/f && error || true
1463         exec 100<&-
1464 }
1465 run_test 43 "execution of file opened for write should return -ETXTBSY"
1466
1467 test_43a() {
1468         mkdir -p $DIR/d43
1469         cp -p `which multiop` $DIR/d43/multiop
1470         $DIR/d43/multiop $TMP/test43.junk O_c &
1471         MULTIPID=$!
1472         sleep 1
1473         multiop $DIR/d43/multiop Oc && error "expected error, got success"
1474         kill -USR1 $MULTIPID || return 2
1475         wait $MULTIPID || return 3
1476 }
1477 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
1478
1479 test_43b() {
1480         mkdir -p $DIR/d43
1481         cp -p `which multiop` $DIR/d43/multiop
1482         $DIR/d43/multiop $TMP/test43.junk O_c &
1483         MULTIPID=$!
1484         sleep 1
1485         truncate $DIR/d43/multiop 0 && error "expected error, got success"
1486         kill -USR1 $MULTIPID || return 2
1487         wait $MULTIPID || return 3
1488 }
1489 run_test 43b "truncate of file being executed should return -ETXTBSY"
1490
1491 test_43c() {
1492         local testdir="$DIR/d43c"
1493         mkdir -p $testdir
1494         cp $SHELL $testdir/
1495         ( cd $(dirname $SHELL) && md5sum $(basename $SHELL) ) | \
1496                 ( cd $testdir && md5sum -c)
1497 }
1498 run_test 43c "md5sum of copy into lustre========================"
1499
1500 test_44() {
1501         [  "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
1502         dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
1503         dd if=$DIR/f1 bs=4k count=1
1504 }
1505 run_test 44 "zero length read from a sparse stripe ============="
1506
1507 test_44a() {
1508     local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
1509                          awk '{print $2}'`
1510     local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
1511                       awk '{print $2}'`
1512     if [ $nstripe -eq 0 ] ; then
1513         nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
1514     fi
1515
1516     OFFSETS="0 $((stride/2)) $((stride-1))"
1517     for offset in $OFFSETS ; do
1518       for i in `seq 0 $((nstripe-1))`; do
1519         rm -f $DIR/d44a
1520         local GLOBALOFFSETS=""
1521         local size=$((((i + 2 * $nstripe )*$stride + $offset)))  # Bytes
1522         ll_sparseness_write $DIR/d44a $size  || error "ll_sparseness_write"
1523         GLOBALOFFSETS="$GLOBALOFFSETS $size"
1524         ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1525                             || error "ll_sparseness_verify $GLOBALOFFSETS"
1526
1527         for j in `seq 0 $((nstripe-1))`; do
1528             size=$((((j + $nstripe )*$stride + $offset)))  # Bytes
1529             ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
1530             GLOBALOFFSETS="$GLOBALOFFSETS $size"
1531         done
1532         ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
1533                             || error "ll_sparseness_verify $GLOBALOFFSETS"
1534       done
1535     done
1536 }
1537 run_test 44a "test sparse pwrite ==============================="
1538
1539 dirty_osc_total() {
1540         tot=0
1541         for d in /proc/fs/lustre/osc/*/cur_dirty_bytes; do
1542                 tot=$(($tot + `cat $d`))
1543         done
1544         echo $tot
1545 }
1546 do_dirty_record() {
1547         before=`dirty_osc_total`
1548         echo executing "\"$*\""
1549         eval $*
1550         after=`dirty_osc_total`
1551         echo before $before, after $after
1552 }
1553 test_45() {
1554         f="$DIR/f45"
1555         # Obtain grants from OST if it supports it
1556         echo blah > ${f}_grant
1557         stop_writeback
1558         sync
1559         do_dirty_record "echo blah > $f"
1560         [ $before -eq $after ] && error "write wasn't cached"
1561         do_dirty_record "> $f"
1562         [ $before -gt $after ] || error "truncate didn't lower dirty count"
1563         do_dirty_record "echo blah > $f"
1564         [ $before -eq $after ] && error "write wasn't cached"
1565         do_dirty_record "sync"
1566         [ $before -gt $after ] || error "writeback didn't lower dirty count"
1567         do_dirty_record "echo blah > $f"
1568         [ $before -eq $after ] && error "write wasn't cached"
1569         do_dirty_record "cancel_lru_locks OSC"
1570         [ $before -gt $after ] || error "lock cancellation didn't lower dirty count"
1571         start_writeback
1572 }
1573 run_test 45 "osc io page accounting ============================"
1574
1575 page_size() {
1576         getconf PAGE_SIZE
1577 }
1578
1579 # in a 2 stripe file (lov.sh), page 1023 maps to page 511 in its object.  this
1580 # test tickles a bug where re-dirtying a page was failing to be mapped to the
1581 # objects offset and an assert hit when an rpc was built with 1023's mapped 
1582 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
1583 test_46() {
1584         f="$DIR/f46"
1585         stop_writeback
1586         sync
1587         dd if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1588         sync
1589         dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=1023 count=1
1590         dd conv=notrunc if=/dev/zero of=$f bs=`page_size` seek=511 count=1
1591         sync
1592         start_writeback
1593 }
1594 run_test 46 "dirtying a previously written page ================"
1595
1596 # Check that device nodes are created and then visible correctly (#2091)
1597 test_47() {
1598         cmknod $DIR/test_47_node || error
1599 }
1600 run_test 47 "Device nodes check ================================"
1601
1602 test_48a() { # bug 2399
1603         check_kernel_version 34 || return 0
1604         mkdir -p $DIR/d48a
1605         cd $DIR/d48a
1606         mv $DIR/d48a $DIR/d48.new || error "move directory failed"
1607         mkdir $DIR/d48a || error "recreate directory failed"
1608         touch foo || error "'touch foo' failed after recreating cwd"
1609         mkdir bar || error "'mkdir foo' failed after recreating cwd"
1610         ls . || error "'ls .' failed after recreating cwd"
1611         ls .. || error "'ls ..' failed after removing cwd"
1612         cd . || error "'cd .' failed after recreating cwd"
1613         mkdir . && error "'mkdir .' worked after recreating cwd"
1614         rmdir . && error "'rmdir .' worked after recreating cwd"
1615         ln -s . baz || error "'ln -s .' failed after recreating cwd"
1616         cd .. || error "'cd ..' failed after recreating cwd"
1617 }
1618 run_test 48a "Access renamed working dir (should return errors)="
1619
1620 test_48b() { # bug 2399
1621         check_kernel_version 34 || return 0
1622         mkdir -p $DIR/d48b
1623         cd $DIR/d48b
1624         rmdir $DIR/d48b || error "remove cwd $DIR/d48b failed"
1625         touch foo && error "'touch foo' worked after removing cwd"
1626         mkdir foo && error "'mkdir foo' worked after removing cwd"
1627         ls . && error "'ls .' worked after removing cwd"
1628         ls .. || error "'ls ..' failed after removing cwd"
1629         cd . && error "'cd .' worked after removing cwd"
1630         mkdir . && error "'mkdir .' worked after removing cwd"
1631         rmdir . && error "'rmdir .' worked after removing cwd"
1632         ln -s . foo && error "'ln -s .' worked after removing cwd"
1633         cd .. || echo "'cd ..' failed after removing cwd `pwd`"  #bug 3517
1634
1635 }
1636 run_test 48b "Access removed working dir (should return errors)="
1637
1638 test_48c() { # bug 2350
1639         check_kernel_version 36 || return 0
1640         #sysctl -w portals.debug=-1
1641         #set -vx
1642         mkdir -p $DIR/d48c/dir
1643         cd $DIR/d48c/dir
1644         $TRACE rmdir $DIR/d48c/dir || error "remove cwd $DIR/d48c/dir failed"
1645         $TRACE touch foo && error "'touch foo' worked after removing cwd"
1646         $TRACE mkdir foo && error "'mkdir foo' worked after removing cwd"
1647         $TRACE ls . && error "'ls .' worked after removing cwd"
1648         $TRACE ls .. || error "'ls ..' failed after removing cwd"
1649         $TRACE cd . && error "'cd .' worked after removing cwd"
1650         $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
1651         $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
1652         $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
1653         $TRACE cd .. || echo "'cd ..' failed after removing cwd `pwd`" #bug 3415
1654 }
1655 run_test 48c "Access removed working subdir (should return errors)"
1656
1657 test_48d() { # bug 2350
1658         check_kernel_version 36 || return 0
1659         #sysctl -w portals.debug=-1
1660         #set -vx
1661         mkdir -p $DIR/d48d/dir
1662         cd $DIR/d48d/dir
1663         $TRACE rmdir $DIR/d48d/dir || error "remove cwd $DIR/d48d/dir failed"
1664         $TRACE rmdir $DIR/d48d || error "remove parent $DIR/d48d failed"
1665         $TRACE touch foo && error "'touch foo' worked after removing parent"
1666         $TRACE mkdir foo && error "'mkdir foo' worked after removing parent"
1667         $TRACE ls . && error "'ls .' worked after removing parent"
1668         $TRACE ls .. && error "'ls ..' worked after removing parent"
1669         $TRACE cd . && error "'cd .' worked after recreate parent"
1670         $TRACE mkdir . && error "'mkdir .' worked after removing parent"
1671         $TRACE rmdir . && error "'rmdir .' worked after removing parent"
1672         $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
1673         $TRACE cd .. && error "'cd ..' worked after removing parent" || true
1674 }
1675 run_test 48d "Access removed parent subdir (should return errors)"
1676
1677 test_50() {
1678         # bug 1485
1679         mkdir $DIR/d50
1680         cd $DIR/d50
1681         ls /proc/$$/cwd || error
1682 }
1683 run_test 50 "special situations: /proc symlinks  ==============="
1684
1685 test_51() {
1686         # bug 1516 - create an empty entry right after ".." then split dir
1687         mkdir $DIR/d49
1688         touch $DIR/d49/foo
1689         $MCREATE $DIR/d49/bar
1690         rm $DIR/d49/foo
1691         createmany -m $DIR/d49/longfile 201
1692         FNUM=202
1693         while [ `ls -sd $DIR/d49 | awk '{ print $1 }'` -eq 4 ]; do
1694                 $MCREATE $DIR/d49/longfile$FNUM
1695                 FNUM=$(($FNUM + 1))
1696                 echo -n "+"
1697         done
1698         ls -l $DIR/d49 > /dev/null || error
1699 }
1700 run_test 51 "special situations: split htree with empty entry =="
1701
1702 test_51b() {
1703        NUMTEST=70000
1704        check_kernel_version 40 || NUMTEST=31000
1705        NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
1706        [ $NUMFREE -lt $NUMTEST ] && \
1707                echo "skipping test 51b, not enough free inodes($NUMFREE)" && \
1708                return
1709        mkdir -p $DIR/d51b
1710        (cd $DIR/d51b; mkdirmany t $NUMTEST)
1711 }
1712 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
1713
1714 test_51c() {
1715        NUMTEST=70000
1716        check_kernel_version 40 || NUMTEST=31000
1717        NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
1718        [ $NUMFREE -lt $NUMTEST ] && echo "skipping test 51c" && return
1719        mkdir -p $DIR/d51b
1720        (cd $DIR/d51b; rmdirmany t $NUMTEST)
1721 }
1722 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
1723
1724 test_52a() {
1725         [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
1726         mkdir -p $DIR/d52a
1727         touch $DIR/d52a/foo
1728         chattr =a $DIR/d52a/foo || error
1729         echo bar >> $DIR/d52a/foo || error
1730         cp /etc/hosts $DIR/d52a/foo && error
1731         rm -f $DIR/d52a/foo 2>/dev/null && error
1732         link $DIR/d52a/foo $DIR/d52a/foo_link 2>/dev/null && error
1733         echo foo >> $DIR/d52a/foo || error
1734         mrename $DIR/d52a/foo $DIR/d52a/foo_ren && error
1735         lsattr $DIR/d52a/foo | egrep -q "^-+a-+ $DIR/d52a/foo" || error
1736         chattr -a $DIR/d52a/foo || error
1737
1738         rm -fr $DIR/d52a || error
1739 }
1740 run_test 52a "append-only flag test (should return errors) ====="
1741
1742 test_52b() {
1743         [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
1744         mkdir -p $DIR/d52b
1745         touch $DIR/d52b/foo
1746         chattr =i $DIR/d52b/foo || error
1747         cat test > $DIR/d52b/foo && error
1748         cp /etc/hosts $DIR/d52b/foo && error
1749         rm -f $DIR/d52b/foo 2>/dev/null && error
1750         link $DIR/d52b/foo $DIR/d52b/foo_link 2>/dev/null && error
1751         echo foo >> $DIR/d52b/foo && error
1752         mrename $DIR/d52b/foo $DIR/d52b/foo_ren && error
1753         [ -f $DIR/d52b/foo ] || error
1754         [ -f $DIR/d52b/foo_ren ] && error
1755         lsattr $DIR/d52b/foo | egrep -q "^-+i-+ $DIR/d52b/foo" || error
1756         chattr -i $DIR/d52b/foo || error
1757
1758         rm -fr $DIR/d52b || error
1759 }
1760 run_test 52b "immutable flag test (should return errors) ======="
1761
1762 test_53() {
1763         for i in `ls -d /proc/fs/lustre/osc/OSC*mds1 2> /dev/null` ; do
1764                 ostname=`echo $i | cut -d _ -f 3-4 | sed -e s/_mds1//`
1765                 ost_last=`cat /proc/fs/lustre/obdfilter/$ostname/last_id`
1766                 mds_last=`cat $i/prealloc_last_id`
1767                 echo "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1768                 if [ $ost_last != $mds_last ]; then
1769                     error "$ostname.last_id=$ost_last ; MDS.last_id=$mds_last"
1770                 fi
1771         done
1772 }
1773 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
1774
1775 test_54a() {
1776         $SOCKETSERVER $DIR/socket
1777         $SOCKETCLIENT $DIR/socket || error
1778         $MUNLINK $DIR/socket
1779 }
1780 run_test 54a "unix damain socket test =========================="
1781
1782 test_54b() {
1783         f="$DIR/f54b"
1784         mknod $f c 1 3
1785         chmod 0666 $f
1786         dd if=/dev/zero of=$f bs=`page_size` count=1 
1787 }
1788 run_test 54b "char device works in lustre ======================"
1789
1790 find_loop_dev() {
1791        [ "$LOOPNUM" ] && return
1792        [ -b /dev/loop/0 ] && LOOPBASE=/dev/loop/
1793        [ -b /dev/loop0 ] && LOOPBASE=/dev/loop
1794        [ -z "$LOOPBASE" ] && echo "/dev/loop/0 and /dev/loop0 gone?" && return
1795
1796        for i in `seq 3 7`; do
1797                losetup $LOOPBASE$i > /dev/null 2>&1 && continue
1798                LOOPDEV=$LOOPBASE$i
1799                LOOPNUM=$i
1800                break
1801        done
1802 }
1803
1804 test_54c() {
1805         tfile="$DIR/f54c"
1806         tdir="$DIR/d54c"
1807         loopdev="$DIR/loop54c"
1808         
1809         find_loop_dev
1810         [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
1811         mknod $loopdev b 7 $LOOPNUM
1812         echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
1813         
1814         dd if=/dev/zero of=$tfile bs=`page_size` seek=1024 count=1 > /dev/null
1815         losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
1816         mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
1817         mkdir -p $tdir
1818         mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
1819         dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
1820         df $tdir
1821         dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
1822         umount $tdir
1823         losetup -d $loopdev
1824         rm $loopdev
1825 }
1826 run_test 54c "block device works in lustre ====================="
1827
1828 test_54d() {
1829         f="$DIR/f54d"
1830         string="aaaaaa"
1831         mknod $f p
1832         [ "$string" = `echo $string > $f | cat $f` ] || error
1833 }
1834 run_test 54d "fifo device works in lustre ======================"
1835
1836 check_fstype() {
1837        grep -q $FSTYPE /proc/filesystems && return 0
1838        modprobe $FSTYPE
1839        grep -q $FSTYPE /proc/filesystems && return 0
1840        insmod ../$FSTYPE/$FSTYPE.o
1841        grep -q $FSTYPE /proc/filesystems && return 0
1842        return 1
1843 }
1844
1845 test_55() {
1846         rm -rf $DIR/d55
1847         mkdir $DIR/d55
1848         check_fstype && echo "can't find fs $FSTYPE, skipping test 55" && return
1849         mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
1850         touch $DIR/d55/foo
1851         $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
1852         $IOPENTEST2 $DIR/d55 || error "running $IOPENTEST2"
1853         echo "check for $EXT2_DEV. Please wait..."
1854         rm -rf $DIR/d55/*
1855         umount $DIR/d55 || error "unmounting"
1856 }
1857 run_test 55 "check iopen_connect_dentry() ======================"
1858
1859 test_56() {
1860         rm -rf $DIR/d56
1861         mkdir $DIR/d56
1862         mkdir $DIR/d56/dir
1863         NUMFILES=3
1864         NUMFILESx2=$(($NUMFILES * 2))
1865         for i in `seq 1 $NUMFILES` ; do
1866                 touch $DIR/d56/file$i
1867                 touch $DIR/d56/dir/file$i
1868         done
1869
1870         # test lfs find with --recursive
1871         FILENUM=`$LFIND --recursive $DIR/d56 | grep -v OBDS | grep -c obdidx`
1872         [ $FILENUM -eq $NUMFILESx2 ] || error \
1873                 "lfs find --recursive $DIR/d56 wrong: found $FILENUM, expected $NUMFILESx2"
1874         FILENUM=`$LFIND $DIR/d56 | grep -v OBDS | grep -c obdidx`
1875         [ $FILENUM -eq $NUMFILES ] || error \
1876                 "lfs find $DIR/d56 without --recursive wrong: found $FILENUM,
1877                 expected $NUMFILES"
1878         echo "lfs find --recursive passed."
1879
1880         # test lfs find with file instead of dir
1881         FILENUM=`$LFIND $DIR/d56/file1 | grep -v OBDS | grep -c obdidx`
1882         [ $FILENUM  -eq 1 ] || error \
1883                  "lfs find $DIR/d56/file1 wrong: found $FILENUM, expected 1"
1884         echo "lfs find file passed."
1885
1886         #test lfs find with --verbose
1887         [ `$LFIND --verbose $DIR/d56 | grep -v OBDS | grep -c lmm_magic` -eq $NUMFILES ] ||\
1888                 error "lfs find --verbose $DIR/d56 wrong: should find $NUMFILES lmm_magic info"
1889         [ `$LFIND $DIR/d56 | grep -v OBDS | grep -c lmm_magic` -eq 0 ] || error \
1890                 "lfs find $DIR/d56 without --verbose wrong: should not show lmm_magic info"
1891         echo "lfs find --verbose passed."
1892
1893         #test lfs find with --obd
1894         $LFIND --obd wrong_uuid $DIR/d56 2>&1 | grep -q "unknown obduuid" || \
1895                 error "lfs find --obd wrong_uuid should return error information"
1896
1897         [  "$OSTCOUNT" -lt 2 ] && \
1898                 echo "skipping other lfs find --obd test" && return
1899         FILENUM=`$LFIND --recursive $DIR/d56 | grep -v OBDS | grep obdidx | wc -l`
1900         OBDUUID=`$LFIND --recursive $DIR/d56 | grep -A 1 OBDS | grep -v OBDS | awk '{print $3}'`
1901         OBDIDX=`$LFIND --recursive $DIR/d56 | grep -A 1 OBDS | grep -v OBDS | awk '{print $1}'`
1902         FOUND=`$LFIND --recursive --obd $OBDUUID $DIR/d56 | wc -l`
1903
1904         [ $FOUND -eq $FILENUM ] || \
1905                 error "lfs find --obd wrong: found $FOUND, expected $FILENUM"
1906
1907         [ `$LFIND -r -v --obd $OBDUUID $DIR/d56 | grep "^[[:blank:]]*$OBDIDX" | wc -l` ] || \
1908                 error "lfs find --obd wrong: should not show file on other obd"
1909
1910         echo "lfs find --obd passed."
1911 }
1912 run_test 56 "check lfs find ===================================="
1913
1914 test_57a() {
1915         # note test will not do anything if MDS is not local
1916         for DEV in `cat /proc/fs/lustre/mds/*/mntdev`; do
1917                 dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
1918                 DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
1919                 [ "$DEVISIZE" -gt 128 ] || error "inode size $DEVISIZE"
1920                 rm $TMP/t57a.dump
1921         done
1922 }
1923 run_test 57a "verify MDS filesystem created with large inodes =="
1924
1925 test_57b() {
1926         FILECOUNT=100
1927         FILE1=$DIR/d57b/f1
1928         FILEN=$DIR/d57b/f$FILECOUNT
1929         rm -rf $DIR/d57b || error "removing $DIR/d57b"
1930         mkdir -p $DIR/d57b || error "creating $DIR/d57b"
1931         echo "mcreating $FILECOUNT files"
1932         createmany -m $DIR/d57b/f 1 $FILECOUNT || \
1933                 error "creating files in $DIR/d57b"
1934
1935         # verify that files do not have EAs yet
1936         $LFIND $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
1937         $LFIND $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
1938
1939         MDSFREE="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1940         MDCFREE="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1941         echo "opening files to create objects/EAs"
1942         for FILE in `seq -f $DIR/d57b/f%g 1 $FILECOUNT`; do
1943                 $OPENFILE -f O_RDWR $FILE > /dev/null || error "opening $FILE"
1944         done
1945
1946         # verify that files have EAs now
1947         $LFIND $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
1948         $LFIND $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
1949
1950         MDSFREE2="`cat /proc/fs/lustre/mds/*/kbytesfree`"
1951         MDCFREE2="`cat /proc/fs/lustre/mdc/*/kbytesfree`"
1952         if [ "$MDCFREE" != "$MDCFREE2" ]; then
1953                 if [ "$MDSFREE" != "$MDSFREE2" ]; then
1954                         error "MDC before $MDCFREE != after $MDCFREE2"
1955                 else
1956                         echo "MDC before $MDCFREE != after $MDCFREE2"
1957                         echo "unable to confirm if MDS has large inodes"
1958                 fi
1959         fi
1960         rm -rf $DIR/d57b
1961 }
1962 run_test 57b "default LOV EAs are stored inside large inodes ==="
1963
1964 test_58() {
1965         wiretest
1966 }
1967 run_test 58 "verify cross-platform wire constants =============="
1968
1969 test_59() {
1970         echo "touch 130 files"
1971         for i in `seq 1 130` ; do
1972                 touch $DIR/59-$i
1973         done
1974         echo "rm 130 files"
1975         for i in `seq 1 130` ; do
1976                 rm -f $DIR/59-$i
1977         done
1978         sync
1979         sleep 2
1980         # wait for commitment of removal
1981 }
1982 run_test 59 "verify cancellation of llog records async ========="
1983
1984 test_60() {
1985         echo 60 "llog tests run from kernel mode"
1986         sh run-llog.sh
1987 }
1988 run_test 60 "llog sanity tests run from kernel module =========="
1989
1990 test_61() {
1991         f="$DIR/f61"
1992         dd if=/dev/zero of=$f bs=`page_size` count=1
1993         cancel_lru_locks OSC
1994         multiop $f OSMWUc || error
1995         sync
1996 }
1997 run_test 61 "mmap() writes don't make sync hang ================"
1998
1999 # bug 2330 - insufficient obd_match error checking causes LBUG
2000 test_62() {
2001         f="$DIR/f62"
2002         echo foo > $f
2003         cancel_lru_locks OSC
2004         echo 0x405 > /proc/sys/lustre/fail_loc
2005         cat $f && error "cat succeeded, expect -EIO"
2006         echo 0 > /proc/sys/lustre/fail_loc
2007 }
2008 run_test 62 "verify obd_match failure doesn't LBUG (should -EIO)"
2009
2010 # bug 2319 - oig_wait() interrupted causes crash because of invalid waitq.
2011 test_63() {
2012         MAX_DIRTY_MB=`cat /proc/fs/lustre/osc/*/max_dirty_mb | head -n 1`
2013         for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
2014                 echo 0 > $i
2015         done
2016         for i in `seq 10` ; do
2017                 dd if=/dev/zero of=$DIR/f63 bs=8k &
2018                 sleep 5
2019                 kill $!
2020                 sleep 1
2021         done
2022
2023         for i in /proc/fs/lustre/osc/*/max_dirty_mb ; do
2024                 echo $MAX_DIRTY_MB > $i
2025         done
2026         true
2027 }
2028 run_test 63 "Verify oig_wait interruption does not crash ======"
2029
2030 test_64a () {
2031         df $DIR
2032         grep "[0-9]" /proc/fs/lustre/osc/OSC*MNT*/cur*
2033 }
2034 run_test 64a "verify filter grant calculations (in kernel) ====="
2035
2036 test_64b () {
2037         sh oos.sh $MOUNT
2038 }
2039 run_test 64b "check out-of-space detection on client ==========="
2040
2041 # bug 1414 - set/get directories' stripe info
2042 test_65a() {
2043         mkdir -p $DIR/d65
2044         touch $DIR/d65/f1
2045         $LVERIFY $DIR/d65 $DIR/d65/f1 || error "lverify failed"
2046 }
2047 run_test 65a "directory with no stripe info ===================="
2048
2049 test_65b() {
2050         mkdir -p $DIR/d65
2051         $LSTRIPE $DIR/d65 $(($STRIPESIZE * 2)) 0 1 || error "setstripe"
2052         touch $DIR/d65/f2
2053         $LVERIFY $DIR/d65 $DIR/d65/f2 || error "lverify failed"
2054 }
2055 run_test 65b "directory setstripe $(($STRIPESIZE * 2)) 0 1 ==============="
2056
2057 test_65c() {
2058         if [ $OSTCOUNT -gt 1 ]; then
2059                 mkdir -p $DIR/d65
2060                 $LSTRIPE $DIR/d65 $(($STRIPESIZE * 4)) 1 \
2061                         $(($OSTCOUNT - 1)) || error "setstripe"
2062                 touch $DIR/d65/f3
2063                 $LVERIFY $DIR/d65 $DIR/d65/f3 || error "lverify failed"
2064         fi
2065 }
2066 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
2067
2068 [ $STRIPECOUNT -eq 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
2069
2070 test_65d() {
2071         mkdir -p $DIR/d65
2072         $LSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
2073         touch $DIR/d65/f4 $DIR/d65/f5
2074         $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
2075 }
2076 run_test 65d "directory setstripe $STRIPESIZE -1 $sc ======================"
2077
2078 test_65e() {
2079         mkdir -p $DIR/d65
2080
2081         $LSTRIPE $DIR/d65 0 -1 0 || error "setstripe"
2082         touch $DIR/d65/f6
2083         $LVERIFY $DIR/d65 $DIR/d65/f6 || error "lverify failed"
2084 }
2085 run_test 65e "directory setstripe 0 -1 0 (default) ============="
2086
2087 test_65f() {
2088         mkdir -p $DIR/d65f
2089         $RUNAS $LSTRIPE $DIR/d65f 0 -1 0 && error "setstripe succeeded" || true
2090 }
2091 run_test 65f "dir setstripe permission (should return error) ==="
2092
2093 # bug 2543 - update blocks count on client
2094 test_66() {
2095         COUNT=${COUNT:-8}
2096         dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
2097         sync
2098         BLOCKS=`ls -s $DIR/f66 | awk '{ print $1 }'`
2099         [ $BLOCKS -ge $COUNT ] || error "$DIR/f66 blocks $BLOCKS < $COUNT"
2100 }
2101 run_test 66 "update inode blocks count on client ==============="
2102
2103 test_67() { # bug 3285 - supplementary group fails on MDS, passes on client
2104         [ "$RUNAS_ID" = "$UID" ] && echo "skipping test 67" && return
2105         check_kernel_version 35 || return 0
2106         mkdir $DIR/d67
2107         chmod 771 $DIR/d67
2108         chgrp $RUNAS_ID $DIR/d67
2109         $RUNAS -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/d67 && error ||true
2110 }
2111 run_test 67 "supplementary group failure (should return error) ="
2112
2113 cleanup_68() {
2114        if [ "$LOOPDEV" ]; then
2115                swapoff $LOOPDEV || error "swapoff failed"
2116                losetup -d $LOOPDEV || error "losetup -d failed"
2117                unset LOOPDEV LOOPNUM
2118        fi
2119        rm -f $DIR/f68
2120 }
2121
2122 meminfo() {
2123        awk '($1 == "'$1':") { print $2 }' /proc/meminfo
2124 }
2125
2126 swap_used() {
2127        swapon -s | awk '($1 == "'$1'") { print $4 }'
2128 }
2129
2130 # excercise swapping to lustre by adding a high priority swapfile entry
2131 # and then consuming memory until it is used.
2132 test_68() {
2133        [ "$UID" != 0 ] && echo "skipping test 68 (must run as root)" && return
2134        [ "`lsmod|grep obdfilter`" ] && echo "skipping test 68 (local OST)" && \
2135                return
2136
2137        find_loop_dev
2138        dd if=/dev/zero of=$DIR/f68 bs=64k count=1024
2139
2140        trap cleanup_68 EXIT
2141
2142        losetup $LOOPDEV $DIR/f68 || error "losetup $LOOPDEV failed"
2143        mkswap $LOOPDEV
2144        swapon -p 32767 $LOOPDEV || error "swapon $LOOPDEV failed"
2145
2146        echo "before: `swapon -s | grep $LOOPDEV`"
2147        KBFREE=`meminfo MemTotal`
2148        $MEMHOG $KBFREE || error "error allocating $KBFREE kB"
2149        echo "after: `swapon -s | grep $LOOPDEV`"
2150        SWAPUSED=`swap_used $LOOPDEV`
2151
2152        cleanup_68
2153
2154        [ $SWAPUSED -eq 0 ] && echo "no swap used???" || true
2155 }
2156 run_test 68 "support swapping to Lustre ========================"
2157
2158 # on the LLNL clusters, runas will still pick up root's $TMP settings,
2159 # which will not be writable for the runas user, and then you get a CVS
2160 # error message with a corrupt path string (CVS bug) and panic.
2161 # We're not using much space, so just stick it in /tmp, which is safe.
2162 OLDTMPDIR=$TMPDIR
2163 OLDTMP=$TMP
2164 TMPDIR=/tmp
2165 TMP=/tmp
2166 OLDHOME=$HOME
2167 [ $RUNAS_ID -ne $UID ] && HOME=/tmp
2168
2169 test_99a() {
2170         mkdir -p $DIR/d99cvsroot
2171         chown $RUNAS_ID $DIR/d99cvsroot
2172         $RUNAS cvs -d $DIR/d99cvsroot init || error
2173 }
2174 run_test 99a "cvs init ========================================="
2175
2176 test_99b() {
2177         [ ! -d $DIR/d99cvsroot ] && test_99a
2178         cd /etc/init.d
2179         # some versions of cvs import exit(1) when asked to import links or
2180         # files they can't read.  ignore those files.
2181         TOIGNORE=$(find . -type l -printf '-I %f\n' -o \
2182                         ! -perm +4 -printf '-I %f\n')
2183         $RUNAS cvs -d $DIR/d99cvsroot import -m "nomesg" $TOIGNORE \
2184                 d99reposname vtag rtag
2185 }
2186 run_test 99b "cvs import ======================================="
2187
2188 test_99c() {
2189         [ ! -d $DIR/d99cvsroot ] && test_99b
2190         cd $DIR
2191         mkdir -p $DIR/d99reposname
2192         chown $RUNAS_ID $DIR/d99reposname
2193         $RUNAS cvs -d $DIR/d99cvsroot co d99reposname
2194 }
2195 run_test 99c "cvs checkout ====================================="
2196
2197 test_99d() {
2198         [ ! -d $DIR/d99cvsroot ] && test_99c
2199         cd $DIR/d99reposname
2200         $RUNAS touch foo99
2201         $RUNAS cvs add -m 'addmsg' foo99
2202 }
2203 run_test 99d "cvs add =========================================="
2204
2205 test_99e() {
2206         [ ! -d $DIR/d99cvsroot ] && test_99c
2207         cd $DIR/d99reposname
2208         $RUNAS cvs update
2209 }
2210 run_test 99e "cvs update ======================================="
2211
2212 test_99f() {
2213         [ ! -d $DIR/d99cvsroot ] && test_99d
2214         cd $DIR/d99reposname
2215         $RUNAS cvs commit -m 'nomsg' foo99
2216 }
2217 run_test 99f "cvs commit ======================================="
2218
2219 TMPDIR=$OLDTMPDIR
2220 TMP=$OLDTMP
2221 HOME=$OLDHOME
2222
2223 log "cleanup: ======================================================"
2224 if [ "`mount | grep ^$NAME`" ]; then
2225         rm -rf $DIR/[Rdfs][1-9]*
2226         if [ "$I_MOUNTED" = "yes" ]; then
2227                 sh llmountcleanup.sh || error
2228         fi
2229 fi
2230
2231 echo '=========================== finished ==============================='
2232 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true