All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfstests: Add mkfs input validation tests
@ 2016-06-14  8:31 Jan Tulak
  2016-06-23 11:04 ` Eryu Guan
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jan Tulak @ 2016-06-14  8:31 UTC (permalink / raw)
  To: fstests; +Cc: Jan Tulak, Dave Chinner

mkfs.xfs does not do a very good job of input validation. This test
is designed to exercise the input validation and test good/bad
combinations of options being set. It will not pass on an old
mkfs.xfs binary - it is designed to be the test case for an input
validation cleanup (merged in spring/summer 2016).

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Jan Tulak <jtulak@redhat.com>

---

CHANGES:
  * Edited commit message to reflect that the cleanup was already merged.
  * I added other sections - now it should go through all options and check
conflicting/mandatory combinations when appropriate. I'm not feeding a garbage
into every option, because now the parsing should be done consistently and the
same for all options of the same type. However, it is possible I forgot
something what should be there - in such case, hit me. :-)

Also, at the moment of submitting this, there are some patches for xfsprogs
fixing some issues in the mailing list - so expect this to fail with the
current for-next branch (c5d584c)

Regarding of the number of this test: I used the number as this test was some
time half baked and I wanted to avoid conflicts with other new tests. So if it
is an issue, I can submit it with another number, somewhere in the main
sequence.

Cheers,
Jan
---
 tests/xfs/400-input-validation     | 335 +++++++++++++++++++++++++++++++++++++
 tests/xfs/400-input-validation.out |   2 +
 tests/xfs/group                    |   1 +
 3 files changed, 338 insertions(+)
 create mode 100755 tests/xfs/400-input-validation
 create mode 100644 tests/xfs/400-input-validation.out

diff --git a/tests/xfs/400-input-validation b/tests/xfs/400-input-validation
new file mode 100755
index 0000000..c52a4b6
--- /dev/null
+++ b/tests/xfs/400-input-validation
@@ -0,0 +1,335 @@
+#! /bin/bash
+# FS QA Test No. xfs/400
+#
+# mkfs.xfs input validation test. Designed to break mkfs.xfs if it doesn't
+# filter garbage input or invalid option combinations correctly.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2014 Red Hat, Inc.  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.*
+}
+
+# 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
+
+rm $seqres.full || true
+echo silence is golden
+
+# clear out any options to mkfs first. We want to test realtime and external log
+# devices if we can, but we also want to control them ourselves.
+logdev=$SCRATCH_LOGDEV
+rtdev=$SCRATCH_RTDEV
+
+MKFS_OPTIONS=
+SCRATCH_LOGDEV=
+SCRATCH_RTDEV=
+
+# limit the image size of the filesystem being created to something small
+fssize=$((4 * 1024 * 1024 * 1024))
+logsize=$((4 * 1024 * 1024 * 100))
+fsimg=$TEST_DIR/$seq.img
+
+do_mkfs_pass()
+{
+        echo >> $seqres.full
+        echo "pass expected $*" >> $seqres.full
+        $MKFS_XFS_PROG -f -N $* >> $seqres.full 2>&1
+        [ $? -ne 0 ] && echo "fail $*"
+}
+
+do_mkfs_fail()
+{
+        echo >> $seqres.full
+        echo "fail expected $*" >> $seqres.full
+        $MKFS_XFS_PROG -f -N $* >> $seqres.full 2>&1
+        [ $? -eq 0 ] && echo "pass $*"
+}
+
+reset_fsimg()
+{
+        rm -f $fsimg
+        $XFS_IO_PROG -f -c "truncate $fssize" $fsimg
+}
+
+reset_fsimg
+
+do_mkfs_pass $SCRATCH_DEV
+
+# basic "should fail" options
+
+# specifying sector sizes in sectors or blocks or garbage
+do_mkfs_fail -s size=2s $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2s $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2s $SCRATCH_DEV
+do_mkfs_fail -s size=2b $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2b $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2b $SCRATCH_DEV
+
+do_mkfs_fail -s size=grot $SCRATCH_DEV
+do_mkfs_fail -s size=2yerk $SCRATCH_DEV
+do_mkfs_fail -d sectsize=blah $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2foo $SCRATCH_DEV
+do_mkfs_fail -l sectsize=nggh $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2nggh $SCRATCH_DEV
+
+# conflicting sector/block sizes
+do_mkfs_fail -s size=512 -d sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -s size=512 -l sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2048 -l sectsize=1024 $SCRATCH_DEV
+
+do_mkfs_fail -b size=512 -s size=1024 $SCRATCH_DEV
+do_mkfs_fail -b size=512 -d sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -b size=512 -l sectsize=1024 $SCRATCH_DEV
+
+# specifying block sizes in sectors without specifying sector size
+# or in blocks or garbage
+do_mkfs_fail -b size=2s $SCRATCH_DEV
+do_mkfs_fail -b size=2b $SCRATCH_DEV
+do_mkfs_fail -b size=nfi $SCRATCH_DEV
+do_mkfs_fail -b size=4096nfi $SCRATCH_DEV
+do_mkfs_fail -n size=2s $SCRATCH_DEV
+do_mkfs_fail -n size=2b $SCRATCH_DEV
+do_mkfs_fail -n size=nfi $SCRATCH_DEV
+do_mkfs_fail -n size=4096nfi $SCRATCH_DEV
+
+# bad label length
+do_mkfs_fail -L thisiswaytoolong $SCRATCH_DEV
+
+# basic "should pass" data section tests
+do_mkfs_pass $SCRATCH_DEV
+do_mkfs_pass -d name=$SCRATCH_DEV
+do_mkfs_pass -d size=$fssize $SCRATCH_DEV
+do_mkfs_pass -d agcount=32 $SCRATCH_DEV
+do_mkfs_pass -d agsize=32m $SCRATCH_DEV
+do_mkfs_pass -d agsize=32M $SCRATCH_DEV
+do_mkfs_pass -d agsize=1g $SCRATCH_DEV
+do_mkfs_pass -d agsize=$((32 * 1024 * 1024)) $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -d agsize=8192b $SCRATCH_DEV
+do_mkfs_pass -d sectsize=512,agsize=65536s $SCRATCH_DEV
+do_mkfs_pass -s size=512 -d agsize=65536s $SCRATCH_DEV
+do_mkfs_pass -d noalign $SCRATCH_DEV
+do_mkfs_pass -d sunit=0,swidth=0 $SCRATCH_DEV
+do_mkfs_pass -d sunit=8,swidth=8 $SCRATCH_DEV
+do_mkfs_pass -d sunit=8,swidth=64 $SCRATCH_DEV
+do_mkfs_pass -d su=0,sw=0 $SCRATCH_DEV
+do_mkfs_pass -d su=4096,sw=1 $SCRATCH_DEV
+do_mkfs_pass -d su=4k,sw=1 $SCRATCH_DEV
+do_mkfs_pass -d su=4K,sw=8 $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -d su=1b,sw=8 $SCRATCH_DEV
+do_mkfs_pass -d sectsize=512,su=8s,sw=8 $SCRATCH_DEV
+do_mkfs_pass -s size=512 -d su=8s,sw=8 $SCRATCH_DEV
+
+# invalid data section tests
+do_mkfs_fail -d size=${fssize}b $SCRATCH_DEV
+do_mkfs_fail -d size=${fssize}s $SCRATCH_DEV
+do_mkfs_fail -d size=${fssize}yerk $SCRATCH_DEV
+do_mkfs_fail -d agsize=8192b $SCRATCH_DEV
+do_mkfs_fail -d agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -d agsize=32Mbsdfsdo $SCRATCH_DEV
+do_mkfs_fail -d agsize=1GB $SCRATCH_DEV
+do_mkfs_fail -d agcount=1k $SCRATCH_DEV
+do_mkfs_fail -d agcount=6b $SCRATCH_DEV
+do_mkfs_fail -d agcount=32,agsize=32m $SCRATCH_DEV
+do_mkfs_fail -d sunit=0,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=0 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=64,noalign $SCRATCH_DEV
+do_mkfs_fail -d sunit=64k,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=64m $SCRATCH_DEV
+do_mkfs_fail -d su=0,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=0 $SCRATCH_DEV
+do_mkfs_fail -d su=4097,sw=1 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64,noalign $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64s $SCRATCH_DEV
+do_mkfs_fail -d su=4096s,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096b,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096garabge,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64,sunit=64,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sectsize=10,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -d sectsize=512s,agsize=65536s $SCRATCH_DEV
+
+reset_fsimg
+
+# file section, should pass
+do_mkfs_pass $fsimg
+do_mkfs_pass -d file=0 $SCRATCH_DEV
+do_mkfs_pass -d size=$fssize,file=1,name=$fsimg
+do_mkfs_pass -d size=$fssize,file $fsimg
+do_mkfs_pass -d size=$fssize $fsimg
+do_mkfs_pass -d size=$fssize,name=$fsimg
+do_mkfs_pass -d size=$((fssize/2)) $fsimg
+# again this one, to check that we didn't truncated the file
+do_mkfs_pass -d size=$fssize $fsimg
+rm -f $fsimg
+do_mkfs_pass -d file,size=$fssize $fsimg
+
+reset_fsimg
+
+# file section, should fail
+do_mkfs_fail -d file=1 $SCRATCH_DEV
+do_mkfs_fail -d file $fsimg # no size given
+rm -f $fsimg
+do_mkfs_fail $fsimg
+do_mkfs_fail -d size=$fssize $fsimg
+
+reset_fsimg
+
+# log section, should pass
+do_mkfs_pass -l size=$logsize -d size=$fssize $SCRATCH_DEV
+do_mkfs_pass -l agnum=2 $SCRATCH_DEV
+do_mkfs_pass -l size=4096b $SCRATCH_DEV
+do_mkfs_pass -l sectsize=512 $SCRATCH_DEV
+do_mkfs_pass -l sunit=64 $SCRATCH_DEV
+do_mkfs_pass -l sunit=64 -d sunit=8,swidth=8 $SCRATCH_DEV
+do_mkfs_pass -l sunit=8 $SCRATCH_DEV
+do_mkfs_pass -l su=$((4096*10)) $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -l su=10b $SCRATCH_DEV
+do_mkfs_pass -l sectsize=512,su=$((4096*10)) $SCRATCH_DEV
+do_mkfs_pass -l internal $SCRATCH_DEV
+$XFS_IO_PROG -f -c "truncate $logsize" $fsimg
+do_mkfs_pass -l logdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -l name=$fsimg $SCRATCH_DEV
+do_mkfs_pass -l lazy-count=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l lazy-count=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=2 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=2 $SCRATCH_DEV
+
+# log section, should fail
+do_mkfs_fail -l size=${fssize}b $SCRATCH_DEV
+do_mkfs_fail -l size=${fssize}s $SCRATCH_DEV
+do_mkfs_fail -l size=${fssize}yerk $SCRATCH_DEV
+do_mkfs_fail -l agnum=1k $SCRATCH_DEV
+do_mkfs_fail -l agnum=6b $SCRATCH_DEV
+do_mkfs_fail -l agnum=32 $SCRATCH_DEV
+do_mkfs_fail -l sunit=0  $SCRATCH_DEV
+do_mkfs_fail -l sunit=63 $SCRATCH_DEV
+do_mkfs_fail -l su=1 $SCRATCH_DEV
+do_mkfs_fail -l su=10b $SCRATCH_DEV
+do_mkfs_fail -l su=10s $SCRATCH_DEV
+do_mkfs_fail -l su=$((4096*10+1)) $SCRATCH_DEV
+do_mkfs_fail -l sectsize=10,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -l sectsize=512s,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -l internal=0 $SCRATCH_DEV
+reset_fsimg
+do_mkfs_fail -l internal=1,logdev=$fsimg $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=0  $SCRATCH_DEV
+
+
+
+# naming section, should pass
+do_mkfs_pass -n size=65536 $SCRATCH_DEV
+do_mkfs_pass -n log=15 $SCRATCH_DEV
+do_mkfs_pass -n version=2 $SCRATCH_DEV
+do_mkfs_pass -n version=ci $SCRATCH_DEV
+do_mkfs_pass -n ftype=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -n ftype=1 $SCRATCH_DEV
+
+# naming section, should fail
+do_mkfs_fail -n version=1 $SCRATCH_DEV
+do_mkfs_fail -n version=cid $SCRATCH_DEV
+do_mkfs_fail -n ftype=4 $SCRATCH_DEV
+do_mkfs_fail -n ftype=0 $SCRATCH_DEV
+
+reset_fsimg
+
+# metadata section, should pass
+do_mkfs_pass -m crc=1,finobt=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=1,finobt=0 $SCRATCH_DEV
+do_mkfs_pass -m crc=0,finobt=0 $SCRATCH_DEV
+do_mkfs_pass -m crc=1 -n ftype=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=0 -n ftype=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=0 -n ftype=0 $SCRATCH_DEV
+
+# metadata section, should fail
+do_mkfs_fail -m crc=0,finobt=1 $SCRATCH_DEV
+do_mkfs_fail -m crc=1 -n ftype=0 $SCRATCH_DEV
+
+
+# realtime section, should pass
+do_mkfs_pass -r rtdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -r extsize=4k $SCRATCH_DEV
+do_mkfs_pass -r extsize=1G $SCRATCH_DEV
+do_mkfs_pass -r size=65536,rtdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -r noalign $SCRATCH_DEV
+
+
+# realtime section, should fail
+do_mkfs_fail -r rtdev=$SCRATCH_DEV
+do_mkfs_fail -r extsize=256 $SCRATCH_DEV
+do_mkfs_fail -r extsize=2G $SCRATCH_DEV
+do_mkfs_fail -r size=65536 $SCRATCH_DEV
+
+
+
+# inode section, should pass
+do_mkfs_pass -i size=256 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i size=512 $SCRATCH_DEV
+do_mkfs_pass -i size=2048 $SCRATCH_DEV
+do_mkfs_pass -i log=10 $SCRATCH_DEV
+do_mkfs_pass -i perblock=2 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=10 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=100 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=0 $SCRATCH_DEV
+do_mkfs_pass -i align=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i align=1 -m crc=1 $SCRATCH_DEV
+do_mkfs_pass -i attr=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i attr=2 $SCRATCH_DEV
+do_mkfs_pass -i projid32bit $SCRATCH_DEV
+do_mkfs_pass -i sparse=0 $SCRATCH_DEV
+do_mkfs_pass -i sparse -m crc $SCRATCH_DEV
+
+
+# inode section, should fail
+do_mkfs_fail -i size=256 -m crc $SCRATCH_DEV
+do_mkfs_fail -i size=128 $SCRATCH_DEV
+do_mkfs_fail -i size=513 $SCRATCH_DEV
+do_mkfs_fail -i size=4096 $SCRATCH_DEV
+do_mkfs_fail -i maxpct=110 $SCRATCH_DEV
+do_mkfs_fail -i align=2 $SCRATCH_DEV
+do_mkfs_fail -i sparse -m crc=0 $SCRATCH_DEV
+do_mkfs_fail -i align=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -i attr=1 -m crc=1 $SCRATCH_DEV
+
+status=0
+exit
diff --git a/tests/xfs/400-input-validation.out b/tests/xfs/400-input-validation.out
new file mode 100644
index 0000000..7080553
--- /dev/null
+++ b/tests/xfs/400-input-validation.out
@@ -0,0 +1,2 @@
+QA output created by 400-input-validation
+silence is golden
diff --git a/tests/xfs/group b/tests/xfs/group
index f4c6816..b51ef2e 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -285,3 +285,4 @@
 303 auto quick quota
 304 auto quick quota
 305 auto quota
+400-input-validation auto quick mkfs
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH] xfstests: Add mkfs input validation tests
  2016-06-14  8:31 [PATCH] xfstests: Add mkfs input validation tests Jan Tulak
@ 2016-06-23 11:04 ` Eryu Guan
  2016-06-23 11:10   ` Jan Tulak
  2016-06-29 10:38 ` [PATCH v2] " Jan Tulak
  2016-07-01 16:12 ` [PATCH v3] " Jan Tulak
  2 siblings, 1 reply; 9+ messages in thread
From: Eryu Guan @ 2016-06-23 11:04 UTC (permalink / raw)
  To: Jan Tulak; +Cc: fstests, Dave Chinner

On Tue, Jun 14, 2016 at 10:31:08AM +0200, Jan Tulak wrote:
> mkfs.xfs does not do a very good job of input validation. This test
> is designed to exercise the input validation and test good/bad
> combinations of options being set. It will not pass on an old
> mkfs.xfs binary - it is designed to be the test case for an input
> validation cleanup (merged in spring/summer 2016).

Looks good to me overall, I tested with xfsprogs v4.7-rc1 and it passed
the test, on both x86_64 and ppc64 host. Old xfsprogs failed the test as
expected.

But I'm not sure about all the sub-tests it does, is it enough or not,
is it doing valid tests, etc. Need help from xfs developers.

Some minor issues below.

> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> 
> ---
> 
> CHANGES:
>   * Edited commit message to reflect that the cleanup was already merged.
>   * I added other sections - now it should go through all options and check
> conflicting/mandatory combinations when appropriate. I'm not feeding a garbage
> into every option, because now the parsing should be done consistently and the
> same for all options of the same type. However, it is possible I forgot
> something what should be there - in such case, hit me. :-)
> 
> Also, at the moment of submitting this, there are some patches for xfsprogs
> fixing some issues in the mailing list - so expect this to fail with the
> current for-next branch (c5d584c)
> 
> Regarding of the number of this test: I used the number as this test was some
> time half baked and I wanted to avoid conflicts with other new tests. So if it
> is an issue, I can submit it with another number, somewhere in the main
> sequence.
> 
> Cheers,
> Jan
> ---
>  tests/xfs/400-input-validation     | 335 +++++++++++++++++++++++++++++++++++++
>  tests/xfs/400-input-validation.out |   2 +
>  tests/xfs/group                    |   1 +
>  3 files changed, 338 insertions(+)
>  create mode 100755 tests/xfs/400-input-validation
>  create mode 100644 tests/xfs/400-input-validation.out
> 
> diff --git a/tests/xfs/400-input-validation b/tests/xfs/400-input-validation
> new file mode 100755
> index 0000000..c52a4b6
> --- /dev/null
> +++ b/tests/xfs/400-input-validation
> @@ -0,0 +1,335 @@
> +#! /bin/bash
> +# FS QA Test No. xfs/400
> +#
> +# mkfs.xfs input validation test. Designed to break mkfs.xfs if it doesn't
> +# filter garbage input or invalid option combinations correctly.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
                   ^^^^ 2016
> +#
> +# 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.*

You're using space for indention in the whole test, please use tab.

> +}
> +
> +# 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
> +
> +rm $seqres.full || true

rm -f $seqres.full

Otherwise it fails when I ran it for the first time
rm: cannot remove '/root/xfstests/results//xfs/006-input-validation.full': No such file or directory

Thanks,
Eryu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] xfstests: Add mkfs input validation tests
  2016-06-23 11:04 ` Eryu Guan
