xfs/029: filter out "extended-header: cycle: 1" from output
[xfstests-dev.git] / tests / xfs / 279
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2012 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 279
6 #
7 # Test mkfs.xfs against various types of devices with varying
8 # logical & physical sector sizes and offsets.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     cd /
22     rm -f $tmp.*
23     _put_scsi_debug_dev
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/scsi_debug
30
31 # real QA test starts here
32 _supported_fs xfs
33 _supported_os Linux
34
35 _require_scsi_debug
36
37 rm -f $seqres.full
38
39 # Remove xfs signature so -f isn't needed to re-mkfs
40 _wipe_device()
41 {
42         device=$1
43         dd if=/dev/zero of=$device bs=4k count=1 &>/dev/null
44 }
45
46 _check_mkfs()
47 {
48         echo "===================" 
49         echo "mkfs with opts: $@" | sed -e "s,$SCSI_DEBUG_DEV,DEVICE,"
50         $MKFS_XFS_PROG $@ 2>/dev/null > $tmp.mkfs.full
51         if [ $? -ne 0 ]; then
52                 echo "Failed."
53                 return
54         fi
55         echo "Passed."
56         cat $tmp.mkfs.full | _filter_mkfs >> $seqres.full 2>$tmp.mkfs
57         . $tmp.mkfs
58         echo "Got sector size: $sectsz"
59         device=`echo $@ | awk '{print $NF}'`
60         _wipe_device $device
61 }
62
63 # === 4k physical 512b logical aligned
64 (
65 echo "==================="
66 echo "4k physical 512b logical aligned"
67 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128`
68 test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
69 # sector size should default to 4k
70 _check_mkfs $SCSI_DEBUG_DEV
71 # blocksize smaller than physical sectorsize should revert to logical sectorsize
72 _check_mkfs -b size=2048 -f $SCSI_DEBUG_DEV
73 ) | tee -a $seqres.full
74 _put_scsi_debug_dev
75
76 # === 4k physical 512b logical unaligned
77 (
78 echo "==================="
79 echo "4k physical 512b logical unaligned"
80 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 128`
81 test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
82 # should fail on misalignment
83 _check_mkfs $SCSI_DEBUG_DEV
84 # should fall back to logical sector size with force
85 _check_mkfs -f $SCSI_DEBUG_DEV
86 # with 4k sector specified should fail without force
87 _check_mkfs -s size=4096 $SCSI_DEBUG_DEV
88 # with 4k sector specified should fall back to logical sector size with force
89 _check_mkfs -s size=4096 -f $SCSI_DEBUG_DEV
90 ) | tee -a $seqres.full
91 _put_scsi_debug_dev
92
93 # === hard 4k physical / 4k logical
94 (
95 echo "==================="
96 echo "hard 4k physical / 4k logical"
97 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 128`
98 test -b "$SCSI_DEBUG_DEV" || _notrun "Could not get scsi_debug device"
99 # block size smaller than sector size should fail 
100 _check_mkfs -b size=2048 $SCSI_DEBUG_DEV
101 # sector size smaller than physical sector size should fail
102 _check_mkfs -s size=512 $SCSI_DEBUG_DEV
103 ) | tee -a $seqres.full
104 _put_scsi_debug_dev
105
106 status=0
107 exit