xfsqa: build dbtest on debian platforms
[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 # creator
26 owner=mohamedb@sgi.com
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38     cd /
39     rm -f $tmp.*
40 }
41 # dd the 1st sector then repair
42 _dd_repair_check()
43 {
44         #dd first sector
45         dd if=/dev/zero of=$1 bs=$2 count=1 2>&1 | _filter_dd
46         #xfs_repair
47         _scratch_xfs_repair 2>&1 | _filter_repair
48         #check repair
49         if _check_scratch_fs; then
50                 echo "repair passed"
51         else
52                 echo "repair failed!"
53         fi
54 }
55
56 # get standard environment, filters and checks
57 . ./common.rc
58 . ./common.filter
59 . ./common.repair
60
61 # real QA test starts here
62
63 # Modify as appropriate.
64 _supported_fs xfs
65 _supported_os Linux
66
67 # From the PV
68 # o Summary of testing:
69 #    1. mkfs.xfs a default filesystem, note agcount value.
70 #    2. dd zero first sector and repair and verify.
71 #    3. mkfs.xfs overriding agcount to a smaller value
72 #             (ie. each AG is bigger)
73 #    4. dd zero first sector, repair and verify.
74 #          -> old mkfs.xfs will cause repair to incorrectly
75 #             fix filesystem, new mkfs.xfs will be fine.
76
77 _require_scratch
78 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs \
79         || _fail "mkfs failed!"
80
81 # By executing the followint tmp file, will get on the mkfs options stored in
82 # variables
83 . $tmp.mkfs
84
85 # if the default agcount is too small, bump it up and re-mkfs before testing
86 if [ $agcount -lt 8 ]; then
87         agcount=8
88         _scratch_mkfs_xfs -dagcount=$agcount >/dev/null 2>&1 \
89                 || _notrun "Test requires at least 8 AGs."
90 fi
91
92 _dd_repair_check $SCRATCH_DEV $sectsz
93
94 # smaller AGCOUNT
95 let "agcount=$agcount-2"
96 _scratch_mkfs_xfs -dagcount=$agcount >/dev/null 2>&1 \
97         || _fail "mkfs failed!"
98
99 _dd_repair_check $SCRATCH_DEV $sectsz
100
101 # success, all done
102 status=0
103 exit