Modify existing test cases, and add a new one.
[xfstests-dev.git] / 049
1 #! /bin/sh
2 # FS QA Test No. 049
3 #
4 # XFS on loop test
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8 #-----------------------------------------------------------------------
9 #
10 # creator
11 owner=dxm@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 _cleanup()
17 {
18     cd /
19     umount $SCRATCH_MNT/test2 > /dev/null 2>&1
20     umount $SCRATCH_MNT/test > /dev/null 2>&1
21     rm -f $tmp.*
22
23     if [ -w $seq.full ]
24     then
25         echo "--- mounts at end (after cleanup)" >> $seq.full
26         mount >> $seq.full
27     fi
28 }
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "_cleanup ; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38
39 # real QA test starts here
40 _supported_fs xfs
41 _supported_os Linux
42
43 _log()
44 {
45     echo "--- $*"
46     echo "--- $*" >> $seq.full
47 }
48
49 _require_nobigloopfs
50 _require_nonexternal
51 _require_scratch
52 _require_loop
53
54 rm -f $seq.full
55
56 echo "(dev=$SCRATCH_DEV, mount=$SCRATCH_MNT)" >> $seq.full
57 echo "" >> $seq.full
58
59 echo "--- mounts" >> $seq.full
60 mount >> $seq.full
61
62 _log "Create ext2 fs on scratch"
63 mkfs -t ext2 $SCRATCH_DEV >> $seq.full 2>&1 \
64     || _fail "!!! failed to mkfs ext2"
65
66 _log "Mount ext2 fs on scratch"
67 mount -t ext2 $SCRATCH_DEV $SCRATCH_MNT >> $seq.full 2>&1 \
68     || _fail "!!! failed to mount"
69
70 _log "Create xfs fs in file on scratch"
71 /sbin/mkfs.xfs -f -dfile,name=$SCRATCH_MNT/test.xfs,size=40m \
72     >> $seq.full 2>&1 \
73     || _fail "!!! failed to mkfs xfs"
74
75 _log "Make mount points"
76 mkdir $SCRATCH_MNT/test $SCRATCH_MNT/test2 >> $seq.full 2>&1 \
77     || _fail "!!! failed to make mount points"
78
79 _log "Mount xfs via loop"
80 mount -t xfs -o loop $SCRATCH_MNT/test.xfs $SCRATCH_MNT/test >> $seq.full 2>&1 \
81     || _fail "!!! failed to loop mount xfs"
82
83 _log "stress"
84 $FSSTRESS_PROG -d $SCRATCH_MNT/test -n 1000 $FSSTRESS_AVOID >> $seq.full 2>&1 \
85     || _fail "!!! stress failed"
86
87 _log "clean"
88 rm -rf $SCRATCH_MNT/test/* >> $seq.full 2>&1 \
89     || _fail "!!! clean failed"
90
91 _log "create file for ext2 fs"
92 dd if=/dev/zero of=$SCRATCH_MNT/test/test.ext2 bs=1024 count=10240 >> $seq.full 2>&1 \
93     || _fail "!!! create file failed"
94
95 _log "Create ext2 fs in file on looped xfs"
96 echo y | mkfs -t ext2 $SCRATCH_MNT/test/test.ext2 >> $seq.full 2>&1 \
97     || _fail "!!! failed to mkfs ext2 on xfs"
98
99 _log "Mount ext2 on xfs via loop"
100 mount -t ext2 -o loop $SCRATCH_MNT/test/test.ext2 $SCRATCH_MNT/test2 >> $seq.full 2>&1 \
101     || _fail "!!! failed to loop mount xfs"
102
103 _log "stress ext2 on xfs via loop"
104 $FSSTRESS_PROG -d $SCRATCH_MNT/test2 -n 1000 $FSSTRESS_AVOID >> $seq.full 2>&1 \
105     || _fail "!!! stress ext2 failed"
106
107 _log "clean"
108 rm -rf $SCRATCH_MNT/test/* >> $seq.full 2>&1 \
109     || _fail "!!! clean failed"
110
111 _log "umount ext2 on xfs"
112 umount $SCRATCH_MNT/test2 >> $seq.full 2>&1 \
113     || _fail "!!! umount ext2 failed"
114
115 _log "umount xfs"
116 umount $SCRATCH_MNT/test >> $seq.full 2>&1 \
117     || _fail "!!! umount xfs failed"
118
119 echo "--- mounts at end (before cleanup)" >> $seq.full
120 mount >> $seq.full
121
122 rm -f $seq.full
123 # success, all done
124 status=0
125 exit