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