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