@ 2016-06-23 11:10   ` Jan Tulak
  0 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-06-23 11:10 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests, Dave Chinner

On Thu, Jun 23, 2016 at 1:04 PM, Eryu Guan <eguan@redhat.com> wrote:
> On Tue, Jun 14, 2016 at 10:31:08AM +0200, Jan Tulak wrote:
>> mkfs.xfs does not do a very good job of input validation. This test
>> is designed to exercise the input validation and test good/bad
>> combinations of options being set. It will not pass on an old
>> mkfs.xfs binary - it is designed to be the test case for an input
>> validation cleanup (merged in spring/summer 2016).
>
> Looks good to me overall, I tested with xfsprogs v4.7-rc1 and it passed
> the test, on both x86_64 and ppc64 host. Old xfsprogs failed the test as
> expected.
>
> But I'm not sure about all the sub-tests it does, is it enough or not,
> is it doing valid tests, etc. Need help from xfs developers.
>

Thanks. This is something I hope to hear too... I tried to put there
everything important, but with so many options and combinations,
omittions are possible. :-)

> Some minor issues below.

I will see to them and send a fix. Thank you.

Cheers, Jan

>
>>
>> Signed-off-by: Dave Chinner <dchinner@redhat.com>
>> Signed-off-by: Jan Tulak <jtulak@redhat.com>
>>
>> ---
>>
>> CHANGES:
>>   * Edited commit message to reflect that the cleanup was already merged.
>>   * I added other sections - now it should go through all options and check
>> conflicting/mandatory combinations when appropriate. I'm not feeding a garbage
>> into every option, because now the parsing should be done consistently and the
>> same for all options of the same type. However, it is possible I forgot
>> something what should be there - in such case, hit me. :-)
>>
>> Also, at the moment of submitting this, there are some patches for xfsprogs
>> fixing some issues in the mailing list - so expect this to fail with the
>> current for-next branch (c5d584c)
>>
>> Regarding of the number of this test: I used the number as this test was some
>> time half baked and I wanted to avoid conflicts with other new tests. So if it
>> is an issue, I can submit it with another number, somewhere in the main
>> sequence.
>>
>> Cheers,
>> Jan
>> ---
>>  tests/xfs/400-input-validation     | 335 +++++++++++++++++++++++++++++++++++++
>>  tests/xfs/400-input-validation.out |   2 +
>>  tests/xfs/group                    |   1 +
>>  3 files changed, 338 insertions(+)
>>  create mode 100755 tests/xfs/400-input-validation
>>  create mode 100644 tests/xfs/400-input-validation.out
>>
>> diff --git a/tests/xfs/400-input-validation b/tests/xfs/400-input-validation
>> new file mode 100755
>> index 0000000..c52a4b6
>> --- /dev/null
>> +++ b/tests/xfs/400-input-validation
>> @@ -0,0 +1,335 @@
>> +#! /bin/bash
>> +# FS QA Test No. xfs/400
>> +#
>> +# mkfs.xfs input validation test. Designed to break mkfs.xfs if it doesn't
>> +# filter garbage input or invalid option combinations correctly.
>> +#
>> +#-----------------------------------------------------------------------
>> +# Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
>                    ^^^^ 2016
>> +#
>> +# 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.*
>
> You're using space for indention in the whole test, please use tab.
>
>> +}
>> +
>> +# 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
>> +
>> +rm $seqres.full || true
>
> rm -f $seqres.full
>
> Otherwise it fails when I ran it for the first time
> rm: cannot remove '/root/xfstests/results//xfs/006-input-validation.full': No such file or directory
>
> Thanks,
> Eryu



-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2] xfstests: Add mkfs input validation tests
  2016-06-14  8:31 [PATCH] xfstests: Add mkfs input validation tests Jan Tulak
  2016-06-23 11:04 ` Eryu Guan
