Fix the display of a variable.
[xfstests-dev.git] / 178
1 #! /bin/sh
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 #
11 # creator
12 owner=mohamedb@sgi.com
13
14 seq=`basename $0`
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24     cd /
25     rm -f $tmp.*
26 }
27 # dd the 1st sector then repair
28 _dd_repair_check() 
29 {
30         #dd first sector
31         dd if=/dev/zero of=$1 bs=$2 count=1 2>&1 | _filter_dd
32         #xfs_repair
33         _scratch_xfs_repair 2>&1 | _filter_repair 
34         #check repair
35         if _check_scratch_fs; then
36                 echo "repair passed"
37         else
38                 echo "repair failed!"
39         fi
40 }
41
42 # get standard environment, filters and checks
43 . ./common.rc
44 . ./common.filter
45 . ./common.repair
46
47 # real QA test starts here
48
49 # Modify as appropriate.
50 _supported_fs xfs 
51 _supported_os Linux
52
53 # From the PV
54 # o Summary of testing:
55 #    1. mkfs.xfs a default filesystem, note agcount value.
56 #    2. dd zero first sector and repair and verify.
57 #    3. mkfs.xfs overriding agcount to a smaller value 
58 #             (ie. each AG is bigger)
59 #    4. dd zero first sector, repair and verify.
60 #          -> old mkfs.xfs will cause repair to incorrectly
61 #             fix filesystem, new mkfs.xfs will be fine.
62
63 _require_scratch
64 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs \
65         || _fail "mkfs failed!"
66
67 # By executing the followint tmp file, will get on the mkfs options stored in 
68 # variables
69 . $tmp.mkfs
70
71 [ $agcount -le 2 ] && _notrun "Test requires more than 2 AGs."
72
73 _dd_repair_check $SCRATCH_DEV $sectsz
74
75 # smaller AGCOUNT
76 let "agcount=$agcount-2"
77 _scratch_mkfs_xfs -dagcount=$agcount >/dev/null 2>&1 \
78         || _fail "mkfs failed!"
79
80 _dd_repair_check $SCRATCH_DEV $sectsz
81
82 # success, all done
83 status=0
84 exit