diff mbox series

[v5,1/1] generic: add test for boundary in xfs_attr_shortform_verify

Message ID 20200915132651.238212-2-preichl@redhat.com (mailing list archive)
State New, archived
Headers show
Series generic: add test for boundary in xfs_attr_shortform_verify | expand

Commit Message

Pavel Reichl Sept. 15, 2020, 1:26 p.m. UTC
Add a regression test to check that the boundary test
for the fixed-offset parts of xfs_attr_sf_entry
in xfs_attr_shortform_verify is not off by one.

This can be shown by:

touch file
setfattr -n user.a file

With help from Zorro. Thanks very much.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
---
 tests/generic/611     | 58 +++++++++++++++++++++++++++++++++++++++++++
 tests/generic/611.out |  2 ++
 tests/generic/group   |  1 +
 3 files changed, 61 insertions(+)
 create mode 100755 tests/generic/611
 create mode 100644 tests/generic/611.out

Comments

Zorro Lang Sept. 16, 2020, 1:44 a.m. UTC | #1
On Tue, Sep 15, 2020 at 03:26:51PM +0200, Pavel Reichl wrote:
> Add a regression test to check that the boundary test
> for the fixed-offset parts of xfs_attr_sf_entry
> in xfs_attr_shortform_verify is not off by one.
> 
> This can be shown by:
> 
> touch file
> setfattr -n user.a file
> 
> With help from Zorro. Thanks very much.
> 
> Signed-off-by: Pavel Reichl <preichl@redhat.com>
> ---

Looks good to me,
Reviewed-by: Zorro Lang <zlang@redhat.com>

>  tests/generic/611     | 58 +++++++++++++++++++++++++++++++++++++++++++
>  tests/generic/611.out |  2 ++
>  tests/generic/group   |  1 +
>  3 files changed, 61 insertions(+)
>  create mode 100755 tests/generic/611
>  create mode 100644 tests/generic/611.out
> 
> diff --git a/tests/generic/611 b/tests/generic/611
> new file mode 100755
> index 00000000..069db6f9
> --- /dev/null
> +++ b/tests/generic/611
> @@ -0,0 +1,58 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
> +#
> +# FS QA Test 611
> +#
> +# Verify that metadata won't get corrupted when extended attribute
> +# name of size one is set.
> +#
> +# This test verifies the problem fixed in kernel with commit
> +# f4020438fab0 ("xfs: fix boundary test in xfs_attr_shortform_verify")
> +
> +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
> +. ./common/attr
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +
> +_supported_fs generic
> +_supported_os Linux
> +_require_scratch
> +_require_attrs
> +
> +_scratch_mkfs > $seqres.full 2>&1
> +_scratch_mount
> +
> +localfile="${SCRATCH_MNT}/testfile"
> +
> +touch "${localfile}"
> +"${SETFATTR_PROG}" -n user.a "${localfile}"
> +
> +# Make sure that changes are written to disk
> +_scratch_cycle_mount
> +
> +# If the target bug isn't fixed, getfattr fails
> +${GETFATTR_PROG} --absolute-names -n user.a $localfile | grep 'user.a'
> +
> +status=0
> +exit
> diff --git a/tests/generic/611.out b/tests/generic/611.out
> new file mode 100644
> index 00000000..1ab12434
> --- /dev/null
> +++ b/tests/generic/611.out
> @@ -0,0 +1,2 @@
> +QA output created by 611
> +user.a=""
> diff --git a/tests/generic/group b/tests/generic/group
> index 8eba6c98..4af4b494 100644
> --- a/tests/generic/group
> +++ b/tests/generic/group
> @@ -613,3 +613,4 @@
>  608 auto attr quick dax
>  609 auto quick rw
>  610 auto quick prealloc zero
> +611 auto quick attr
> -- 
> 2.26.2
>
diff mbox series

Patch

diff --git a/tests/generic/611 b/tests/generic/611
new file mode 100755
index 00000000..069db6f9
--- /dev/null
+++ b/tests/generic/611
@@ -0,0 +1,58 @@ 
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Red Hat, Inc. All Rights Reserved.
+#
+# FS QA Test 611
+#
+# Verify that metadata won't get corrupted when extended attribute
+# name of size one is set.
+#
+# This test verifies the problem fixed in kernel with commit
+# f4020438fab0 ("xfs: fix boundary test in xfs_attr_shortform_verify")
+
+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
+. ./common/attr
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+_require_attrs
+
+_scratch_mkfs > $seqres.full 2>&1
+_scratch_mount
+
+localfile="${SCRATCH_MNT}/testfile"
+
+touch "${localfile}"
+"${SETFATTR_PROG}" -n user.a "${localfile}"
+
+# Make sure that changes are written to disk
+_scratch_cycle_mount
+
+# If the target bug isn't fixed, getfattr fails
+${GETFATTR_PROG} --absolute-names -n user.a $localfile | grep 'user.a'
+
+status=0
+exit
diff --git a/tests/generic/611.out b/tests/generic/611.out
new file mode 100644
index 00000000..1ab12434
--- /dev/null
+++ b/tests/generic/611.out
@@ -0,0 +1,2 @@ 
+QA output created by 611
+user.a=""
diff --git a/tests/generic/group b/tests/generic/group
index 8eba6c98..4af4b494 100644
--- a/tests/generic/group
+++ b/tests/generic/group
@@ -613,3 +613,4 @@ 
 608 auto attr quick dax
 609 auto quick rw
 610 auto quick prealloc zero
+611 auto quick attr