@ 2016-06-29 10:38 ` Jan Tulak
  2016-06-29 12:52   ` Eryu Guan
  2016-07-01 16:12 ` [PATCH v3] " Jan Tulak
  2 siblings, 1 reply; 9+ messages in thread
From: Jan Tulak @ 2016-06-29 10:38 UTC (permalink / raw)
  To: fstests; +Cc: jtulak

mkfs.xfs does not do a very good job of input validation. This test
is designed to exercise the input validation and test good/bad
combinations of options being set. It will not pass on an old
mkfs.xfs binary - it is designed to be the test case for an input
validation cleanup (merged in spring/summer 2016).

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Jan Tulak <jtulak@redhat.com>

---

I didn't got other feedback than the three small issues fixed bellow, and it is
passing on current xfsprogs-dev as it should. So I think that it can be merged.

CHANGES:
  * Change copyright year to 2016
  * rm || true --> rm -f
  * Change from space to tab indent

Cheers,
Jan

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 tests/xfs/400-input-validation     | 335 +++++++++++++++++++++++++++++++++++++
 tests/xfs/400-input-validation.out |   2 +
 tests/xfs/group                    |   1 +
 3 files changed, 338 insertions(+)
 create mode 100755 tests/xfs/400-input-validation
 create mode 100644 tests/xfs/400-input-validation.out

diff --git a/tests/xfs/400-input-validation b/tests/xfs/400-input-validation
new file mode 100755
index 0000000..e0996c6
--- /dev/null
+++ b/tests/xfs/400-input-validation
@@ -0,0 +1,335 @@
+#! /bin/bash
+# FS QA Test No. xfs/400
+#
+# mkfs.xfs input validation test. Designed to break mkfs.xfs if it doesn't
+# filter garbage input or invalid option combinations correctly.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Red Hat, Inc.  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.*
+}
+
+# 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
+
+rm -f $seqres.full
+echo silence is golden
+
+# clear out any options to mkfs first. We want to test realtime and external log
+# devices if we can, but we also want to control them ourselves.
+logdev=$SCRATCH_LOGDEV
+rtdev=$SCRATCH_RTDEV
+
+MKFS_OPTIONS=
+SCRATCH_LOGDEV=
+SCRATCH_RTDEV=
+
+# limit the image size of the filesystem being created to something small
+fssize=$((4 * 1024 * 1024 * 1024))
+logsize=$((4 * 1024 * 1024 * 100))
+fsimg=$TEST_DIR/$seq.img
+
+do_mkfs_pass()
+{
+	echo >> $seqres.full
+	echo "pass expected $*" >> $seqres.full
+	$MKFS_XFS_PROG -f -N $* >> $seqres.full 2>&1
+	[ $? -ne 0 ] && echo "fail $*"
+}
+
+do_mkfs_fail()
+{
+	echo >> $seqres.full
+	echo "fail expected $*" >> $seqres.full
+	$MKFS_XFS_PROG -f -N $* >> $seqres.full 2>&1
+	[ $? -eq 0 ] && echo "pass $*"
+}
+
+reset_fsimg()
+{
+	rm -f $fsimg
+	$XFS_IO_PROG -f -c "truncate $fssize" $fsimg
+}
+
+reset_fsimg
+
+do_mkfs_pass $SCRATCH_DEV
+
+# basic "should fail" options
+
+# specifying sector sizes in sectors or blocks or garbage
+do_mkfs_fail -s size=2s $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2s $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2s $SCRATCH_DEV
+do_mkfs_fail -s size=2b $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2b $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2b $SCRATCH_DEV
+
+do_mkfs_fail -s size=grot $SCRATCH_DEV
+do_mkfs_fail -s size=2yerk $SCRATCH_DEV
+do_mkfs_fail -d sectsize=blah $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2foo $SCRATCH_DEV
+do_mkfs_fail -l sectsize=nggh $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2nggh $SCRATCH_DEV
+
+# conflicting sector/block sizes
+do_mkfs_fail -s size=512 -d sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -s size=512 -l sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2048 -l sectsize=1024 $SCRATCH_DEV
+
+do_mkfs_fail -b size=512 -s size=1024 $SCRATCH_DEV
+do_mkfs_fail -b size=512 -d sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -b size=512 -l sectsize=1024 $SCRATCH_DEV
+
+# specifying block sizes in sectors without specifying sector size
+# or in blocks or garbage
+do_mkfs_fail -b size=2s $SCRATCH_DEV
+do_mkfs_fail -b size=2b $SCRATCH_DEV
+do_mkfs_fail -b size=nfi $SCRATCH_DEV
+do_mkfs_fail -b size=4096nfi $SCRATCH_DEV
+do_mkfs_fail -n size=2s $SCRATCH_DEV
+do_mkfs_fail -n size=2b $SCRATCH_DEV
+do_mkfs_fail -n size=nfi $SCRATCH_DEV
+do_mkfs_fail -n size=4096nfi $SCRATCH_DEV
+
+# bad label length
+do_mkfs_fail -L thisiswaytoolong $SCRATCH_DEV
+
+# basic "should pass" data section tests
+do_mkfs_pass $SCRATCH_DEV
+do_mkfs_pass -d name=$SCRATCH_DEV
+do_mkfs_pass -d size=$fssize $SCRATCH_DEV
+do_mkfs_pass -d agcount=32 $SCRATCH_DEV
+do_mkfs_pass -d agsize=32m $SCRATCH_DEV
+do_mkfs_pass -d agsize=32M $SCRATCH_DEV
+do_mkfs_pass -d agsize=1g $SCRATCH_DEV
+do_mkfs_pass -d agsize=$((32 * 1024 * 1024)) $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -d agsize=8192b $SCRATCH_DEV
+do_mkfs_pass -d sectsize=512,agsize=65536s $SCRATCH_DEV
+do_mkfs_pass -s size=512 -d agsize=65536s $SCRATCH_DEV
+do_mkfs_pass -d noalign $SCRATCH_DEV
+do_mkfs_pass -d sunit=0,swidth=0 $SCRATCH_DEV
+do_mkfs_pass -d sunit=8,swidth=8 $SCRATCH_DEV
+do_mkfs_pass -d sunit=8,swidth=64 $SCRATCH_DEV
+do_mkfs_pass -d su=0,sw=0 $SCRATCH_DEV
+do_mkfs_pass -d su=4096,sw=1 $SCRATCH_DEV
+do_mkfs_pass -d su=4k,sw=1 $SCRATCH_DEV
+do_mkfs_pass -d su=4K,sw=8 $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -d su=1b,sw=8 $SCRATCH_DEV
+do_mkfs_pass -d sectsize=512,su=8s,sw=8 $SCRATCH_DEV
+do_mkfs_pass -s size=512 -d su=8s,sw=8 $SCRATCH_DEV
+
+# invalid data section tests
+do_mkfs_fail -d size=${fssize}b $SCRATCH_DEV
+do_mkfs_fail -d size=${fssize}s $SCRATCH_DEV
+do_mkfs_fail -d size=${fssize}yerk $SCRATCH_DEV
+do_mkfs_fail -d agsize=8192b $SCRATCH_DEV
+do_mkfs_fail -d agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -d agsize=32Mbsdfsdo $SCRATCH_DEV
+do_mkfs_fail -d agsize=1GB $SCRATCH_DEV
+do_mkfs_fail -d agcount=1k $SCRATCH_DEV
+do_mkfs_fail -d agcount=6b $SCRATCH_DEV
+do_mkfs_fail -d agcount=32,agsize=32m $SCRATCH_DEV
+do_mkfs_fail -d sunit=0,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=0 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=64,noalign $SCRATCH_DEV
+do_mkfs_fail -d sunit=64k,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=64m $SCRATCH_DEV
+do_mkfs_fail -d su=0,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=0 $SCRATCH_DEV
+do_mkfs_fail -d su=4097,sw=1 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64,noalign $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64s $SCRATCH_DEV
+do_mkfs_fail -d su=4096s,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096b,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096garabge,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64,sunit=64,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sectsize=10,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -d sectsize=512s,agsize=65536s $SCRATCH_DEV
+
+reset_fsimg
+
+# file section, should pass
+do_mkfs_pass $fsimg
+do_mkfs_pass -d file=0 $SCRATCH_DEV
+do_mkfs_pass -d size=$fssize,file=1,name=$fsimg
+do_mkfs_pass -d size=$fssize,file $fsimg
+do_mkfs_pass -d size=$fssize $fsimg
+do_mkfs_pass -d size=$fssize,name=$fsimg
+do_mkfs_pass -d size=$((fssize/2)) $fsimg
+# again this one, to check that we didn't truncated the file
+do_mkfs_pass -d size=$fssize $fsimg
+rm -f $fsimg
+do_mkfs_pass -d file,size=$fssize $fsimg
+
+reset_fsimg
+
+# file section, should fail
+do_mkfs_fail -d file=1 $SCRATCH_DEV
+do_mkfs_fail -d file $fsimg # no size given
+rm -f $fsimg
+do_mkfs_fail $fsimg
+do_mkfs_fail -d size=$fssize $fsimg
+
+reset_fsimg
+
+# log section, should pass
+do_mkfs_pass -l size=$logsize -d size=$fssize $SCRATCH_DEV
+do_mkfs_pass -l agnum=2 $SCRATCH_DEV
+do_mkfs_pass -l size=4096b $SCRATCH_DEV
+do_mkfs_pass -l sectsize=512 $SCRATCH_DEV
+do_mkfs_pass -l sunit=64 $SCRATCH_DEV
+do_mkfs_pass -l sunit=64 -d sunit=8,swidth=8 $SCRATCH_DEV
+do_mkfs_pass -l sunit=8 $SCRATCH_DEV
+do_mkfs_pass -l su=$((4096*10)) $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -l su=10b $SCRATCH_DEV
+do_mkfs_pass -l sectsize=512,su=$((4096*10)) $SCRATCH_DEV
+do_mkfs_pass -l internal $SCRATCH_DEV
+$XFS_IO_PROG -f -c "truncate $logsize" $fsimg
+do_mkfs_pass -l logdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -l name=$fsimg $SCRATCH_DEV
+do_mkfs_pass -l lazy-count=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l lazy-count=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=2 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=2 $SCRATCH_DEV
+
+# log section, should fail
+do_mkfs_fail -l size=${fssize}b $SCRATCH_DEV
+do_mkfs_fail -l size=${fssize}s $SCRATCH_DEV
+do_mkfs_fail -l size=${fssize}yerk $SCRATCH_DEV
+do_mkfs_fail -l agnum=1k $SCRATCH_DEV
+do_mkfs_fail -l agnum=6b $SCRATCH_DEV
+do_mkfs_fail -l agnum=32 $SCRATCH_DEV
+do_mkfs_fail -l sunit=0  $SCRATCH_DEV
+do_mkfs_fail -l sunit=63 $SCRATCH_DEV
+do_mkfs_fail -l su=1 $SCRATCH_DEV
+do_mkfs_fail -l su=10b $SCRATCH_DEV
+do_mkfs_fail -l su=10s $SCRATCH_DEV
+do_mkfs_fail -l su=$((4096*10+1)) $SCRATCH_DEV
+do_mkfs_fail -l sectsize=10,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -l sectsize=512s,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -l internal=0 $SCRATCH_DEV
+reset_fsimg
+do_mkfs_fail -l internal=1,logdev=$fsimg $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=0  $SCRATCH_DEV
+
+
+
+# naming section, should pass
+do_mkfs_pass -n size=65536 $SCRATCH_DEV
+do_mkfs_pass -n log=15 $SCRATCH_DEV
+do_mkfs_pass -n version=2 $SCRATCH_DEV
+do_mkfs_pass -n version=ci $SCRATCH_DEV
+do_mkfs_pass -n ftype=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -n ftype=1 $SCRATCH_DEV
+
+# naming section, should fail
+do_mkfs_fail -n version=1 $SCRATCH_DEV
+do_mkfs_fail -n version=cid $SCRATCH_DEV
+do_mkfs_fail -n ftype=4 $SCRATCH_DEV
+do_mkfs_fail -n ftype=0 $SCRATCH_DEV
+
+reset_fsimg
+
+# metadata section, should pass
+do_mkfs_pass -m crc=1,finobt=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=1,finobt=0 $SCRATCH_DEV
+do_mkfs_pass -m crc=0,finobt=0 $SCRATCH_DEV
+do_mkfs_pass -m crc=1 -n ftype=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=0 -n ftype=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=0 -n ftype=0 $SCRATCH_DEV
+
+# metadata section, should fail
+do_mkfs_fail -m crc=0,finobt=1 $SCRATCH_DEV
+do_mkfs_fail -m crc=1 -n ftype=0 $SCRATCH_DEV
+
+
+# realtime section, should pass
+do_mkfs_pass -r rtdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -r extsize=4k $SCRATCH_DEV
+do_mkfs_pass -r extsize=1G $SCRATCH_DEV
+do_mkfs_pass -r size=65536,rtdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -r noalign $SCRATCH_DEV
+
+
+# realtime section, should fail
+do_mkfs_fail -r rtdev=$SCRATCH_DEV
+do_mkfs_fail -r extsize=256 $SCRATCH_DEV
+do_mkfs_fail -r extsize=2G $SCRATCH_DEV
+do_mkfs_fail -r size=65536 $SCRATCH_DEV
+
+
+
+# inode section, should pass
+do_mkfs_pass -i size=256 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i size=512 $SCRATCH_DEV
+do_mkfs_pass -i size=2048 $SCRATCH_DEV
+do_mkfs_pass -i log=10 $SCRATCH_DEV
+do_mkfs_pass -i perblock=2 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=10 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=100 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=0 $SCRATCH_DEV
+do_mkfs_pass -i align=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i align=1 -m crc=1 $SCRATCH_DEV
+do_mkfs_pass -i attr=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i attr=2 $SCRATCH_DEV
+do_mkfs_pass -i projid32bit $SCRATCH_DEV
+do_mkfs_pass -i sparse=0 $SCRATCH_DEV
+do_mkfs_pass -i sparse -m crc $SCRATCH_DEV
+
+
+# inode section, should fail
+do_mkfs_fail -i size=256 -m crc $SCRATCH_DEV
+do_mkfs_fail -i size=128 $SCRATCH_DEV
+do_mkfs_fail -i size=513 $SCRATCH_DEV
+do_mkfs_fail -i size=4096 $SCRATCH_DEV
+do_mkfs_fail -i maxpct=110 $SCRATCH_DEV
+do_mkfs_fail -i align=2 $SCRATCH_DEV
+do_mkfs_fail -i sparse -m crc=0 $SCRATCH_DEV
+do_mkfs_fail -i align=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -i attr=1 -m crc=1 $SCRATCH_DEV
+
+status=0
+exit
diff --git a/tests/xfs/400-input-validation.out b/tests/xfs/400-input-validation.out
new file mode 100644
index 0000000..7080553
--- /dev/null
+++ b/tests/xfs/400-input-validation.out
@@ -0,0 +1,2 @@
+QA output created by 400-input-validation
+silence is golden
diff --git a/tests/xfs/group b/tests/xfs/group
index 5a35a76..002692a 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -290,3 +290,4 @@
 308 auto quick clone
 309 auto clone
 310 auto clone rmap
+400-input-validation auto quick mkfs
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] xfstests: Add mkfs input validation tests
  2016-06-29 10:38 ` [PATCH v2] " Jan Tulak
