fstests: move test group info to test files
[xfstests-dev.git] / tests / xfs / 272
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 272
6 #
7 # Check that getfsmap agrees with getbmap.
8 #
9 . ./common/preamble
10 _begin_fstest auto quick rmap fsmap
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15         cd /
16         rm -rf "$tmp".* $TEST_DIR/fsmap $TEST_DIR/bmap
17 }
18
19 # Import common functions.
20 . ./common/filter
21
22 # real QA test starts here
23 _supported_fs xfs
24 _require_xfs_scratch_rmapbt
25 _require_xfs_io_command "fsmap"
26 _require_test_program "punch-alternating"
27
28 rm -f "$seqres.full"
29
30 echo "Format and mount"
31 _scratch_mkfs > "$seqres.full" 2>&1
32 _scratch_mount
33
34 # Make sure everything is on the data device
35 _xfs_force_bdev data $SCRATCH_MNT
36
37 _pwrite_byte 0x80 0 737373 $SCRATCH_MNT/urk >> $seqres.full
38 sync
39 $here/src/punch-alternating $SCRATCH_MNT/urk >> $seqres.full
40 ino=$(stat -c '%i' $SCRATCH_MNT/urk)
41
42 echo "Get fsmap" | tee -a $seqres.full
43 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT >> $seqres.full
44 $XFS_IO_PROG -c 'fsmap -v' $SCRATCH_MNT | tr '[]()' '    ' > $TEST_DIR/fsmap
45
46 echo "Get bmap" | tee -a $seqres.full
47 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk >> $seqres.full
48 $XFS_IO_PROG -c 'bmap -v' $SCRATCH_MNT/urk | grep '^[[:space:]]*[0-9]*:' | grep -v 'hole' | tr '[]()' '    ' > $TEST_DIR/bmap
49
50 echo "Check bmap and fsmap" | tee -a $seqres.full
51 cat $TEST_DIR/bmap | while read ext offrange colon blockrange ag agrange total crap; do
52         qstr="^[[:space:]]*[0-9]*:[[:space:]]*[0-9]*:[0-9]*[[:space:]]*${blockrange} :[[:space:]]*${ino}[[:space:]]*${offrange}[[:space:]]*${ag}[[:space:]]*${agrange}[[:space:]]*${total}$"
53         echo "${qstr}" >> $seqres.full
54         grep "${qstr}" $TEST_DIR/fsmap >> $seqres.full
55         found=$(grep -c "${qstr}" $TEST_DIR/fsmap)
56         test $found -eq 1 || echo "Unexpected output for offset ${offrange}."
57 done
58
59 echo "Check device field of FS metadata and regular file"
60 data_dev=$(grep 'static fs metadata' $TEST_DIR/fsmap | head -n 1 | awk '{print $2}')
61 rt_dev=$(grep "${ino}[[:space:]]*[0-9]*\.\.[0-9]*" $TEST_DIR/fsmap | head -n 1 | awk '{print $2}')
62 test "${data_dev}" = "${rt_dev}" || echo "data ${data_dev} realtime ${rt_dev}?"
63
64 # success, all done
65 status=0
66 exit