xfs
[Top] [All Lists]

Re: [PATCH v2] xfstests: test setting XFS BMBT fields

To: Mark Tinguely <tinguely@xxxxxxx>
Subject: Re: [PATCH v2] xfstests: test setting XFS BMBT fields
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Tue, 18 Feb 2014 21:18:08 +1100
Cc: xfs@xxxxxxxxxxx
Delivered-to: xfs@xxxxxxxxxxx
In-reply-to: <20140213202608.627433955@xxxxxxx>
References: <20140210231046.910977175@xxxxxxx> <20140213202608.627433955@xxxxxxx>
User-agent: Mutt/1.5.21 (2010-09-15)
On Thu, Feb 13, 2014 at 02:26:56PM -0600, Mark Tinguely wrote:
> Test the setting of the XFS BMBT fields. Runs through the valid
> bit values for each field and tests an illegal value.
> 
> Signed-off-by: Mark Tinguely <tinguely@xxxxxxx>
> ---
> v2:
>  Removed the test for CRC filesystems which also removes need for the nasty
>   prefixes and filtering output.

Breaking CRC filesystem testing isn't the best approach, IMO. Using
Eric's approach of turning off CRCs - as the bug fix will be in
xfs_db binaries that support CRCs - is a much better idea.

It's also missing _require_scratch.

>  Remove the hex input as an integer test because it aint a number.

And so we should be testing that it isn't endian converted.

So rather than go around again, here's an updated patch below that
fixes all these issues.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx


xfs: test setting XFS BMBT fields in xfs_db

From: Mark Tinguely <tinguely@xxxxxxx>

Test the setting of the XFS BMBT fields via xfs_db. Runs through the
valid bit values for each field and tests an illegal value.

