xfstests: include test subdirectory support
[xfstests-dev.git] / 178
1 #! /bin/bash
2 # FS QA Test No. 178
3 #
4 # Reproduce PV#:967665
5 # Test if mkfs.xfs wipes old AG headers when using -f option
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     rm -f $tmp.*
38 }
39 # dd the 1st sector then repair
40 _dd_repair_check()
41 {
42         #dd first sector
43         dd if=/dev/zero of=$1 bs=$2 count=1 2>&1 | _filter_dd
44         #xfs_repair
45         _scratch_xfs_repair 2>&1 | _filter_repair
46         #check repair
47         if _check_scratch_fs; then
48                 echo "repair passed"
49         else
50                 echo "repair failed!"
51         fi
52 }
53
54 # get standard environment, filters and checks
55 . ./common.rc
56 . ./common.filter
57 . ./common.repair
58
59 # real QA test starts here
60
61 # Modify as appropriate.
62 _supported_fs xfs
63 _supported_os Linux
64
65 # From the PV
66 # o Summary of testing:
67 #    1. mkfs.xfs a default filesystem, note agcount value.
68 #    2. dd zero first sector and repair and verify.
69 #    3. mkfs.xfs overriding agcount to a smaller value
70 #             (ie. each AG is bigger)
71 #    4. dd zero first sector, repair and verify.
72 #          -> old mkfs.xfs will cause repair to incorrectly
73 #             fix filesystem, new mkfs.xfs will be fine.
74
75 _require_scratch
76 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs \
77         || _fail "mkfs failed!"
78
79 # By executing the followint tmp file, will get on the mkfs options stored in
80 # variables
81 . $tmp.mkfs
82
83 # if the default agcount is too small, bump it up and re-mkfs before testing
84 if [ $agcount -lt 8 ]; then
85         agcount=8
86         _scratch_mkfs_xfs -dagcount=$agcount >/dev/null 2>&1 \
87                 || _notrun "Test requires at least 8 AGs."
88 fi
89
90 _dd_repair_check $SCRATCH_DEV $sectsz
91
92 # smaller AGCOUNT
93 let "agcount=$agcount-2"
94 _scratch_mkfs_xfs -dagcount=$agcount >/dev/null 2>&1 \
95         || _fail "mkfs failed!"
96
97 _dd_repair_check $SCRATCH_DEV $sectsz
98
99 # success, all done
100 status=0
101 exit