xfstests: convert tests to use new results directory
[xfstests-dev.git] / tests / xfs / 122
1 #! /bin/bash
2 # FS QA Test No. 122
3 #
4 # pv#952498
5 # Keep an eye on some of the xfs type sizes
6 # Motivation from differing ondisk types for 32 and 64 bit word versions.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 seqres=$RESULT_DIR/$seq
30 seqres=$RESULT_DIR/$seq
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
37
38 # get standard environment
39 . ./common.rc
40
41 # real QA test starts here
42 _supported_fs xfs
43 _supported_os Linux
44 _require_command $INDENT_PROG "indent"
45
46 # filter out known changes to xfs type sizes
47 _type_size_filter()
48 {
49         # lazy SB adds __be32 agf_btreeblks - pv960372
50         if [ "$($MKFS_XFS_PROG 2>&1 | grep -c lazy-count )" == "0" ]; then
51                 perl -ne '
52 s/sizeof\( xfs_agf_t \) = 60/sizeof( xfs_agf_t ) = <SIZE>/;
53                 print;'
54         else
55                 perl -ne '
56 s/sizeof\( xfs_agf_t \) = 64/sizeof( xfs_agf_t ) = <SIZE>/;
57                 print;'
58         fi
59 }
60
61 # filter out known changes to xfs type names
62 _type_name_filter()
63 {
64         sed -e 's/xfs_bmbt_rec_64_t/xfs_bmbt_rec_t/'
65 }
66
67 _attribute_filter()
68 {
69         sed -e 's/__attribute__ *[(][(]packed[)][)]//' \
70             -e 's/__arch_pack//'
71 }
72
73 cprog=$tmp.get_structs.c
74 oprog=$tmp.get_structs
75 progout=$tmp.output
76
77 cat >$cprog <<EOF
78 #include <stdio.h>
79 #include <xfs/libxlog.h>
80 EOF
81
82 cat >$tmp.ignore <<EOF
83 xfs_alloctype_t
84 xfs_buf_cancel_t
85 xfs_bmbt_rec_32_t
86 xfs_swapext_t
87 xfs_dirops_t
88 xfs_efi_log_item_t
89 xfs_efd_log_item_t
90 xfs_iocore_t
91 xfs_ihash_t
92 xfs_chashlist_t
93 xfs_chash_t
94 xfs_iptr_t
95 xfs_dmops_t
96 xfs_qmops_t
97 xfs_ioops_t
98 xfs_mod_sb_t
99 xfs_dqtrx_t
100 xfs_dqtrxops_t
101 xfs_ail_t
102 xfs_ail_entry_t
103 xfs_item_ops_t
104 xfs_log_busy_slot_t
105 xfs_log_busy_chunk_t
106 xfs_inode_log_format_t
107 xfs_efi_log_format_t
108 xfs_efd_log_format_t
109 xfs_perag_busy_t
110 xfs_perag_t
111 xfs_alloc_arg_t
112 xfs_attr_list_context_t
113 xfs_attr_sf_sort_t
114 xfs_bmbt_irec_t
115 xfs_bmbt_rec_host_t
116 xfs_bmap_free_item_t
117 xfs_bmap_free_t
118 xfs_bmalloca_t
119 xfs_btree_cur_t
120 xfs_buf_log_item_t
121 xfs_buf_log_format_v1_t
122 xfs_da_args_t
123 xfs_dabuf_t
124 xfs_da_state_blk_t
125 xfs_da_state_path_t
126 xfs_da_state_t
127 xfs_dinode_t
128 xfs_dircook_t
129 xfs_dir2_block_t
130 xfs_dir2_data_entry_t
131 xfs_dir2_data_union_t
132 xfs_dir2_data_t
133 xfs_dir2_put_args_t
134 xfs_dir_put_args_t
135 xfs_dir_sf_sort_t
136 xfs_extent_t
137 xfs_ext_irec_t
138 xfs_extdelta_t
139 xfs_flock64_t
140 xfs_fsop_geom_v1_t
141 xfs_growfs_data_t
142 xfs_growfs_rt_t
143 xfs_bstime_t
144 xfs_bstat_t
145 xfs_fsop_bulkreq_t
146 xfs_icsb_cnts_t
147 xfs_icdinode_t
148 xfs_ictimestamp_t
149 xfs_inobt_rec_incore_t
150 xfs_inogrp_t
151 xfs_fid2_t
152 xfs_fsop_handlereq_t
153 xfs_fsop_setdm_handlereq_t
154 xfs_fsop_attrlist_handlereq_t
155 xfs_attr_multiop_t
156 xfs_fsop_attrmulti_handlereq_t
157 xfs_imap_t
158 xfs_ifork_t
159 xfs_inode_t
160 xfs_inode_log_item_t
161 xfs_log_iovec_t
162 xfs_log_callback_t
163 xfs_metablock_t
164 xfs_mount_t
165 xfs_sb_t
166 xfs_log_item_t
167 xfs_log_item_desc_t
168 xfs_log_item_chunk_t
169 xfs_trans_t
170 xfs_dirent_t
171 xfs_fsop_getparents_handlereq_t
172 xfs_dinode_core_t
173 EOF
174
175 echo 'int main(int argc, char *argv[]) {' >>$cprog
176
177 #
178 # Printfs of typedef sizes
179 #
180 cat /usr/include/xfs/xfs*.h | indent |\
181 _attribute_filter |\
182 tee $seqres.full |\
183 egrep '} *xfs_.*_t' |\
184 egrep -v -f $tmp.ignore |\
185 awk '{sub(/[;,]/,"",$2); print "printf(\"sizeof(", $2, ") = %d\\n\", sizeof(", $2, "));"}' \
186 >>$cprog
187
188 #
189 # Look at offsets of key ones which differ in lengths
190 #
191
192 # xfs_sb_t
193 cat /usr/include/xfs/xfs*.h | indent |\
194 awk '
195    /typedef struct xfs_sb/ { structon = 1; next }
196    structon && $2 ~ /^sb_/ { sub(/[;,]/,"",$2)
197                              print "printf(\"offsetof(xfs_sb_t,", $2, ") = %d\\n\", offsetof(xfs_sb_t,", $2, "));"; next}
198    structon && /}/ { structon = 0; next}
199 '>>$cprog
200
201 echo 'return 0; }' >>$cprog
202
203 # create and run program
204 cc -o $oprog $cprog >> $seqres.full 2>&1 || \
205   _notrun "Could not compile test program (see end of $seqres.full)"
206 $oprog | _type_size_filter | _type_name_filter > $progout
207
208 #
209 # add addition sizes and xfs_sb_t fields that don't exist in the version
210 # being tested.
211 #
212
213 # xfsprogs 2.9.8: sb_bad_features2 in pv 978822
214 if [ $XFSPROGS_VERSION -lt 20908 ]; then
215         echo 'offsetof(xfs_sb_t, sb_bad_features2 ) = 204' >>$progout
216 fi
217 if [ $XFSPROGS_VERSION -lt 30000 ]; then
218         echo 'sizeof( xfs_dsb_t ) = 208' >>$progout;
219 fi
220
221 LC_COLLATE=POSIX sort $progout
222
223 status=0