xfs/122: add legacy timestamps to ondisk checker
[xfstests-dev.git] / tests / xfs / 122
index dc28c56a9477a6e816b6d38747d7f5be491a2778..c85933153e7983507aea1b222e207809ebffae20 100755 (executable)
@@ -1,29 +1,13 @@
 #! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
+#
 # FS QA Test No. 122
 #
 # pv#952498
 # Keep an eye on some of the xfs type sizes
 # Motivation from differing ondisk types for 32 and 64 bit word versions.
 #
-#-----------------------------------------------------------------------
-# Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-#
-#-----------------------------------------------------------------------
-#
-
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
@@ -38,9 +22,10 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 
 # real QA test starts here
 _supported_fs xfs
-_supported_os Linux
 _require_command "$INDENT_PROG" indent
 
+rm -f $seqres.full
+
 # filter out known changes to xfs type sizes
 _type_size_filter()
 {
@@ -71,17 +56,22 @@ _attribute_filter()
 cprog=$tmp.get_structs.c
 oprog=$tmp.get_structs
 progout=$tmp.output
+keyfile=$tmp.keys
 
 cat >$cprog <<EOF
 #define _GNU_SOURCE
 #include <stdio.h>
 EOF
+# Certain headers must be included in a certain order...
+for hdr in xfs.h xfs_types.h xfs_fs.h xfs_arch.h xfs_format.h; do
+       test -e "/usr/include/xfs/$hdr" && echo "#include <xfs/$hdr>" >> $cprog
+done
+# ...but be sure to pull in any new headers that might show up.
 for hdr in /usr/include/xfs/xfs*.h; do
        echo "#include <$(echo "$hdr" | sed -e 's|/usr/include/||g')>" >> $cprog
 done
 
 # missing:
-# xfs_attr_shortform_t
 # xfs_trans_header_t
 
 cat >$tmp.ignore <<EOF
@@ -156,12 +146,15 @@ xfs_growfs_data_t
 xfs_growfs_rt_t
 xfs_bstime_t
 xfs_bstat_t
+struct xfs_bstat
 xfs_fsop_bulkreq_t
+struct xfs_fsop_bulkreq
 xfs_icsb_cnts_t
 xfs_icdinode_t
 xfs_ictimestamp_t
 xfs_inobt_rec_incore_t
 xfs_inogrp_t
+struct xfs_inogrp
 xfs_fid2_t
 xfs_fsop_handlereq_t
 xfs_fsop_setdm_handlereq_t
@@ -184,6 +177,11 @@ xfs_trans_t
 xfs_dirent_t
 xfs_fsop_getparents_handlereq_t
 xfs_dinode_core_t
+struct xfs_iext_cursor
+struct xfs_ino_geometry
+struct xfs_attrlist
+struct xfs_attrlist_ent
+struct xfs_legacy_ictimestamp
 EOF
 
 echo 'int main(int argc, char *argv[]) {' >>$cprog
@@ -191,10 +189,6 @@ echo 'int main(int argc, char *argv[]) {' >>$cprog
 #
 # Printfs of typedef sizes
 #
-cat /usr/include/xfs/xfs*.h | indent |\
-_attribute_filter |\
-egrep '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' > /tmp/barf
-
 cat /usr/include/xfs/xfs*.h | indent |\
 _attribute_filter |\
 egrep '(} *xfs_.*_t|^struct xfs_[a-z0-9_]*$)' |\
@@ -213,6 +207,7 @@ cat /usr/include/xfs/xfs*.h | indent |\
 awk '
    /typedef struct xfs_sb/ { structon = 1; next }
    structon && $2 ~ /^sb_/ { sub(/[;,]/,"",$2)
+                             sub(/XFSLABEL_MAX/,"12",$2)
                              printf("printf(\"offsetof(xfs_sb_t, %s) = \\%zu\\n\", offsetof(xfs_sb_t, %s));", $2, $2); next}
    structon && /}/ { structon = 0; next}
 '>>$cprog
@@ -224,18 +219,12 @@ cc -o $oprog $cprog >> $seqres.full 2>&1 || \
   _notrun "Could not compile test program (see end of $seqres.full)"
 $oprog | _type_size_filter | _type_name_filter > $progout
 
-#
-# add addition sizes and xfs_sb_t fields that don't exist in the version
-# being tested.
-#
+# Find all the items that only exist in the golden output
+comm -23 <(grep '=' $0.out | sed -e 's/ =.*$//g' | LC_COLLATE=POSIX sort) \
+        <(sed -e 's/ =.*$//g' < $progout | LC_COLLATE=POSIX sort) > $keyfile
 
-# xfsprogs 2.9.8: sb_bad_features2 in pv 978822
-if [ $XFSPROGS_VERSION -lt 20908 ]; then
-       echo 'offsetof(xfs_sb_t, sb_bad_features2 ) = 204' >>$progout
-fi
-if [ $XFSPROGS_VERSION -lt 30000 ]; then
-       echo 'sizeof( xfs_dsb_t ) = 208' >>$progout;
-fi
+# Copy those items to the program output
+grep -F -f $keyfile $0.out >> $progout
 
 LC_COLLATE=POSIX sort $progout