144cc719ec37010e287fbd1384f87396f90137c4
[xfstests-dev.git] / tests / xfs / 049
1 #! /bin/bash
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 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 echo "QA output created by $seq"
27
28 _cleanup()
29 {
30     cd /
31     umount -d $SCRATCH_MNT/test2 > /dev/null 2>&1
32     umount -d $SCRATCH_MNT/test > /dev/null 2>&1
33     rm -f $tmp.*
34
35     if [ -w $seq.full ]
36     then
37         echo "--- mounts at end (after cleanup)" >> $seq.full
38         mount >> $seq.full
39     fi
40 }
41
42 here=`pwd`
43 tmp=/tmp/$$
44 status=1        # failure is the default!
45 trap "_cleanup ; exit \$status" 0 1 2 3 15
46
47 # get standard environment, filters and checks
48 . ./common.rc
49 . ./common.filter
50
51 # real QA test starts here
52 _supported_fs xfs
53 _supported_os Linux
54
55 _log()
56 {
57     echo "--- $*"
58     echo "--- $*" >> $seq.full
59 }
60
61 _require_nonexternal
62 _require_scratch
63 _require_no_large_scratch_dev
64 _require_loop
65 _require_ext2
66
67 rm -f $seq.full
68
69 echo "(dev=$SCRATCH_DEV, mount=$SCRATCH_MNT)" >> $seq.full
70 echo "" >> $seq.full
71
72 echo "--- mounts" >> $seq.full
73 mount >> $seq.full
74
75 _log "Create ext2 fs on scratch"
76 mkfs -t ext2 -F $SCRATCH_DEV >> $seq.full 2>&1 \
77     || _fail "!!! failed to mkfs ext2"
78
79 _log "Mount ext2 fs on scratch"
80 mount -t ext2 $SCRATCH_DEV $SCRATCH_MNT >> $seq.full 2>&1 \
81     || _fail "!!! failed to mount"
82
83 _log "Create xfs fs in file on scratch"
84 ${MKFS_PROG}.xfs -f -dfile,name=$SCRATCH_MNT/test.xfs,size=40m \
85     >> $seq.full 2>&1 \
86     || _fail "!!! failed to mkfs xfs"
87
88 _log "Make mount points"
89 mkdir $SCRATCH_MNT/test $SCRATCH_MNT/test2 >> $seq.full 2>&1 \
90     || _fail "!!! failed to make mount points"
91
92 _log "Mount xfs via loop"
93 mount -t xfs -o loop $SCRATCH_MNT/test.xfs $SCRATCH_MNT/test >> $seq.full 2>&1 \
94     || _fail "!!! failed to loop mount xfs"
95
96 _log "stress"
97 $FSSTRESS_PROG -d $SCRATCH_MNT/test -n 1000 $FSSTRESS_AVOID >> $seq.full 2>&1 \
98     || _fail "!!! stress failed"
99
100 _log "clean"
101 rm -rf $SCRATCH_MNT/test/* >> $seq.full 2>&1 \
102     || _fail "!!! clean failed"
103
104 _log "create file for ext2 fs"
105 dd if=/dev/zero of=$SCRATCH_MNT/test/test.ext2 bs=1024 count=10240 >> $seq.full 2>&1 \
106     || _fail "!!! create file failed"
107
108 _log "Create ext2 fs in file on looped xfs"
109 echo y | mkfs -t ext2 $SCRATCH_MNT/test/test.ext2 >> $seq.full 2>&1 \
110     || _fail "!!! failed to mkfs ext2 on xfs"
111
112 _log "Mount ext2 on xfs via loop"
113 mount -t ext2 -o loop $SCRATCH_MNT/test/test.ext2 $SCRATCH_MNT/test2 >> $seq.full 2>&1 \
114     || _fail "!!! failed to loop mount xfs"
115
116 _log "stress ext2 on xfs via loop"
117 $FSSTRESS_PROG -d $SCRATCH_MNT/test2 -n 1000 $FSSTRESS_AVOID >> $seq.full 2>&1 \
118     || _fail "!!! stress ext2 failed"
119
120 _log "clean"
121 rm -rf $SCRATCH_MNT/test/* >> $seq.full 2>&1 \
122     || _fail "!!! clean failed"
123
124 _log "umount ext2 on xfs"
125 umount -d $SCRATCH_MNT/test2 >> $seq.full 2>&1 \
126     || _fail "!!! umount ext2 failed"
127
128 _log "umount xfs"
129 umount -d $SCRATCH_MNT/test >> $seq.full 2>&1 \
130     || _fail "!!! umount xfs failed"
131
132 echo "--- mounts at end (before cleanup)" >> $seq.full
133 mount >> $seq.full
134
135 rm -f $seq.full
136 # success, all done
137 status=0
138 exit