xfstests: Use installed libraries only
[xfstests-dev.git] / 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 # creator
25 owner=dxm@sgi.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 _cleanup()
31 {
32     cd /
33     umount -d $SCRATCH_MNT/test2 > /dev/null 2>&1
34     umount -d $SCRATCH_MNT/test > /dev/null 2>&1
35     rm -f $tmp.*
36
37     if [ -w $seq.full ]
38     then
39         echo "--- mounts at end (after cleanup)" >> $seq.full
40         mount >> $seq.full
41     fi
42 }
43
44 here=`pwd`
45 tmp=/tmp/$$
46 status=1        # failure is the default!
47 trap "_cleanup ; exit \$status" 0 1 2 3 15
48
49 # get standard environment, filters and checks
50 . ./common.rc
51 . ./common.filter
52
53 # real QA test starts here
54 _supported_fs xfs
55 _supported_os Linux
56
57 _log()
58 {
59     echo "--- $*"
60     echo "--- $*" >> $seq.full
61 }
62
63 _require_nobigloopfs
64 _require_nonexternal
65 _require_scratch
66 _require_loop
67 _require_ext2
68
69 rm -f $seq.full
70
71 echo "(dev=$SCRATCH_DEV, mount=$SCRATCH_MNT)" >> $seq.full
72 echo "" >> $seq.full
73
74 echo "--- mounts" >> $seq.full
75 mount >> $seq.full
76
77 _log "Create ext2 fs on scratch"
78 mkfs -t ext2 -F $SCRATCH_DEV >> $seq.full 2>&1 \
79     || _fail "!!! failed to mkfs ext2"
80
81 _log "Mount ext2 fs on scratch"
82 mount -t ext2 $SCRATCH_DEV $SCRATCH_MNT >> $seq.full 2>&1 \
83     || _fail "!!! failed to mount"
84
85 _log "Create xfs fs in file on scratch"
86 /sbin/mkfs.xfs -f -dfile,name=$SCRATCH_MNT/test.xfs,size=40m \
87     >> $seq.full 2>&1 \
88     || _fail "!!! failed to mkfs xfs"
89
90 _log "Make mount points"
91 mkdir $SCRATCH_MNT/test $SCRATCH_MNT/test2 >> $seq.full 2>&1 \
92     || _fail "!!! failed to make mount points"
93
94 _log "Mount xfs via loop"
95 mount -t xfs -o loop $SCRATCH_MNT/test.xfs $SCRATCH_MNT/test >> $seq.full 2>&1 \
96     || _fail "!!! failed to loop mount xfs"
97
98 _log "stress"
99 $FSSTRESS_PROG -d $SCRATCH_MNT/test -n 1000 $FSSTRESS_AVOID >> $seq.full 2>&1 \
100     || _fail "!!! stress failed"
101
102 _log "clean"
103 rm -rf $SCRATCH_MNT/test/* >> $seq.full 2>&1 \
104     || _fail "!!! clean failed"
105
106 _log "create file for ext2 fs"
107 dd if=/dev/zero of=$SCRATCH_MNT/test/test.ext2 bs=1024 count=10240 >> $seq.full 2>&1 \
108     || _fail "!!! create file failed"
109
110 _log "Create ext2 fs in file on looped xfs"
111 echo y | mkfs -t ext2 $SCRATCH_MNT/test/test.ext2 >> $seq.full 2>&1 \
112     || _fail "!!! failed to mkfs ext2 on xfs"
113
114 _log "Mount ext2 on xfs via loop"
115 mount -t ext2 -o loop $SCRATCH_MNT/test/test.ext2 $SCRATCH_MNT/test2 >> $seq.full 2>&1 \
116     || _fail "!!! failed to loop mount xfs"
117
118 _log "stress ext2 on xfs via loop"
119 $FSSTRESS_PROG -d $SCRATCH_MNT/test2 -n 1000 $FSSTRESS_AVOID >> $seq.full 2>&1 \
120     || _fail "!!! stress ext2 failed"
121
122 _log "clean"
123 rm -rf $SCRATCH_MNT/test/* >> $seq.full 2>&1 \
124     || _fail "!!! clean failed"
125
126 _log "umount ext2 on xfs"
127 umount -d $SCRATCH_MNT/test2 >> $seq.full 2>&1 \
128     || _fail "!!! umount ext2 failed"
129
130 _log "umount xfs"
131 umount -d $SCRATCH_MNT/test >> $seq.full 2>&1 \
132     || _fail "!!! umount xfs failed"
133
134 echo "--- mounts at end (before cleanup)" >> $seq.full
135 mount >> $seq.full
136
137 rm -f $seq.full
138 # success, all done
139 status=0
140 exit