From: Jan Tulak <jtulak@redhat.com>
To: fstests@vger.kernel.org
Cc: eguan@redhat.com, Jan Tulak <jtulak@redhat.com>
Subject: [PATCH v2] xfstests: add _require_xfs_mkfs_validation to common/rc
Date: Thu, 14 Jul 2016 17:57:03 +0200 [thread overview]
Message-ID: <1468511823-16184-1-git-send-email-jtulak@redhat.com> (raw)
In-Reply-To: <1468500214-6237-5-git-send-email-jtulak@redhat.com>
Add a simple way to skip a test if it is (or is not) run on mkfs correctly
validating inputs.
Signed-off-by: Jan Tulak <jtulak@redhat.com>
---
UPDATE:
* Use tmp file instead of scratch - we are using -N flag, so it doesn't
really matter.
* Make both _requires to use the same function for testing, so if it is ever
changed, the change will be reflected in both.
---
common/rc | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/common/rc b/common/rc
index 0c68e4f..c66d31d 100644
--- a/common/rc
+++ b/common/rc
@@ -3843,6 +3843,39 @@ _get_fs_sysfs_attr()
cat /sys/fs/${FSTYP}/${dname}/${attr}
}
+# 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.
+#
+# At first, make a common function that runs the tests and returns
+# number of failed cases.
+mkfs_validation_check()
+{
+ local cmd="$MKFS_XFS_PROG -f -N -d file,name=/tmp/foo,size=$((1024 * 1024 * 1024))"
+ $cmd -s size=2s >/dev/null 2>&1
+ local sum=$?
+ $cmd -l version=2,su=$((256 * 1024 + 4096)) >/dev/null 2>&1
+ sum=`expr $sum + $?`
+ return $sum
+}
+# Skip the test if all calls passed - mkfs accepts invalid input
+_require_xfs_mkfs_validation()
+{
+ mkfs_validation_check
+ if [ "$?" -eq 0 ]; then
+ _notrun "Requires newer mkfs with stricter input checks: the oldest supported version of xfsprogs is 4.7."
+ fi
+}
+
+# The oposite of _require_xfs_mkfs_validation.
+_require_xfs_mkfs_without_validation()
+{
+ mkfs_validation_check
+ if [ "$?" -ne 0 ]; then
+ _notrun "Requires older mkfs without strict input checks: the last supported version of xfsprogs is 4.5."
+ fi
+}
+
init_rc
################################################################################
--
2.5.5
next prev parent reply other threads:[~2016-07-14 15:57 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-14 12:43 [PATCH 0/6 v3] xfstests: some small fixes and mkfs validation test Jan Tulak
2016-07-14 12:43 ` [PATCH 1/6] xfstests: Fix installation for extended names Jan Tulak
2016-07-14 12:43 ` [PATCH 2/6] fstests: filename handling for extended names in ./check was on a wrong place Jan Tulak
2016-07-14 12:43 ` [PATCH 3/6] xfstests: remove unused variable Jan Tulak
2016-07-14 12:43 ` [PATCH 4/6] xfstests: add _require_xfs_mkfs_validation to common/rc Jan Tulak
2016-07-14 14:21 ` Eryu Guan
2016-07-14 15:16 ` Jan Tulak
2016-07-14 15:57 ` Jan Tulak [this message]
2016-07-14 12:43 ` [PATCH 5/6] xfstests: update xfs/096 for new behaviour Jan Tulak
2016-07-14 12:43 ` [PATCH 6/6] xfstests: Add mkfs input validation tests Jan Tulak
2016-07-16 9:33 ` Eryu Guan
2016-07-17 23:30 ` Dave Chinner
2016-07-18 11:29 ` Jan Tulak
2016-07-18 11:47 ` Eryu Guan
2016-07-18 11:54 ` Jan Tulak
2016-07-18 12:33 ` Jan Tulak
2016-07-20 23:54 ` Dave Chinner
2016-07-21 14:24 ` Jan Tulak
2016-07-21 22:40 ` Dave Chinner
2016-07-22 13:08 ` Jan Tulak
2016-07-16 10:28 ` [PATCH 0/6 v3] xfstests: some small fixes and mkfs validation test Eryu Guan
2016-07-18 8:47 ` [PATCH v2] xfstests: Fix installation for extended names Jan Tulak
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=1468511823-16184-1-git-send-email-jtulak@redhat.com \
--to=jtulak@redhat.com \
--cc=eguan@redhat.com \
--cc=fstests@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