@ 2016-06-29 12:52   ` Eryu Guan
  2016-06-29 13:03     ` Jan Tulak
  0 siblings, 1 reply; 9+ messages in thread
From: Eryu Guan @ 2016-06-29 12:52 UTC (permalink / raw)
  To: Jan Tulak; +Cc: fstests

On Wed, Jun 29, 2016 at 12:38:13PM +0200, Jan Tulak wrote:
> mkfs.xfs does not do a very good job of input validation. This test
> is designed to exercise the input validation and test good/bad
> combinations of options being set. It will not pass on an old
> mkfs.xfs binary - it is designed to be the test case for an input
> validation cleanup (merged in spring/summer 2016).
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> 
> ---
> 
> I didn't got other feedback than the three small issues fixed bellow, and it is
> passing on current xfsprogs-dev as it should. So I think that it can be merged.

Looks good to me.

> 
> CHANGES:
>   * Change copyright year to 2016
>   * rm || true --> rm -f
>   * Change from space to tab indent
> 
> Cheers,
> Jan
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> ---
>  tests/xfs/400-input-validation     | 335 +++++++++++++++++++++++++++++++++++++
>  tests/xfs/400-input-validation.out |   2 +

Only one problem with this test seq name. Current Makefile doesn't
support installing such test seq name

  $(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)

