xfstests: make install support common/ and tests/ dirs
[xfstests-dev.git] / tests / xfs / 279
1 #! /bin/bash
2 # FS QA Test No. 279
3 #
4 # Test mkfs.xfs against various types of devices with varying
5 # logical & physical sector sizes and offsets.
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2012 Red Hat, Inc.  All Rights Reserved.
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18 #
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     rm -f $tmp.*
38     _put_scsi_debug_dev
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44 . ./common/scsi_debug
45
46 # real QA test starts here
47 _supported_fs xfs
48 _supported_os Linux
49
50 _require_scsi_debug
51
52 rm -f $seqres.full
53
54 # Remove xfs signature so -f isn't needed to re-mkfs
55 _wipe_device()
56 {
57         device=$1
58         dd if=/dev/zero of=$device bs=4k count=1 &>/dev/null
59 }
60
61 _check_mkfs()
62 {
63         echo "===================" 
64         echo "mkfs with opts: $@" | sed -e "s,/dev/sd.,DEVICE,"
65         /sbin/mkfs.xfs $@ 2>/dev/null > $tmp.mkfs.full
66         if [ $? -ne 0 ]; then
67                 echo "Failed."
68                 return
69         fi
70         echo "Passed."
71         cat $tmp.mkfs.full | _filter_mkfs >> $seqres.full 2>$tmp.mkfs
72         . $tmp.mkfs
73         echo "Got sector size: $sectsz"
74         device=`echo $@ | awk '{print $NF}'`
75         _wipe_device $device
76 }
77
78 # === 4k physical 512b logical aligned
79 (
80 echo "==================="
81 echo "4k physical 512b logical aligned"
82 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 0 128`
83 # sector size should default to 4k
84 _check_mkfs $SCSI_DEBUG_DEV
85 # blocksize smaller than physical sectorsize should revert to logical sectorsize
86 _check_mkfs -b size=2048 -f $SCSI_DEBUG_DEV
87 ) | tee -a $seqres.full
88 _put_scsi_debug_dev
89
90 # === 4k physical 512b logical unaligned
91 (
92 echo "==================="
93 echo "4k physical 512b logical unaligned"
94 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 512 1 128`
95 # should fail on misalignment
96 _check_mkfs $SCSI_DEBUG_DEV
97 # should fall back to logical sector size with force
98 _check_mkfs -f $SCSI_DEBUG_DEV
99 # with 4k sector specified should fail without force
100 _check_mkfs -s size=4096 $SCSI_DEBUG_DEV
101 # with 4k sector specified should fall back to logical sector size with force
102 _check_mkfs -s size=4096 -f $SCSI_DEBUG_DEV
103 ) | tee -a $seqres.full
104 _put_scsi_debug_dev
105
106 # === hard 4k physical / 4k logical
107 (
108 echo "==================="
109 echo "hard 4k physical / 4k logical"
110 SCSI_DEBUG_DEV=`_get_scsi_debug_dev 4096 4096 0 128`
111 # block size smaller than sector size should fail 
112 _check_mkfs -b size=2048 $SCSI_DEBUG_DEV
113 # sector size smaller than physical sector size should fail
114 _check_mkfs -s size=512 $SCSI_DEBUG_DEV
115 ) | tee -a $seqres.full
116 _put_scsi_debug_dev
117
118 status=0
119 exit