955274: DMAPI qa test fixes
[xfstests-dev.git] / 136
1 #! /bin/sh
2 # FS QA Test No. 135
3 #
4 # Test the attr2 code
5 # Let's look, xfs_db, at the inode and its literal area for the
6 # extents and the attributes 
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
10 #-----------------------------------------------------------------------
11 #
12 # creator
13 owner=tes@puffy.melbourne.sgi.com
14
15 seq=`basename $0`
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25     cd /
26     rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common.rc
31 . ./common.filter
32
33 # real QA test starts here
34
35 _notrun "Need to fix up filtering before checkin" 
36
37 # Modify as appropriate.
38 _supported_fs xfs
39 _supported_os IRIX Linux
40 _require_scratch
41
42 export MKFS_OPTIONS="-i size=512,attr=2"
43 _scratch_mkfs_xfs
44 _scratch_mount
45
46 file=$SCRATCH_MNT/file
47 touch $file
48 inum=`ls -i $file | awk '{print $1}'`
49 echo "inum=$inum"
50
51 add_eas()
52 {
53     start=$1
54     end=$2
55     echo ""; echo "** add $start..$end EAs **"
56     i=$start
57     while [ $i -le $end ]; do 
58         attr -s name.$i -V value $file >/dev/null
59         i=`expr $i + 1`
60     done
61 }
62
63 rm_eas()
64 {
65     start=$1
66     end=$2
67     echo ""; echo "** rm $start..$end EAs **"
68     i=$start
69     while [ $i -le $end ]; do 
70         attr -r name.$i $file >/dev/null
71         i=`expr $i + 1`
72     done
73 }
74
75 do_extents()
76 {
77     num=$1
78     echo ""; echo "** $num extents **"
79     src/makeextents -v -p -w -n $num $file
80 }
81
82 _print_inode()
83 {
84     #sync
85     #sleep 2
86     umount $SCRATCH_MNT
87     xfs_db -r -c "inode $inum" -c "print" $SCRATCH_DEV |\
88     awk '
89         /nextents/ { print; next }
90         /naextents/ { print; next }
91         /u\./ { print; next }
92         /a\./ { print; next }
93         /forkoff/ { printf("core.forkoff = %d (%d bytes)\n", $3, $3*8); next }
94         /format/ { print; next }
95         /size/ { print; next }
96     '
97     _scratch_mount
98 }
99
100 # main
101
102 _print_inode
103
104 add_eas 1 1
105 _print_inode
106
107 add_eas 2 2
108 _print_inode
109
110 add_eas 3 4
111 _print_inode
112
113 add_eas 5 8
114 _print_inode
115
116 add_eas 9 16
117 _print_inode
118
119 add_eas 17 20
120 _print_inode
121
122 add_eas 21 21
123 _print_inode
124
125 add_eas 22 22
126 _print_inode
127
128 add_eas 23 23
129 _print_inode
130
131 add_eas 24 24
132 _print_inode
133
134 add_eas 25 25
135 _print_inode
136
137 add_eas 26 30
138 _print_inode
139
140 add_eas 31 35
141 _print_inode
142
143 rm_eas 1 34
144 _print_inode
145
146 # now do the extents
147
148 #build up
149 j=1
150 while [ $j -le 30 ]; do
151     do_extents $j
152     _print_inode
153     j=`expr $j + 2`
154 done
155
156 #scale down
157 j=30
158 while [ $j -ge 1 ]; do
159     do_extents $j
160     _print_inode
161     j=`expr $j - 2`
162 done
163
164 #build up
165 j=1
166 while [ $j -le 30 ]; do
167     do_extents $j
168     _print_inode
169     j=`expr $j + 2`
170 done
171
172 # success, all done
173 status=0
174 exit