Can you please send another patch to fix this?

Thanks,
Eryu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] xfstests: Add mkfs input validation tests
  2016-06-29 12:52   ` Eryu Guan
@ 2016-06-29 13:03     ` Jan Tulak
  0 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-06-29 13:03 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests

On Wed, Jun 29, 2016 at 2:52 PM, Eryu Guan <eguan@redhat.com> wrote:
> On Wed, Jun 29, 2016 at 12:38:13PM +0200, Jan Tulak wrote:
>> mkfs.xfs does not do a very good job of input validation. This test
>> is designed to exercise the input validation and test good/bad
>> combinations of options being set. It will not pass on an old
>> mkfs.xfs binary - it is designed to be the test case for an input
>> validation cleanup (merged in spring/summer 2016).
>>
>> Signed-off-by: Dave Chinner <dchinner@redhat.com>
>> Signed-off-by: Jan Tulak <jtulak@redhat.com>
>>
>> ---
>>
>> I didn't got other feedback than the three small issues fixed bellow, and it is
>> passing on current xfsprogs-dev as it should. So I think that it can be merged.
>
> Looks good to me.
>
>>
>> CHANGES:
>>   * Change copyright year to 2016
>>   * rm || true --> rm -f
>>   * Change from space to tab indent
>>
>> Cheers,
>> Jan
>>
>> Signed-off-by: Jan Tulak <jtulak@redhat.com>
>> ---
>>  tests/xfs/400-input-validation     | 335 +++++++++++++++++++++++++++++++++++++
>>  tests/xfs/400-input-validation.out |   2 +
>
> Only one problem with this test seq name. Current Makefile doesn't
> support installing such test seq name
>
>   $(INSTALL) -m 755 [0-9]?? $(TARGET_DIR)
>
> Can you please send another patch to fix this?
>

