QA test updates - fixes for pquota, extsize, fsstress, and ensure mount options passe...
[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.filter
25
26 # link correct .out file
27 _link_out_file $seq.out
28
29 _check_repair()
30 {
31         _scratch_xfs_repair >$tmp.0 2>&1
32         for i in 1 2 3 4
33         do
34                 echo "Repairing, iteration $i" | tee -a $seq.full
35                 _scratch_xfs_repair 2>&1 | tee -a $seq.full >$tmp.$i
36                 diff $tmp.0 $tmp.$i >> $seq.full
37                 if [ $? -ne 0 ]; then
38                         echo "ERROR: repair round $i differs (see $seq.full)"
39                         break
40                 fi
41                 # echo all interesting stuff...
42                 perl -ne '
43                         s/(rebuilding directory inode) (\d+)/\1 INO/g;
44                         s/internal log/<TYPEOF> log/g;
45                         s/external log on \S+/<TYPEOF> log/g;
46                         /^\S+/ && print;
47                 ' $tmp.$i
48         done
49         echo
50 }
51
52 # prototype file to create various directory forms
53 _create_proto()
54 {
55         total=$1
56         count=0
57
58         # take inode size into account for non-shortform directories...
59         [ $total -gt 0 ] && total=`expr $total \* $isize / 512`
60
61         cat >$tmp.proto <<EOF
62 DUMMY1
63 0 0
64 : root directory
65 d--777 3 1
66 lost+found d--755 3 1
67 $
68 EOF
69
70         while [ $count -lt $total ]
71         do
72                 count=`expr $count + 1`
73                 cat >>$tmp.proto <<EOF
74 ${count}_of_${total}_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---755 3 1 /bin/true
75 EOF
76         done
77         echo '$' >>$tmp.proto
78 }
79
80 # real QA test starts here
81 _supported_fs xfs
82 _supported_os IRIX Linux
83
84 _require_nobigloopfs
85 _require_scratch
86
87 MKFSV1="-p $tmp.proto -n version=1"
88 MKFSV2="-p $tmp.proto -n version=2"
89
90 # sanity test - default + one root directory entry
91 # Note: must do this proto/mkfs now for later inode size calcs
92 _create_proto 0
93 echo "=== version 1, one entry"
94 _scratch_mkfs_xfs $MKFSV1 >$tmp.mkfs0 2>&1
95 _filter_mkfs <$tmp.mkfs0 >/dev/null 2>$tmp.mkfs
96 . $tmp.mkfs
97 _check_repair
98 echo "=== version 2, one entry (shortform)"
99 _scratch_mkfs_xfs $MKFSV2 | _filter_mkfs >/dev/null 2>&1
100 _check_repair
101
102 # block-form root directory & repeat
103 _create_proto 20
104 echo "=== version 1, twenty entries"
105 _scratch_mkfs_xfs $MKFSV1 | _filter_mkfs >/dev/null 2>&1
106 _check_repair
107 echo "=== version 2, twenty entries (block form)"
108 _scratch_mkfs_xfs $MKFSV2 | _filter_mkfs >/dev/null 2>&1
109 _check_repair
110
111 # leaf-form root directory & repeat
112 _create_proto 1000
113 echo "=== version 1, thousand entries"
114 _scratch_mkfs_xfs $MKFSV1 | _filter_mkfs >/dev/null 2>&1
115 _check_repair
116 echo "=== version 2, thousand entries (leaf form)"
117 _scratch_mkfs_xfs $MKFSV2 | _filter_mkfs >/dev/null 2>&1
118 _check_repair
119
120 # success, all done
121 status=0
122 exit