common: don't check scratch dev on all tests
[xfstests-dev.git] / tests / xfs / 001
1 #! /bin/bash
2 # FS QA Test No. 001
3 #
4 # Test the xfs_db write of the XFS BMBT entries. For each XFS BMBT field,
5 # write the value 0, each bit and finally the entry beyond the maximum legal
6 # value. Also makes sure a core write and hex input still work.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2014 SGI.  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 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -f $tmp.*
39 }
40
41 _do_bit_test()
42 {
43         field="$1"
44         bits="$2"
45
46         echo "testing $field with $bits bits"
47         $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write $field 0" $SCRATCH_DEV
48         num=1
49         for n in `seq 0 1 $bits`; do
50                 $XFS_DB_PROG -x -c "inode $FILE_INO" \
51                           -c "write $field $num" $SCRATCH_DEV
52                 let num=$num*2
53         done
54         echo
55 }
56
57 # get standard environment, filters and checks
58 . ./common/rc
59 . ./common/filter
60
61 # real QA test starts here
62
63 # Modify as appropriate.
64 _supported_fs xfs
65 _supported_os Linux
66 _require_scratch_nocheck
67 _require_xfs_mkfs_crc
68
69 _scratch_mkfs -m crc=0 >/dev/null 2>&1
70 _scratch_mount
71
72 # create the test file
73 echo "make a file with data so it has an extent" > $SCRATCH_MNT/file
74
75 # find the inode for the test file
76 FILE_INO=`ls -i $SCRATCH_MNT |awk '{print $1}'`
77
78 _scratch_unmount
79
80 # test bit length constants
81 BMBT_EXNTFLAG_BITLEN=1
82 BMBT_STARTOFF_BITLEN=54
83 BMBT_STARTBLOCK_BITLEN=52
84 BMBT_BLOCKCOUNT_BITLEN=21
85
86 # test setting the BMBT entries from 0 to past the valid number.
87 _do_bit_test "u.bmx[0].extentflag" $BMBT_EXNTFLAG_BITLEN
88 _do_bit_test "u.bmx[0].startoff" $BMBT_STARTOFF_BITLEN
89 _do_bit_test "u.bmx[0].startblock" $BMBT_STARTBLOCK_BITLEN
90 _do_bit_test "u.bmx[0].blockcount" $BMBT_BLOCKCOUNT_BITLEN
91 # test setting the 32 bit generation number
92 $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0x5a" $SCRATCH_DEV
93 $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0xa5" $SCRATCH_DEV
94 $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen 0" $SCRATCH_DEV
95 $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #5a5a" $SCRATCH_DEV
96 $XFS_DB_PROG -x -c "inode $FILE_INO" -c "write core.gen #a5a5" $SCRATCH_DEV
97 status=0
98 exit