Add test system 'mallet'.
[xfstests-dev.git] / 149
1 #! /bin/sh
2 # FS QA Test No. 149
3 #
4 # Exercise xfs_prepair - ensure repeated use doesn't corrupt
5 # This is a clone of test 031 using xfs_prepair instead of xfs_repair
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
9 #-----------------------------------------------------------------------
10 #
11 # creator
12 owner=ddiss@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 "rm -f $tmp.*; exit \$status" 0 1 2 3 15
21 rm -f $seq.full
22
23 # get standard environment, filters and checks
24 . ./common.rc
25 . ./common.repair
26 . ./common.filter
27
28 [ -z "$XFS_PARALLEL_REPAIR_PROG" ] && _notrun "parallel repair binary xfs_prepair is not installed"
29
30 # force use of parallel repair
31 export XFS_REPAIR_PROG=$XFS_PARALLEL_REPAIR_PROG
32
33 _check_repair()
34 {
35         echo "Repairing, round 0" >> $seq.full
36         _scratch_xfs_repair 2>&1 | _filter_repair | tee -a $seq.full >$tmp.0
37         for i in 1 2 3 4
38         do
39                 echo "Repairing, iteration $i" | tee -a $seq.full
40                 _scratch_xfs_repair 2>&1 | _filter_repair >$tmp.$i
41                 diff $tmp.0 $tmp.$i >> $seq.full
42                 if [ $? -ne 0 ]; then
43                         echo "ERROR: repair round $i differs to round 0 (see $seq.full)" | tee -a $seq.full
44                         break
45                 fi
46                 # echo all interesting stuff...
47                 perl -ne '
48                         s/(rebuilding directory inode) (\d+)/\1 INO/g;
49                         s/internal log/<TYPEOF> log/g;
50                         s/external log on \S+/<TYPEOF> log/g;
51                         /^\S+/ && print;
52                 ' $tmp.$i
53         done
54         echo
55 }
56
57 # prototype file to create various directory forms
58 _create_proto()
59 {
60         total=$1
61         count=0
62
63         # take inode size into account for non-shortform directories...
64         [ $total -gt 0 ] && total=`expr $total \* $isize / 512`
65
66         cat >$tmp.proto <<EOF
67 DUMMY1
68 0 0
69 : root directory
70 d--777 3 1
71 lost+found d--755 3 1
72 $
73 EOF
74
75         while [ $count -lt $total ]
76         do
77                 count=`expr $count + 1`
78                 cat >>$tmp.proto <<EOF
79 ${count}_of_${total}_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---755 3 1 /bin/true
80 EOF
81         done
82         echo '$' >>$tmp.proto
83 }
84
85 # real QA test starts here
86 _supported_fs xfs
87 _supported_os IRIX Linux
88
89 _require_nobigloopfs
90 _require_scratch
91
92 # sanity test - default + one root directory entry
93 # Note: must do this proto/mkfs now for later inode size calcs
94 _create_proto 0
95 echo "=== one entry (shortform)"
96 _scratch_mkfs_xfs -p $tmp.proto >$tmp.mkfs0 2>&1
97 _filter_mkfs <$tmp.mkfs0 >/dev/null 2>$tmp.mkfs
98 . $tmp.mkfs
99 _check_repair
100
101 # block-form root directory & repeat
102 _create_proto 20
103 echo "=== twenty entries (block form)"
104 _scratch_mkfs_xfs -p $tmp.proto | _filter_mkfs >/dev/null 2>&1
105 _check_repair
106
107 # leaf-form root directory & repeat
108 _create_proto 1000
109 echo "=== thousand entries (leaf form)"
110 _scratch_mkfs_xfs -p $tmp.proto | _filter_mkfs >/dev/null 2>&1
111 _check_repair
112
113 # success, all done
114 status=0
115 exit