O_o

Looks like I forgot the installation part when I was writing the
patches for xfstests for the extended test names. Gonna fix it!

Thanks.

Cheers,
Jan

-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v3] xfstests: Add mkfs input validation tests
  2016-06-14  8:31 [PATCH] xfstests: Add mkfs input validation tests Jan Tulak
  2016-06-23 11:04 ` Eryu Guan
  2016-06-29 10:38 ` [PATCH v2] " Jan Tulak
@ 2016-07-01 16:12 ` Jan Tulak
  2016-07-13 10:46   ` Eryu Guan
  2 siblings, 1 reply; 9+ messages in thread
From: Jan Tulak @ 2016-07-01 16:12 UTC (permalink / raw)
  To: fstests; +Cc: eguan, Jan Tulak, Dave Chinner

mkfs.xfs does not do a very good job of input validation. This test
is designed to exercise the input validation and test good/bad
combinations of options being set. It will not pass on an old
mkfs.xfs binary - it is designed to be the test case for an input
validation cleanup (merged in spring/summer 2016).

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Jan Tulak <jtulak@redhat.com>

---
CHANGES:
  * Skip this test on older binaries, detected by a few feature checks

Cheers,
Jan

Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
 tests/xfs/400-input-validation     | 350 +++++++++++++++++++++++++++++++++++++
 tests/xfs/400-input-validation.out |   2 +
 tests/xfs/group                    |   1 +
 3 files changed, 353 insertions(+)
 create mode 100755 tests/xfs/400-input-validation
 create mode 100644 tests/xfs/400-input-validation.out

