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