[dchinner: added _require_xfs_mkfs_crc and turned off crcs so that
the test doesn't just fail on CRC enabled test runs.]

[dchinner: added hex block values to check they don't get endian
swapped.]

Signed-off-by: Mark Tinguely <tinguely@xxxxxxx>
Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
Signed-off-by: Dave Chinner <david@xxxxxxxxxxxxx>

---
 tests/xfs/001     |  98 +++++++++++++++++++++++++++++++++++
 tests/xfs/001.out | 150 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/group   |   1 +
 3 files changed, 249 insertions(+)

diff --git a/tests/xfs/001 b/tests/xfs/001
new file mode 100755
index 0000000..e72e6fd
--- /dev/null
+++ b/tests/xfs/001
@@ -0,0 +1,98 @@
+#! /bin/bash
+# FS QA Test No. 001
+#
+# Test the xfs_db write of the XFS BMBT entries. For each XFS BMBT field,
+# write the value 0, each bit and finally the entry beyond the maximum legal
+# value. Also makes sure a core write and hex input still work.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 SGI.  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"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    rm -f $tmp.*
+}
+
+_do_bit_test()
+{
+       field="$1"
+       bits="$2"
+
+       echo "testing $field with $bits bits"
+       $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write $field 0" $SCRATCH_DEV
+       num=1
+       for n in `seq 0 1 $bits`; do
+               $XFS_DB_PROG -x -c "inode $FILE_INO" \
+                         -c "write $field $num" $SCRATCH_DEV
+               let num=$num*2
+       done
+       echo
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs xfs
+_supported_os Linux
+_require_scratch
+_require_xfs_mkfs_crc
+
+_scratch_mkfs -m crc=0 >/dev/null 2>&1
+_scratch_mount
+
+# create the test file
+echo "make a file with data so it has an extent" > $SCRATCH_MNT/file
+
+# find the inode for the test file
+FILE_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'`
+
+_scratch_unmount
+
+# test bit length constants
+BMBT_EXNTFLAG_BITLEN=1
+BMBT_STARTOFF_BITLEN=54
+BMBT_STARTBLOCK_BITLEN=52
+BMBT_BLOCKCOUNT_BITLEN=21
+
+# test setting the BMBT entries from 0 to past the valid number.
+_do_bit_test "u.bmx[0].extentflag" $BMBT_EXNTFLAG_BITLEN
+_do_bit_test "u.bmx[0].startoff" $BMBT_STARTOFF_BITLEN
+_do_bit_test "u.bmx[0].startblock" $BMBT_STARTBLOCK_BITLEN
+_do_bit_test "u.bmx[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN
+# test setting the 32 bit generation number
+$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0x5a" $SCRATCH_DEV
+$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0xa5" $SCRATCH_DEV
+$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0" $SCRATCH_DEV
+$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #5a5a" $SCRATCH_DEV
+$XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #a5a5" $SCRATCH_DEV
+status=0
+exit
diff --git a/tests/xfs/001.out b/tests/xfs/001.out
new file mode 100644
index 0000000..53aba1c
--- /dev/null
+++ b/tests/xfs/001.out
@@ -0,0 +1,150 @@
+QA output created by 001
+testing u.bmx[0].extentflag with 1 bits
+u.bmx[0].extentflag = 0
+u.bmx[0].extentflag = 1
+unable to convert value '2'.
+
+testing u.bmx[0].startoff with 54 bits
+u.bmx[0].startoff = 0
+u.bmx[0].startoff = 1
+u.bmx[0].startoff = 2
+u.bmx[0].startoff = 4
+u.bmx[0].startoff = 8
+u.bmx[0].startoff = 16
+u.bmx[0].startoff = 32
+u.bmx[0].startoff = 64
+u.bmx[0].startoff = 128
+u.bmx[0].startoff = 256
+u.bmx[0].startoff = 512
+u.bmx[0].startoff = 1024
+u.bmx[0].startoff = 2048
+u.bmx[0].startoff = 4096
+u.bmx[0].startoff = 8192
+u.bmx[0].startoff = 16384
+u.bmx[0].startoff = 32768
+u.bmx[0].startoff = 65536
+u.bmx[0].startoff = 131072
+u.bmx[0].startoff = 262144
+u.bmx[0].startoff = 524288
+u.bmx[0].startoff = 1048576
+u.bmx[0].startoff = 2097152
+u.bmx[0].startoff = 4194304
+u.bmx[0].startoff = 8388608
+u.bmx[0].startoff = 16777216
+u.bmx[0].startoff = 33554432
+u.bmx[0].startoff = 67108864
+u.bmx[0].startoff = 134217728
+u.bmx[0].startoff = 268435456
+u.bmx[0].startoff = 536870912
+u.bmx[0].startoff = 1073741824
+u.bmx[0].startoff = 2147483648
+u.bmx[0].startoff = 4294967296
+u.bmx[0].startoff = 8589934592
+u.bmx[0].startoff = 17179869184
+u.bmx[0].startoff = 34359738368
+u.bmx[0].startoff = 68719476736
+u.bmx[0].startoff = 137438953472
+u.bmx[0].startoff = 274877906944
+u.bmx[0].startoff = 549755813888
+u.bmx[0].startoff = 1099511627776
+u.bmx[0].startoff = 2199023255552
+u.bmx[0].startoff = 4398046511104
+u.bmx[0].startoff = 8796093022208
+u.bmx[0].startoff = 17592186044416
+u.bmx[0].startoff = 35184372088832
+u.bmx[0].startoff = 70368744177664
+u.bmx[0].startoff = 140737488355328
+u.bmx[0].startoff = 281474976710656
+u.bmx[0].startoff = 562949953421312
+u.bmx[0].startoff = 1125899906842624
+u.bmx[0].startoff = 2251799813685248
+u.bmx[0].startoff = 4503599627370496
+u.bmx[0].startoff = 9007199254740992
+unable to convert value '18014398509481984'.
+
+testing u.bmx[0].startblock with 52 bits
+u.bmx[0].startblock = 0
+u.bmx[0].startblock = 1
+u.bmx[0].startblock = 2
+u.bmx[0].startblock = 4
+u.bmx[0].startblock = 8
+u.bmx[0].startblock = 16
+u.bmx[0].startblock = 32
+u.bmx[0].startblock = 64
+u.bmx[0].startblock = 128
+u.bmx[0].startblock = 256
+u.bmx[0].startblock = 512
+u.bmx[0].startblock = 1024
+u.bmx[0].startblock = 2048
+u.bmx[0].startblock = 4096
+u.bmx[0].startblock = 8192
+u.bmx[0].startblock = 16384
+u.bmx[0].startblock = 32768
+u.bmx[0].startblock = 65536
+u.bmx[0].startblock = 131072
+u.bmx[0].startblock = 262144
+u.bmx[0].startblock = 524288
+u.bmx[0].startblock = 1048576
+u.bmx[0].startblock = 2097152
+u.bmx[0].startblock = 4194304
+u.bmx[0].startblock = 8388608
+u.bmx[0].startblock = 16777216
+u.bmx[0].startblock = 33554432
+u.bmx[0].startblock = 67108864
+u.bmx[0].startblock = 134217728
+u.bmx[0].startblock = 268435456
+u.bmx[0].startblock = 536870912
+u.bmx[0].startblock = 1073741824
+u.bmx[0].startblock = 2147483648
+u.bmx[0].startblock = 4294967296
+u.bmx[0].startblock = 8589934592
+u.bmx[0].startblock = 17179869184
+u.bmx[0].startblock = 34359738368
+u.bmx[0].startblock = 68719476736
+u.bmx[0].startblock = 137438953472
+u.bmx[0].startblock = 274877906944
+u.bmx[0].startblock = 549755813888
+u.bmx[0].startblock = 1099511627776
+u.bmx[0].startblock = 2199023255552
+u.bmx[0].startblock = 4398046511104
+u.bmx[0].startblock = 8796093022208
+u.bmx[0].startblock = 17592186044416
+u.bmx[0].startblock = 35184372088832
+u.bmx[0].startblock = 70368744177664
+u.bmx[0].startblock = 140737488355328
+u.bmx[0].startblock = 281474976710656
+u.bmx[0].startblock = 562949953421312
+u.bmx[0].startblock = 1125899906842624
+u.bmx[0].startblock = 2251799813685248
+unable to convert value '4503599627370496'.
+
+testing u.bmx[0].blockcount with 21 bits
+u.bmx[0].blockcount = 0
+u.bmx[0].blockcount = 1
+u.bmx[0].blockcount = 2
+u.bmx[0].blockcount = 4
+u.bmx[0].blockcount = 8
+u.bmx[0].blockcount = 16
+u.bmx[0].blockcount = 32
+u.bmx[0].blockcount = 64
+u.bmx[0].blockcount = 128
+u.bmx[0].blockcount = 256
+u.bmx[0].blockcount = 512
+u.bmx[0].blockcount = 1024
+u.bmx[0].blockcount = 2048
+u.bmx[0].blockcount = 4096
+u.bmx[0].blockcount = 8192
+u.bmx[0].blockcount = 16384
+u.bmx[0].blockcount = 32768
+u.bmx[0].blockcount = 65536
+u.bmx[0].blockcount = 131072
+u.bmx[0].blockcount = 262144
+u.bmx[0].blockcount = 524288
+u.bmx[0].blockcount = 1048576
+unable to convert value '2097152'.
+
+core.gen = 90
+core.gen = 165
+core.gen = 0
+core.gen = 1515847680
+core.gen = 2779054080
diff --git a/tests/xfs/group b/tests/xfs/group
index 279ffe2..88285eb 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -1,3 +1,4 @@
+001 db auto quick
 003 db auto quick
 004 db auto quick
 008 rw ioctl auto quick

<Prev in Thread] Current Thread [Next in Thread>