diff --git a/tests/xfs/400-input-validation b/tests/xfs/400-input-validation
new file mode 100755
index 0000000..d6f9110
--- /dev/null
+++ b/tests/xfs/400-input-validation
@@ -0,0 +1,350 @@
+#! /bin/bash
+# FS QA Test No. xfs/400
+#
+# mkfs.xfs input validation test. Designed to break mkfs.xfs if it doesn't
+# filter garbage input or invalid option combinations correctly.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Red Hat, Inc.  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.*
+}
+
+# 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
+
+# Skip if we are running an older binary without the stricter input checks.
+# Make multiple checks to be sure that there is no regression on the one
+# selected feature check, which would skew the result.
+$MKFS_XFS_PROG -f -N -s size=2s $SCRATCH_DEV >/dev/null 2>&1
+sum=$?
+$MKFS_XFS_PROG -f -N -l version=2,su=$((256 * 1024 + 4096)) $SCRATCH_DEV >/dev/null 2>&1
+sum=`expr $sum + $?`
+
+if [ "$sum" -eq 0 ]; then
+	_notrun "Requires newer mkfs with stricter input checks."
+fi
+
+
+
+
+rm -f $seqres.full
+echo silence is golden
+
+# clear out any options to mkfs first. We want to test realtime and external log
+# devices if we can, but we also want to control them ourselves.
+logdev=$SCRATCH_LOGDEV
+rtdev=$SCRATCH_RTDEV
+
+MKFS_OPTIONS=
+SCRATCH_LOGDEV=
+SCRATCH_RTDEV=
+
+# limit the image size of the filesystem being created to something small
+fssize=$((4 * 1024 * 1024 * 1024))
+logsize=$((4 * 1024 * 1024 * 100))
+fsimg=$TEST_DIR/$seq.img
+
+do_mkfs_pass()
+{
+	echo >> $seqres.full
+	echo "pass expected $*" >> $seqres.full
+	$MKFS_XFS_PROG -f -N $* >> $seqres.full 2>&1
+	[ $? -ne 0 ] && echo "fail $*"
+}
+
+do_mkfs_fail()
+{
+	echo >> $seqres.full
+	echo "fail expected $*" >> $seqres.full
+	$MKFS_XFS_PROG -f -N $* >> $seqres.full 2>&1
+	[ $? -eq 0 ] && echo "pass $*"
+}
+
+reset_fsimg()
+{
+	rm -f $fsimg
+	$XFS_IO_PROG -f -c "truncate $fssize" $fsimg
+}
+
+reset_fsimg
+
+do_mkfs_pass $SCRATCH_DEV
+
+# basic "should fail" options
+
+# specifying sector sizes in sectors or blocks or garbage
+do_mkfs_fail -s size=2s $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2s $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2s $SCRATCH_DEV
+do_mkfs_fail -s size=2b $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2b $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2b $SCRATCH_DEV
+
+do_mkfs_fail -s size=grot $SCRATCH_DEV
+do_mkfs_fail -s size=2yerk $SCRATCH_DEV
+do_mkfs_fail -d sectsize=blah $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2foo $SCRATCH_DEV
+do_mkfs_fail -l sectsize=nggh $SCRATCH_DEV
+do_mkfs_fail -l sectsize=2nggh $SCRATCH_DEV
+
+# conflicting sector/block sizes
+do_mkfs_fail -s size=512 -d sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -s size=512 -l sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -d sectsize=2048 -l sectsize=1024 $SCRATCH_DEV
+
+do_mkfs_fail -b size=512 -s size=1024 $SCRATCH_DEV
+do_mkfs_fail -b size=512 -d sectsize=1024 $SCRATCH_DEV
+do_mkfs_fail -b size=512 -l sectsize=1024 $SCRATCH_DEV
+
+# specifying block sizes in sectors without specifying sector size
+# or in blocks or garbage
+do_mkfs_fail -b size=2s $SCRATCH_DEV
+do_mkfs_fail -b size=2b $SCRATCH_DEV
+do_mkfs_fail -b size=nfi $SCRATCH_DEV
+do_mkfs_fail -b size=4096nfi $SCRATCH_DEV
+do_mkfs_fail -n size=2s $SCRATCH_DEV
+do_mkfs_fail -n size=2b $SCRATCH_DEV
+do_mkfs_fail -n size=nfi $SCRATCH_DEV
+do_mkfs_fail -n size=4096nfi $SCRATCH_DEV
+
+# bad label length
+do_mkfs_fail -L thisiswaytoolong $SCRATCH_DEV
+
+# basic "should pass" data section tests
+do_mkfs_pass $SCRATCH_DEV
+do_mkfs_pass -d name=$SCRATCH_DEV
+do_mkfs_pass -d size=$fssize $SCRATCH_DEV
+do_mkfs_pass -d agcount=32 $SCRATCH_DEV
+do_mkfs_pass -d agsize=32m $SCRATCH_DEV
+do_mkfs_pass -d agsize=32M $SCRATCH_DEV
+do_mkfs_pass -d agsize=1g $SCRATCH_DEV
+do_mkfs_pass -d agsize=$((32 * 1024 * 1024)) $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -d agsize=8192b $SCRATCH_DEV
+do_mkfs_pass -d sectsize=512,agsize=65536s $SCRATCH_DEV
+do_mkfs_pass -s size=512 -d agsize=65536s $SCRATCH_DEV
+do_mkfs_pass -d noalign $SCRATCH_DEV
+do_mkfs_pass -d sunit=0,swidth=0 $SCRATCH_DEV
+do_mkfs_pass -d sunit=8,swidth=8 $SCRATCH_DEV
+do_mkfs_pass -d sunit=8,swidth=64 $SCRATCH_DEV
+do_mkfs_pass -d su=0,sw=0 $SCRATCH_DEV
+do_mkfs_pass -d su=4096,sw=1 $SCRATCH_DEV
+do_mkfs_pass -d su=4k,sw=1 $SCRATCH_DEV
+do_mkfs_pass -d su=4K,sw=8 $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -d su=1b,sw=8 $SCRATCH_DEV
+do_mkfs_pass -d sectsize=512,su=8s,sw=8 $SCRATCH_DEV
+do_mkfs_pass -s size=512 -d su=8s,sw=8 $SCRATCH_DEV
+
+# invalid data section tests
+do_mkfs_fail -d size=${fssize}b $SCRATCH_DEV
+do_mkfs_fail -d size=${fssize}s $SCRATCH_DEV
+do_mkfs_fail -d size=${fssize}yerk $SCRATCH_DEV
+do_mkfs_fail -d agsize=8192b $SCRATCH_DEV
+do_mkfs_fail -d agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -d agsize=32Mbsdfsdo $SCRATCH_DEV
+do_mkfs_fail -d agsize=1GB $SCRATCH_DEV
+do_mkfs_fail -d agcount=1k $SCRATCH_DEV
+do_mkfs_fail -d agcount=6b $SCRATCH_DEV
+do_mkfs_fail -d agcount=32,agsize=32m $SCRATCH_DEV
+do_mkfs_fail -d sunit=0,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=0 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=64,noalign $SCRATCH_DEV
+do_mkfs_fail -d sunit=64k,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sunit=64,swidth=64m $SCRATCH_DEV
+do_mkfs_fail -d su=0,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=0 $SCRATCH_DEV
+do_mkfs_fail -d su=4097,sw=1 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64,noalign $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64s $SCRATCH_DEV
+do_mkfs_fail -d su=4096s,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096b,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096garabge,sw=64 $SCRATCH_DEV
+do_mkfs_fail -d su=4096,sw=64,sunit=64,swidth=64 $SCRATCH_DEV
+do_mkfs_fail -d sectsize=10,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -d sectsize=512s,agsize=65536s $SCRATCH_DEV
+
+reset_fsimg
+
+# file section, should pass
+do_mkfs_pass $fsimg
+do_mkfs_pass -d file=0 $SCRATCH_DEV
+do_mkfs_pass -d size=$fssize,file=1,name=$fsimg
+do_mkfs_pass -d size=$fssize,file $fsimg
+do_mkfs_pass -d size=$fssize $fsimg
+do_mkfs_pass -d size=$fssize,name=$fsimg
+do_mkfs_pass -d size=$((fssize/2)) $fsimg
+# again this one, to check that we didn't truncated the file
+do_mkfs_pass -d size=$fssize $fsimg
+rm -f $fsimg
+do_mkfs_pass -d file,size=$fssize $fsimg
+
+reset_fsimg
+
+# file section, should fail
+do_mkfs_fail -d file=1 $SCRATCH_DEV
+do_mkfs_fail -d file $fsimg # no size given
+rm -f $fsimg
+do_mkfs_fail $fsimg
+do_mkfs_fail -d size=$fssize $fsimg
+
+reset_fsimg
+
+# log section, should pass
+do_mkfs_pass -l size=$logsize -d size=$fssize $SCRATCH_DEV
+do_mkfs_pass -l agnum=2 $SCRATCH_DEV
+do_mkfs_pass -l size=4096b $SCRATCH_DEV
+do_mkfs_pass -l sectsize=512 $SCRATCH_DEV
+do_mkfs_pass -l sunit=64 $SCRATCH_DEV
+do_mkfs_pass -l sunit=64 -d sunit=8,swidth=8 $SCRATCH_DEV
+do_mkfs_pass -l sunit=8 $SCRATCH_DEV
+do_mkfs_pass -l su=$((4096*10)) $SCRATCH_DEV
+do_mkfs_pass -b size=4096 -l su=10b $SCRATCH_DEV
+do_mkfs_pass -l sectsize=512,su=$((4096*10)) $SCRATCH_DEV
+do_mkfs_pass -l internal $SCRATCH_DEV
+$XFS_IO_PROG -f -c "truncate $logsize" $fsimg
+do_mkfs_pass -l logdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -l name=$fsimg $SCRATCH_DEV
+do_mkfs_pass -l lazy-count=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l lazy-count=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=2 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -l version=2 $SCRATCH_DEV
+
+# log section, should fail
+do_mkfs_fail -l size=${fssize}b $SCRATCH_DEV
+do_mkfs_fail -l size=${fssize}s $SCRATCH_DEV
+do_mkfs_fail -l size=${fssize}yerk $SCRATCH_DEV
+do_mkfs_fail -l agnum=1k $SCRATCH_DEV
+do_mkfs_fail -l agnum=6b $SCRATCH_DEV
+do_mkfs_fail -l agnum=32 $SCRATCH_DEV
+do_mkfs_fail -l sunit=0  $SCRATCH_DEV
+do_mkfs_fail -l sunit=63 $SCRATCH_DEV
+do_mkfs_fail -l su=1 $SCRATCH_DEV
+do_mkfs_fail -l su=10b $SCRATCH_DEV
+do_mkfs_fail -l su=10s $SCRATCH_DEV
+do_mkfs_fail -l su=$((4096*10+1)) $SCRATCH_DEV
+do_mkfs_fail -l sectsize=10,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -l sectsize=512s,agsize=65536s $SCRATCH_DEV
+do_mkfs_fail -l internal=0 $SCRATCH_DEV
+reset_fsimg
+do_mkfs_fail -l internal=1,logdev=$fsimg $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=1garbage $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=2 $SCRATCH_DEV
+do_mkfs_fail -l lazy-count=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=1 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -l version=0  $SCRATCH_DEV
+
+
+
+# naming section, should pass
+do_mkfs_pass -n size=65536 $SCRATCH_DEV
+do_mkfs_pass -n log=15 $SCRATCH_DEV
+do_mkfs_pass -n version=2 $SCRATCH_DEV
+do_mkfs_pass -n version=ci $SCRATCH_DEV
+do_mkfs_pass -n ftype=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -n ftype=1 $SCRATCH_DEV
+
+# naming section, should fail
+do_mkfs_fail -n version=1 $SCRATCH_DEV
+do_mkfs_fail -n version=cid $SCRATCH_DEV
+do_mkfs_fail -n ftype=4 $SCRATCH_DEV
+do_mkfs_fail -n ftype=0 $SCRATCH_DEV
+
+reset_fsimg
+
+# metadata section, should pass
+do_mkfs_pass -m crc=1,finobt=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=1,finobt=0 $SCRATCH_DEV
+do_mkfs_pass -m crc=0,finobt=0 $SCRATCH_DEV
+do_mkfs_pass -m crc=1 -n ftype=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=0 -n ftype=1 $SCRATCH_DEV
+do_mkfs_pass -m crc=0 -n ftype=0 $SCRATCH_DEV
+
+# metadata section, should fail
+do_mkfs_fail -m crc=0,finobt=1 $SCRATCH_DEV
+do_mkfs_fail -m crc=1 -n ftype=0 $SCRATCH_DEV
+
+
+# realtime section, should pass
+do_mkfs_pass -r rtdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -r extsize=4k $SCRATCH_DEV
+do_mkfs_pass -r extsize=1G $SCRATCH_DEV
+do_mkfs_pass -r size=65536,rtdev=$fsimg $SCRATCH_DEV
+do_mkfs_pass -r noalign $SCRATCH_DEV
+
+
+# realtime section, should fail
+do_mkfs_fail -r rtdev=$SCRATCH_DEV
+do_mkfs_fail -r extsize=256 $SCRATCH_DEV
+do_mkfs_fail -r extsize=2G $SCRATCH_DEV
+do_mkfs_fail -r size=65536 $SCRATCH_DEV
+
+
+
+# inode section, should pass
+do_mkfs_pass -i size=256 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i size=512 $SCRATCH_DEV
+do_mkfs_pass -i size=2048 $SCRATCH_DEV
+do_mkfs_pass -i log=10 $SCRATCH_DEV
+do_mkfs_pass -i perblock=2 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=10 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=100 $SCRATCH_DEV
+do_mkfs_pass -i maxpct=0 $SCRATCH_DEV
+do_mkfs_pass -i align=0 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i align=1 -m crc=1 $SCRATCH_DEV
+do_mkfs_pass -i attr=1 -m crc=0 $SCRATCH_DEV
+do_mkfs_pass -i attr=2 $SCRATCH_DEV
+do_mkfs_pass -i projid32bit $SCRATCH_DEV
+do_mkfs_pass -i sparse=0 $SCRATCH_DEV
+do_mkfs_pass -i sparse -m crc $SCRATCH_DEV
+
+
+# inode section, should fail
+do_mkfs_fail -i size=256 -m crc $SCRATCH_DEV
+do_mkfs_fail -i size=128 $SCRATCH_DEV
+do_mkfs_fail -i size=513 $SCRATCH_DEV
+do_mkfs_fail -i size=4096 $SCRATCH_DEV
+do_mkfs_fail -i maxpct=110 $SCRATCH_DEV
+do_mkfs_fail -i align=2 $SCRATCH_DEV
+do_mkfs_fail -i sparse -m crc=0 $SCRATCH_DEV
+do_mkfs_fail -i align=0 -m crc=1 $SCRATCH_DEV
+do_mkfs_fail -i attr=1 -m crc=1 $SCRATCH_DEV
+
+status=0
+exit
diff --git a/tests/xfs/400-input-validation.out b/tests/xfs/400-input-validation.out
new file mode 100644
index 0000000..7080553
--- /dev/null
+++ b/tests/xfs/400-input-validation.out
@@ -0,0 +1,2 @@
+QA output created by 400-input-validation
+silence is golden
diff --git a/tests/xfs/group b/tests/xfs/group
index 5a35a76..002692a 100644
--- a/tests/xfs/group
+++ b/tests/xfs/group
@@ -290,3 +290,4 @@
 308 auto quick clone
 309 auto clone
 310 auto clone rmap
