From: Dave Chinner <david@fromorbit.com>
To: Anand Jain <anand.jain@oracle.com>
Cc: fstests@vger.kernel.org, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 3/3] fstests: btrfs: testcase for sysfs policy syntax verification
Date: Fri, 31 Jan 2025 07:50:11 +1100 [thread overview]
Message-ID: <Z5vmAzAEtzK_EuXO@dread.disaster.area> (raw)
In-Reply-To: <3aecf19197d07ff18ed1c0dda9e63fcaa49b69d1.1738161075.git.anand.jain@oracle.com>
On Wed, Jan 29, 2025 at 11:19:54PM +0800, Anand Jain wrote:
> Checks if the sysfs attribute sanitizes arguments and verifies
> input syntax.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> tests/btrfs/329 | 92 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/329.out | 2 +
> 2 files changed, 94 insertions(+)
> create mode 100755 tests/btrfs/329
> create mode 100644 tests/btrfs/329.out
>
> diff --git a/tests/btrfs/329 b/tests/btrfs/329
> new file mode 100755
> index 000000000000..9f63ab951eac
> --- /dev/null
> +++ b/tests/btrfs/329
> @@ -0,0 +1,92 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2025 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 329
> +#
> +# Verify sysfs knob input syntax.
> +#
> +. ./common/preamble
> +_begin_fstest auto quick
> +
> +. ./common/filter
> +
> +# Modify as appropriate.
> +_require_scratch
> +_require_fs_sysfs read_policy
> +
> +_scratch_mkfs > /dev/null 2>&1 || _fail "mkfs failed"
> +_scratch_mount
> +
> +set_sysfs_policy()
> +{
> + local attr=$1
> + shift
> + local policy=$@
> +
> + _set_fs_sysfs_attr $SCRATCH_DEV $attr ${policy}
> + _get_fs_sysfs_attr $SCRATCH_DEV $attr | grep -q "[${policy}]"
> + if [[ $? != 0 ]]; then
> + echo "Setting sysfs $attr $policy failed"
> + fi
> +}
> +
> +set_sysfs_policy_must_fail()
> +{
> + local attr=$1
> + shift
> + local policy=$@
> +
> + _set_fs_sysfs_attr $SCRATCH_DEV $attr ${policy} | _filter_sysfs_error \
> + | _expect_error_invalid_argument | tee -a $seqres.full
This "catch an exact error or output a different error then use
golden image match failure on secondary error to mark the test as
failed" semantic is .... overly complex.
The output on failure of _filter_sysfs_error will be "Invalid
input". If there's some other failure or it succeeds, the output
will indicate the failure that occurred (i.e. missing line means no
error, different error will output directly by the filter). The
golden image matching will still fail the test.
IOWs, _expect_error_invalid_argument and the output to seqres.full
can go away if the test.out file has a matching error for each
call to set_sysfs_policy_must_fail(). i.e it looks like:
QA output created by 329
Invalid input
Invalid input
Invalid input
Invalid input
Invalid input
Invalid input
.....
Invalid input
-Dave.
--
Dave Chinner
david@fromorbit.com
next prev parent reply other threads:[~2025-01-30 20:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-29 15:19 [PATCH 0/3] fstests: btrfs: add test case to validate sysfs input arguments Anand Jain
2025-01-29 15:19 ` [PATCH 1/3] fstests: common/rc: set_fs_sysfs_attr: redirect errors to stdout Anand Jain
2025-01-29 15:19 ` [PATCH 2/3] fstests: filter: helpers for sysfs error filtering Anand Jain
2025-01-29 15:19 ` [PATCH 3/3] fstests: btrfs: testcase for sysfs policy syntax verification Anand Jain
2025-01-30 20:50 ` Dave Chinner [this message]
2025-01-31 6:43 ` Anand Jain
2025-02-04 0:18 ` Dave Chinner
2025-02-05 11:06 ` Anand Jain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z5vmAzAEtzK_EuXO@dread.disaster.area \
--to=david@fromorbit.com \
--cc=anand.jain@oracle.com \
--cc=fstests@vger.kernel.org \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox