Whamcloud - gitweb
land b_hd_sec onto HEAD:
[fs/lustre-release.git] / lustre / tests / sanity-gns.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 ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
11 [ "$ALWAYS_EXCEPT$EXCEPT" ] && echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
12
13 SRCDIR=`dirname $0`
14 export PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
15 export SECURITY=${SECURITY:-"null"}
16
17 TMP=${TMP:-/tmp}
18 FSTYPE=${FSTYPE:-ext3}
19
20 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
21 CREATETEST=${CREATETEST:-createtest}
22 LFS=${LFS:-lfs}
23 LSTRIPE=${LSTRIPE:-"$LFS setstripe"}
24 LFIND=${LFIND:-"$LFS find"}
25 LVERIFY=${LVERIFY:-ll_dirstripe_verify}
26 LCTL=${LCTL:-lctl}
27 MCREATE=${MCREATE:-mcreate}
28 OPENFILE=${OPENFILE:-openfile}
29 OPENUNLINK=${OPENUNLINK:-openunlink}
30 TOEXCL=${TOEXCL:-toexcl}
31 TRUNCATE=${TRUNCATE:-truncate}
32 MUNLINK=${MUNLINK:-munlink}
33 SOCKETSERVER=${SOCKETSERVER:-socketserver}
34 SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
35 IOPENTEST1=${IOPENTEST1:-iopentest1}
36 IOPENTEST2=${IOPENTEST2:-iopentest2}
37 PTLDEBUG=${PTLDEBUG:-0}
38
39 . krb5_env.sh
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 if [ `using_krb5_sec $SECURITY` == 'y' ] ; then
50     start_krb5_kdc || exit 1
51     if [ $RUNAS_ID -ne $UID ]; then
52         $RUNAS ./krb5_refresh_cache.sh || exit 2
53     fi
54 fi
55
56 export NAME=${NAME:-local}
57
58 SAVE_PWD=$PWD
59
60 clean() {
61         echo -n "cln.."
62         sh llmountcleanup.sh > /dev/null || exit 20
63         I_MOUNTED=no
64 }
65 CLEAN=${CLEAN:-clean}
66
67 start() {
68         echo -n "mnt.."
69         sh llrmount.sh > /dev/null || exit 10
70         I_MOUNTED=yes
71         echo "done"
72 }
73 START=${START:-start}
74
75 log() {
76         echo "$*"
77         lctl mark "$*" 2> /dev/null || true
78 }
79
80 trace() {
81         log "STARTING: $*"
82         strace -o $TMP/$1.strace -ttt $*
83         RC=$?
84         log "FINISHED: $*: rc $RC"
85         return 1
86 }
87 TRACE=${TRACE:-""}
88
89 check_kernel_version() {
90         VERSION_FILE=/proc/fs/lustre/kernel_version
91         WANT_VER=$1
92         [ ! -f $VERSION_FILE ] && echo "can't find kernel version" && return 1
93         GOT_VER=`cat $VERSION_FILE`
94         [ $GOT_VER -ge $WANT_VER ] && return 0
95         log "test needs at least kernel version $WANT_VER, running $GOT_VER"
96         return 1
97 }
98
99 run_one() {
100         if ! mount | grep -q $DIR; then
101                 $START
102         fi
103         echo $PTLDEBUG >/proc/sys/portals/debug 
104         log "== test $1: $2"
105         export TESTNAME=test_$1
106         test_$1 || error "test_$1: exit with rc=$?"
107         unset TESTNAME
108         pass
109         cd $SAVE_PWD
110         $CLEAN
111 }
112
113 build_test_filter() {
114         for O in $ONLY; do
115             eval ONLY_${O}=true
116         done
117         for E in $EXCEPT $ALWAYS_EXCEPT; do
118             eval EXCEPT_${E}=true
119         done
120 }
121
122 _basetest() {
123     echo $*
124 }
125
126 basetest() {
127     IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
128 }
129
130 run_test() {
131          base=`basetest $1`
132          if [ "$ONLY" ]; then
133                  testname=ONLY_$1
134                  if [ ${!testname}x != x ]; then
135                         run_one $1 "$2"
136                         return $?
137                  fi
138                  testname=ONLY_$base
139                  if [ ${!testname}x != x ]; then
140                          run_one $1 "$2"
141                          return $?
142                  fi
143                  echo -n "."
144                  return 0
145         fi
146         testname=EXCEPT_$1
147         if [ ${!testname}x != x ]; then
148                  echo "skipping excluded test $1"
149                  return 0
150         fi
151         testname=EXCEPT_$base
152         if [ ${!testname}x != x ]; then
153                  echo "skipping excluded test $1 (base $base)"
154                  return 0
155         fi
156         run_one $1 "$2"
157         return $?
158 }
159
160 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
161
162 error() { 
163         log "FAIL: $@"
164         if [ "$SANITYLOG" ]; then
165                 echo "FAIL: $TESTNAME $@" >> $SANITYLOG
166         else
167                 exit 1
168         fi
169 }
170
171 pass() { 
172         echo PASS
173 }
174
175 MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
176 if [ -z "$MOUNT" ]; then
177         sh llmount.sh
178         MOUNT="`mount | awk '/^'$NAME' .* lustre_lite / { print $3 }'`"
179         [ -z "$MOUNT" ] && error "NAME=$NAME not mounted"
180         I_MOUNTED=yes
181 fi
182
183 [ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
184
185 DIR=${DIR:-$MOUNT}
186 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
187
188 rm -rf $DIR/[Rdfs][1-9]*
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 2>&1
195
196 find_free_loop() {
197     local LOOP_DEV=""
198     test -b /dev/loop0 && 
199         base="/dev/loop" || base="/dev/loop/"
200
201     for ((i=0;i<256;i++)); do
202         test -b $base$i || continue
203         
204         losetup $base$i >/dev/null 2>&1 || {
205             LOOP_DEV="$base$i"
206             break
207         }
208     done
209     echo $LOOP_DEV
210 }
211
212 setup_loop() {
213     local LOOP_DEV=$1
214     local LOOP_FILE=$2
215     
216     dd if=/dev/zero of=$LOOP_FILE bs=1M count=10 2>/dev/null || return $?
217
218     losetup $LOOP_DEV $LOOP_FILE || {
219         rc=$?
220         cleanup_loop $LOOP_DEV $LOOP_FILE
221         return $rc
222     }
223     
224     mke2fs -F $LOOP_DEV >/dev/null 2>&1 || {
225         rc=$?
226         cleanup_loop $LOOP_DEV $LOOP_FILE
227         echo "cannot create test ext2 fs on $LOOP_DEV"
228         return $?
229     }
230     return 0
231 }
232
233 cleanup_loop() {
234     local LOOP_DEV=$1
235     local LOOP_FILE=$2
236     
237     losetup -d $LOOP_DEV >/dev/null 2>&1
238     rm -fr $LOOP_FILE >/dev/null 2>&1
239 }
240
241 setup_upcall() {
242     local INJECTION=""
243     local UPCALL=$1
244     local MODE=$2
245     local LOG=$3
246
247     test "x$MODE" = "xDEADLOCK" &&
248     INJECTION="touch \$MNTPATH/file"
249     
250     cat > $UPCALL <<- EOF
251 #!/bin/sh
252
253 MOUNT=\`which mount 2>/dev/null\`
254 test "x\$MOUNT" = "x" && MOUNT="/bin/mount"
255
256 OPTIONS=\$1
257 MNTPATH=\$2
258
259 test "x\$OPTIONS" = "x" || "x\$MNTPATH" = "x" &&
260 exit 1
261
262 $INJECTION
263 \$MOUNT \$OPTIONS \$MNTPATH > $LOG 2>&1
264 exit \$?
265 EOF
266     chmod +x $UPCALL
267     return $?
268 }
269
270 cleanup_upcall() {
271     local UPCALL=$1
272     rm -fr $UPCALL
273 }
274
275 show_log() {
276     local LOG=$1
277     
278     test -f $LOG && {
279         echo "======================== upcall log ==========================="
280         cat $LOG
281         echo "==============================================================="
282     }
283 }
284
285 check_gns() {
286     local LOG="/tmp/gns-log"
287     local UPCALL_PATH=""
288     
289     local UPCALL=$1
290     local OBJECT1=$2
291     local OBJECT2=$3
292     local TIMOUT=$4
293     local TICK=$5
294     local MODE=$6
295     
296     rm -fr $LOG >/dev/null 2>&1
297     UPCALL_PATH="/tmp/gns-upcall-$UPCALL.sh"
298     
299     echo "generating upcall $UPCALL_PATH"
300     setup_upcall $UPCALL_PATH $UPCALL $LOG || return $rc
301     echo "======================== upcall script ==========================="
302     cat $UPCALL_PATH 2>/dev/null || return $?
303     echo "=================================================================="
304    
305     echo "$UPCALL_PATH" > /proc/fs/lustre/llite/fs0/gns_upcall || return $?
306     echo "upcall:  $(cat /proc/fs/lustre/llite/fs0/gns_upcall)"
307
308     case "$MODE" in
309         GENERIC)
310             echo -n "mount on open $OBJECT1/test_file1 (generic): "
311             echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 || return $?
312             ;;
313         CONCUR1)
314             local i=1
315             local nr=20
316         
317             echo -n "mount on open $OBJECT1/test_file1 ($nr threads): "
318             for ((;i<=$nr;i++)); do 
319                 echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 &
320             done
321         
322             wait
323             
324             local RETVAL=$?
325             
326             [ $RETVAL -eq 0 ] || 
327                 return $RETVAL
328             ;;
329         CONCUR2)
330             test "x$OBJECT2" = "x" && {
331                 echo "not defined object2 for concurrent2 testing"
332                 return 1
333             }
334             echo -n "mount on open $OBJECT1/test_file1: "
335             echo -n "mount on open $OBJECT2/test_file1: "
336             echo -n "test data" > $OBJECT1/test_file1 >/dev/null 2>&1 &
337             echo -n "test data" > $OBJECT2/test_file1 >/dev/null 2>&1 &
338             
339             wait
340             
341             local RETVAL=$?
342             
343             [ $RETVAL -eq 0 ] || 
344                 return $RETVAL
345             ;;
346         CONCUR3)
347             echo -n "mount on open $OBJECT1/test_file1: "
348             
349             local i=1
350             local nr=20
351             
352             for ((;i<$nr;i++)); do
353                 touch $OBJECT1/file$i &
354                 echo -n "test data" > $OBJECT1/test_file$i >/dev/null 2>&1 &
355                 mkdir $OBJECT1/dir$i &
356             done
357
358             wait
359             
360             local RETVAL=$?
361             
362             [ $RETVAL -eq 0 ] || 
363                 return $RETVAL
364             ;;
365         *)
366             echo "invalid testing mode $MODE"
367             return 1
368     esac
369     
370     local ENTRY1="`basename $OBJECT1`"
371     local ENTRY2="`basename $OBJECT2`"
372     
373     cat /proc/mounts | grep -q "$ENTRY1" || {
374         echo "fail"
375         show_log $LOG
376         return 1
377     }
378     
379     if test "x$MODE" = "xCONCUR2"; then
380         cat /proc/mounts | grep -q "$ENTRY2" || {
381             echo "fail"
382             show_log $LOG
383             return 1
384         }
385     fi
386     
387     echo "success"
388
389     local sleep_time=$TIMOUT
390     let sleep_time+=$TICK*2
391     echo -n "waiting for umount ${sleep_time}s (timeout + tick*2): "
392     sleep $sleep_time
393
394     cat /proc/mounts | grep -q "$ENTRY1" && {
395         echo "failed"
396         return 2
397     }
398     
399     if test "x$MODE" = "xCONCUR2"; then
400         cat /proc/mounts | grep -q "$ENTRY2" && {
401             echo "failed"
402             return 2
403         }
404     fi
405     
406     echo "success"
407     cleanup_upcall $UPCALL_PATH
408     return 0
409 }
410
411 setup_object() {
412     local OBJPATH=$1
413     local OBJECT=$2
414     local CONTENT=$3
415     
416     mkdir -p $OBJPATH || return $?
417     echo -n $CONTENT > $OBJPATH/$OBJECT || return $?
418     
419     echo "======================== mount object ==========================="
420     cat $OBJPATH/$OBJECT
421     echo ""
422     echo "================================================================="
423     
424     chmod u+s $OBJPATH
425     return $?
426 }
427
428 cleanup_object() {
429     local OBJPATH=$1
430
431     chmod u-s $OBJPATH >/dev/null 2>&1
432     umount $OBJPATH >/dev/null 2>&1
433     rm -fr $OBJPATH >/dev/null 2>&1
434 }
435
436 setup_gns() {
437     local OBJECT=$1
438     local TIMOUT=$2
439     local TICK=$3
440
441     echo "$OBJECT" > /proc/fs/lustre/llite/fs0/gns_object_name || error
442     echo "$TIMOUT" > /proc/fs/lustre/llite/fs0/gns_timeout || error
443     echo "$TICK" > /proc/fs/lustre/llite/fs0/gns_tick || error
444
445     echo ""
446     echo "timeout: $(cat /proc/fs/lustre/llite/fs0/gns_timeout)s"
447     echo "object:  $(cat /proc/fs/lustre/llite/fs0/gns_object_name)"
448     echo "tick:    $(cat /proc/fs/lustre/llite/fs0/gns_tick)s"
449     echo ""
450
451 }
452
453 test_1a() {
454     local LOOP_DEV=$(find_free_loop 2>/dev/null)
455     local LOOP_FILE="/tmp/gns_loop_1a"
456     local OBJECT=".mntinfo"
457     local TIMOUT=5
458     local TICK=1
459
460     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
461         error "can't find free loop device"
462
463     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
464     cleanup_loop $LOOP_DEV $LOOP_FILE
465     setup_loop $LOOP_DEV $LOOP_FILE || error
466
467     echo "setting up GNS timeouts and mount object..."
468     setup_gns $OBJECT $TIMOUT $TICK || error
469
470     echo "preparing mount object at $DIR/gns_test_1a/$OBJECT..."
471     setup_object $DIR/gns_test_1a $OBJECT "-t ext2 $LOOP_DEV" || error
472
473     echo ""
474     echo "testing GNS with GENERIC upcall 3 times on the row"
475     for ((i=0;i<3;i++)); do
476         check_gns GENERIC $DIR/gns_test_1a $DIR/gns_test_1a $TIMOUT $TICK GENERIC || {
477             cleanup_object $DIR/gns_test_1a
478             cleanup_loop $LOOP_DEV $LOOP_FILE
479             error
480         }
481     done
482     
483     cleanup_object $DIR/gns_test_1a
484     cleanup_loop $LOOP_DEV $LOOP_FILE
485 }
486
487 run_test 1a " general GNS test - mount/umount (GENERIC) ================"
488
489 test_1b() {
490     local LOOP_DEV=$(find_free_loop 2>/dev/null)
491     local LOOP_FILE="/tmp/gns_loop_1b"
492     local OBJECT=".mntinfo"
493     local TIMOUT=5
494     local TICK=1
495
496     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
497         error "can't find free loop device"
498
499     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
500     cleanup_loop $LOOP_DEV $LOOP_FILE
501     setup_loop $LOOP_DEV $LOOP_FILE || error
502
503     echo "setting up GNS timeouts and mount object..."
504     setup_gns $OBJECT $TIMOUT $TICK || error
505
506     echo "preparing mount object at $DIR/gns_test_1b/$OBJECT..."
507     setup_object $DIR/gns_test_1b $OBJECT "-t ext2 $LOOP_DEV" || error
508
509     echo ""
510     echo "testing GNS with DEADLOCK upcall 3 times on the row"
511     for ((i=0;i<3;i++)); do
512         check_gns DEADLOCK $DIR/gns_test_1b $DIR/gns_test_1b $TIMOUT $TICK GENERIC || {
513             cleanup_object $DIR/gns_test_1b
514             cleanup_loop $LOOP_DEV $LOOP_FILE
515             error
516         }
517     done
518     
519     cleanup_object $DIR/gns_test_1b
520     cleanup_loop $LOOP_DEV $LOOP_FILE
521 }
522
523 run_test 1b " general GNS test - mount/umount (DEADLOCK) ==============="
524
525 test_1c() {
526     local LOOP_DEV=$(find_free_loop 2>/dev/null)
527     local LOOP_FILE="/tmp/gns_loop_1c"
528     local OBJECT=".mntinfo"
529     local TIMOUT=5
530     local TICK=1
531
532     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
533         error "can't find free loop device"
534
535     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
536     cleanup_loop $LOOP_DEV $LOOP_FILE
537     setup_loop $LOOP_DEV $LOOP_FILE || error
538
539     echo "setting up GNS timeouts and mount object..."
540     setup_gns $OBJECT $TIMOUT $TICK || error
541
542     echo "preparing mount object at $DIR/gns_test_1c/$OBJECT..."
543     setup_object $DIR/gns_test_1c $OBJECT "-t ext2 $LOOP_DEV" || error
544
545     echo ""
546     echo "testing GNS with DEADLOCK upcall 4 times on the row"
547     local i=0
548     
549     for ((;i<4;i++)); do
550         local MODE="GENERIC"
551         
552         test $(($i%2)) -eq 1 && MODE="DEADLOCK"
553         
554         check_gns $MODE $DIR/gns_test_1c $DIR/gns_test_1c $TIMOUT $TICK GENERIC || {
555             cleanup_object $DIR/gns_test_1c
556             cleanup_loop $LOOP_DEV $LOOP_FILE
557             error
558         }
559     done
560     
561     cleanup_object $DIR/gns_test_1c
562     cleanup_loop $LOOP_DEV $LOOP_FILE
563 }
564
565 run_test 1c " general GNS test - mount/umount (GENERIC/DEADLOCK) ========"
566
567 test_1d() {
568     local LOOP_DEV=$(find_free_loop 2>/dev/null)
569     local LOOP_FILE="/tmp/gns_loop_1d"
570     local OBJECT=".mntinfo"
571     local TIMOUT=5
572     local TICK=1
573
574     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
575         error "can't find free loop device"
576
577     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
578     cleanup_loop $LOOP_DEV $LOOP_FILE
579     setup_loop $LOOP_DEV $LOOP_FILE || error
580
581     echo "setting up GNS timeouts and mount object..."
582     setup_gns $OBJECT $TIMOUT $TICK || error
583
584     echo "preparing mount object at $DIR/gns_test_1d/$OBJECT..."
585     setup_object $DIR/gns_test_1d $OBJECT "-t ext2 $LOOP_DEV" || error
586
587     echo ""
588     echo "testing GNS with GENERIC/DEADLOCK upcall 4 times on the row in CONCUR1 mode"
589     local i=0
590     
591     for ((;i<4;i++)); do
592         local MODE="GENERIC"
593         
594         test $(($i%2)) -eq 1 && MODE="DEADLOCK"
595         
596         check_gns $MODE $DIR/gns_test_1d $DIR/gns_test_1d $TIMOUT $TICK CONCUR1 || {
597             cleanup_object $DIR/gns_test_1d
598             cleanup_loop $LOOP_DEV $LOOP_FILE
599             error
600         }
601     done
602     
603     cleanup_object $DIR/gns_test_1d
604     cleanup_loop $LOOP_DEV $LOOP_FILE
605 }
606
607 run_test 1d " general GNS test - concurrent mount ======================="
608
609 test_1e() {
610     local LOOP_DEV=$(find_free_loop 2>/dev/null)
611     local LOOP_FILE="/tmp/gns_loop_1e"
612     local OBJECT=".mntinfo"
613     local TIMOUT=5
614     local TICK=1
615
616     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
617         error "can't find free loop device"
618
619     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
620     cleanup_loop $LOOP_DEV $LOOP_FILE
621     setup_loop $LOOP_DEV $LOOP_FILE || error
622
623     echo "setting up GNS timeouts and mount object..."
624     setup_gns $OBJECT $TIMOUT $TICK || error
625
626     echo "preparing mount object at $DIR/gns_test_1e1/$OBJECT..."
627     setup_object $DIR/gns_test_1e1 $OBJECT "-t ext2 $LOOP_DEV" || error
628     
629     echo "preparing mount object at $DIR/gns_test_1e2/$OBJECT..."
630     setup_object $DIR/gns_test_1e2 $OBJECT "-t ext2 $LOOP_DEV" || error
631
632     echo ""
633     echo "testing GNS with GENERIC upcall in CONCUR2 mode"
634     check_gns GENERIC $DIR/gns_test_1e1 $DIR/gns_test_1e2 $TIMOUT $TICK CONCUR2 || {
635         cleanup_object $DIR/gns_test_1e1
636         cleanup_object $DIR/gns_test_1e2
637         cleanup_loop $LOOP_DEV $LOOP_FILE
638         error
639     }
640     
641     cleanup_object $DIR/gns_test_1e1
642     cleanup_object $DIR/gns_test_1e2
643     cleanup_loop $LOOP_DEV $LOOP_FILE
644 }
645
646 run_test 1e " general GNS test - concurrent mount of 2 GNS mounts ======="
647
648 test_2a() {
649     local OBJECT=".mntinfo"
650     local TIMOUT=5
651     local TICK=1
652
653     echo "setting up GNS timeouts and mount object..."
654     setup_gns $OBJECT $TIMOUT $TICK || error
655
656     echo "preparing mount object at $DIR/gns_test_2a/$OBJECT..."
657     mkdir -p $DIR/gns_test_2a
658     ln -s $DIR/gns_test_2a $DIR/gns_test_2a/$OBJECT
659     chmod u+s $DIR/gns_test_2a
660     
661     echo ""
662     echo "testing GNS with GENERIC upcall"
663     check_gns GENERIC $DIR/gns_test_2a $DIR/gns_test_2a $TIMOUT $TICK GENERIC && {
664         chmod u-s $DIR/gns_test_2a
665         rm -fr $DIR/gns_test_2a
666         error "symlink as mount object works?"
667     }
668     
669     chmod u-s $DIR/gns_test_2a
670     rm -fr $DIR/gns_test_2a
671 }
672
673 run_test 2a " odd conditions (mount object is symlink) ============="
674
675 test_2b() {
676     local OBJECT=".mntinfo"
677     local TIMOUT=5
678     local TICK=1
679
680     echo "setting up GNS timeouts and mount object..."
681     setup_gns $OBJECT $TIMOUT $TICK || error
682
683     echo "preparing mount object at $DIR/gns_test_2b/$OBJECT..."
684     mkdir -p $DIR/gns_test_2b/$OBJECT
685     chmod u+s $DIR/gns_test_2b
686     
687     echo ""
688     echo "testing GNS with GENERIC upcall"
689     check_gns GENERIC $DIR/gns_test_2b $DIR/gns_test_2b $TIMOUT $TICK GENERIC && {
690         chmod u-s $DIR/gns_test_2b
691         rm -fr $DIR/gns_test_2b
692         error "dir as mount object works?"
693     }
694     
695     chmod u-s $DIR/gns_test_2b
696     rm -fr $DIR/gns_test_2b
697 }
698
699 run_test 2b " odd conditions (mount object is directory) ==========="
700
701 test_2c() {
702     local OBJECT=".mntinfo"
703     local TIMOUT=5
704     local TICK=1
705
706     echo "setting up GNS timeouts and mount object..."
707     setup_gns $OBJECT $TIMOUT $TICK || error
708
709     echo "preparing mount object at $DIR/gns_test_2c/$OBJECT..."
710     mkdir -p $DIR/gns_test_2c/$OBJECT/$OBJECT/$OBJECT/$OBJECT
711     chmod u+s -R $DIR/gns_test_2c
712     
713     echo ""
714     echo "testing GNS with GENERIC upcall"
715     check_gns GENERIC $DIR/gns_test_2c $DIR/gns_test_2c $TIMOUT $TICK GENERIC && {
716         chmod u-s -R $DIR/gns_test_2c
717         rm -fr $DIR/gns_test_2c
718         error "recursive mounting of dir as mount object works?"
719     }
720     
721     chmod u-s $DIR/gns_test_2c
722     rm -fr $DIR/gns_test_2c
723 }
724
725 run_test 2c " odd conditions (mount object is recursive dir) ======="
726
727 test_2d() {
728     local OBJECT=".mntinfo"
729     local TIMOUT=5
730     local TICK=1
731
732     echo "setting up GNS timeouts and mount object..."
733     setup_gns $OBJECT $TIMOUT $TICK || error
734
735     echo "preparing mount object at $DIR/gns_test_2d/$OBJECT..."
736     mkdir -p $DIR/gns_test_2d
737     chmod u+s $DIR/gns_test_2d
738     
739     echo ""
740     echo "testing GNS with GENERIC upcall"
741     check_gns GENERIC $DIR/gns_test_2d $DIR/gns_test_2d $TIMOUT $TICK GENERIC && {
742         chmod u-s $DIR/gns_test_2d
743         rm -fr $DIR/gns_test_2d
744         error "mount point with absent mount object works?"
745     }
746     
747     chmod u-s $DIR/gns_test_2d
748     rm -fr $DIR/gns_test_2d
749 }
750
751 run_test 2d " odd conditions (mount object is absent) =============="
752
753 test_2e() {
754     local OBJECT=".mntinfo"
755     local TIMOUT=5
756     local TICK=1
757
758     echo "setting up GNS timeouts and mount object..."
759     setup_gns $OBJECT $TIMOUT $TICK || error
760
761     echo "." > /proc/fs/lustre/llite/fs0/gns_object_name
762     test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x." && 
763         error "'.' is set as mount object name"
764
765     echo ".." > /proc/fs/lustre/llite/fs0/gns_object_name
766     test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x.." && 
767         error "'..' is set as mount object name"
768
769     echo ".a" > /proc/fs/lustre/llite/fs0/gns_object_name
770     test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x.a" || 
771         error "'.a' is not set as mount object name"
772
773     echo "..a" > /proc/fs/lustre/llite/fs0/gns_object_name
774     test "x$(cat /proc/fs/lustre/llite/fs0/gns_object_name)" = "x..a" || 
775         error "'..a' is not set as mount object name"
776 }
777
778 run_test 2e " odd conditions ('.' and '..' as mount object) ============="
779
780 test_3a() {
781     local LOOP_DEV=$(find_free_loop 2>/dev/null)
782     local LOOP_FILE="/tmp/gns_loop_3a"
783     local OBJECT=".mntinfo"
784     local TIMOUT=5
785     local TICK=1
786
787     test "x$LOOP_DEV" != "x" && test -b $LOOP_DEV ||
788         error "can't find free loop device"
789
790     echo "preparing loop device $LOOP_DEV <-> $LOOP_FILE..."
791     cleanup_loop $LOOP_DEV $LOOP_FILE
792     setup_loop $LOOP_DEV $LOOP_FILE || error
793
794     echo "setting up GNS timeouts and mount object..."
795     setup_gns $OBJECT $TIMOUT $TICK || error
796
797     echo "preparing mount object at $DIR/gns_test_3a/$OBJECT..."
798     setup_object $DIR/gns_test_3a $OBJECT "-t ext2 $LOOP_DEV" || error
799
800     echo ""
801     echo "testing GNS with DEADLOCK upcall in CONCUR3 mode"
802     
803     local MODE="DEADLOCK"
804         
805     check_gns $MODE $DIR/gns_test_3a $DIR/gns_test_3a $TIMOUT $TICK CONCUR3 || {
806         cleanup_object $DIR/gns_test_3a
807         cleanup_loop $LOOP_DEV $LOOP_FILE
808         error
809     }
810     
811     cleanup_object $DIR/gns_test_3a
812     cleanup_loop $LOOP_DEV $LOOP_FILE
813 }
814
815 run_test 3a " odd conditions (mount point is modifying during mount) ===="
816
817 TMPDIR=$OLDTMPDIR
818 TMP=$OLDTMP
819 HOME=$OLDHOME
820
821 log "cleanup: ==========================================================="
822 if [ "`mount | grep ^$NAME`" ]; then
823         rm -rf $DIR/[Rdfs][1-9]*
824         if [ "$I_MOUNTED" = "yes" ]; then
825                 sh llmountcleanup.sh || error
826         fi
827 fi
828
829 echo '=========================== finished ==============================='
830 [ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true