+400-input-validation auto quick mkfs
-- 
2.5.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] xfstests: Add mkfs input validation tests
  2016-07-01 16:12 ` [PATCH v3] " Jan Tulak
@ 2016-07-13 10:46   ` Eryu Guan
  2016-07-14 10:20     ` Jan Tulak
  0 siblings, 1 reply; 9+ messages in thread
From: Eryu Guan @ 2016-07-13 10:46 UTC (permalink / raw)
  To: Jan Tulak; +Cc: fstests, Dave Chinner

On Fri, Jul 01, 2016 at 06:12:37PM +0200, Jan Tulak wrote:
> mkfs.xfs does not do a very good job of input validation. This test
> is designed to exercise the input validation and test good/bad
> combinations of options being set. It will not pass on an old
> mkfs.xfs binary - it is designed to be the test case for an input
> validation cleanup (merged in spring/summer 2016).
> 
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> 
> ---
> CHANGES:
>   * Skip this test on older binaries, detected by a few feature checks
> 
> Cheers,
> Jan
> 
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> ---
>  tests/xfs/400-input-validation     | 350 +++++++++++++++++++++++++++++++++++++
>  tests/xfs/400-input-validation.out |   2 +
>  tests/xfs/group                    |   1 +
>  3 files changed, 353 insertions(+)
>  create mode 100755 tests/xfs/400-input-validation
>  create mode 100644 tests/xfs/400-input-validation.out
> 
> diff --git a/tests/xfs/400-input-validation b/tests/xfs/400-input-validation
> new file mode 100755
> index 0000000..d6f9110
> --- /dev/null
> +++ b/tests/xfs/400-input-validation
> @@ -0,0 +1,350 @@
> +#! /bin/bash
> +# FS QA Test No. xfs/400
> +#
> +# mkfs.xfs input validation test. Designed to break mkfs.xfs if it doesn't
> +# filter garbage input or invalid option combinations correctly.
> +#
> +#-----------------------------------------------------------------------
> +# Copyright (c) 2016 Red Hat, Inc.  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.*
> +}
> +
> +# 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
> +
> +# Skip if we are running an older binary without the stricter input checks.
> +# Make multiple checks to be sure that there is no regression on the one
> +# selected feature check, which would skew the result.
> +$MKFS_XFS_PROG -f -N -s size=2s $SCRATCH_DEV >/dev/null 2>&1
> +sum=$?
> +$MKFS_XFS_PROG -f -N -l version=2,su=$((256 * 1024 + 4096)) $SCRATCH_DEV >/dev/null 2>&1
> +sum=`expr $sum + $?`
> +
> +if [ "$sum" -eq 0 ]; then
> +	_notrun "Requires newer mkfs with stricter input checks."
> +fi

I think this can be put into a new _require rule in common/rc, as Dave
suggested in his previous review:

"
... a "_require_xfs_mkfs_validation" rule should be
written to determine the version of mkfs being. e.g. by testing one
of the failure cases that the unfixed binary says is ok.
"

Thanks,
Eryu

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v3] xfstests: Add mkfs input validation tests
  2016-07-13 10:46   ` Eryu Guan
@ 2016-07-14 10:20     ` Jan Tulak
  0 siblings, 0 replies; 9+ messages in thread
From: Jan Tulak @ 2016-07-14 10:20 UTC (permalink / raw)
  To: Eryu Guan; +Cc: fstests, Dave Chinner

On Wed, Jul 13, 2016 at 12:46 PM, Eryu Guan <eguan@redhat.com> wrote:
> On Fri, Jul 01, 2016 at 06:12:37PM +0200, Jan Tulak wrote:
>> +
>> +# Skip if we are running an older binary without the stricter input checks.
>> +# Make multiple checks to be sure that there is no regression on the one
>> +# selected feature check, which would skew the result.
>> +$MKFS_XFS_PROG -f -N -s size=2s $SCRATCH_DEV >/dev/null 2>&1
>> +sum=$?
>> +$MKFS_XFS_PROG -f -N -l version=2,su=$((256 * 1024 + 4096)) $SCRATCH_DEV >/dev/null 2>&1
>> +sum=`expr $sum + $?`
>> +
>> +if [ "$sum" -eq 0 ]; then
>> +     _notrun "Requires newer mkfs with stricter input checks."
>> +fi
>
> I think this can be put into a new _require rule in common/rc, as Dave
> suggested in his previous review:
>
> "
> ... a "_require_xfs_mkfs_validation" rule should be
> written to determine the version of mkfs being. e.g. by testing one
> of the failure cases that the unfixed binary says is ok.
> "
>

Mmm, I would say that there is a question whether any other test will
ever need it (and its author remember that there is such function),
but all right. You are two now, who says this, so I will go along.

And I think I will put everything into one patchset, because extended
names fixes has to be applied first for _notrun to work correctly,
then the common/rc functions (I'm making two - one for the new and one
for the old behaviour) and at last can come this and the xfs/096 test.

-- 
Jan Tulak
jtulak@redhat.com / jan@tulak.me

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-07-14 10:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-14  8:31 [PATCH] xfstests: Add mkfs input validation tests Jan Tulak
2016-06-23 11:04 ` Eryu Guan
2016-06-23 11:10   ` Jan Tulak
2016-06-29 10:38 ` [PATCH v2] " Jan Tulak
2016-06-29 12:52   ` Eryu Guan
2016-06-29 13:03     ` Jan Tulak
2016-07-01 16:12 ` [PATCH v3] " Jan Tulak
2016-07-13 10:46   ` Eryu Guan
2016-07-14 10:20     ` Jan Tulak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.