From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: guaneryu@gmail.com, darrick.wong@oracle.com
Cc: linux-xfs@vger.kernel.org, Amir Goldstein <amir73il@gmail.com>,
fstests@vger.kernel.org
Subject: [PATCH 1/3] generic/402: skip test if xfs_io can't parse the date value
Date: Tue, 03 Mar 2020 18:46:34 -0800 [thread overview]
Message-ID: <158328999421.2374922.12052887381904972734.stgit@magnolia> (raw)
In-Reply-To: <158328998787.2374922.4223951558305234252.stgit@magnolia>
From: Darrick J. Wong <darrick.wong@oracle.com>
If xfs_io's utimes command cannot interpret the arguments that are given
to it, it will print out "Bad value for [am]time". Detect when this
happens and drop the file out of the test entirely.
This is particularly noticeable on 32-bit platforms and the largest
timestamp seconds supported by the filesystem is INT_MAX. In this case,
the maximum value we can cram into tv_sec is INT_MAX, and there is no
way to actually test setting a timestamp of INT_MAX + 1 to test the
clamping.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
---
tests/generic/402 | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/tests/generic/402 b/tests/generic/402
index 2a34d127..2481a5d2 100755
--- a/tests/generic/402
+++ b/tests/generic/402
@@ -63,10 +63,26 @@ run_test_individual()
# check if the time needs update
if [ $update_time -eq 1 ]; then
echo "Updating file: $file to timestamp $timestamp" >> $seqres.full
- $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file
- if [ $? -ne 0 ]; then
+ rm -f $tmp.utimes
+ $XFS_IO_PROG -f -c "utimes $timestamp 0 $timestamp 0" $file > $tmp.utimes 2>&1
+ local res=$?
+
+ cat $tmp.utimes >> $seqres.full
+ if [ "$timestamp" -ne 0 ] && grep -q "Bad value" "$tmp.utimes"; then
+ echo "xfs_io could not interpret time value \"$timestamp\", skipping \"$file\" test." >> $seqres.full
+ rm -f $file $tmp.utimes
+ return
+ fi
+ cat $tmp.utimes
+ rm -f $tmp.utimes
+ if [ $res -ne 0 ]; then
echo "Failed to update times on $file" | tee -a $seqres.full
fi
+ else
+ if [ ! -f "$file" ]; then
+ echo "xfs_io did not create file for time value \"$timestamp\", skipping test." >> $seqres.full
+ return
+ fi
fi
tsclamp=$((timestamp<tsmin?tsmin:timestamp>tsmax?tsmax:timestamp))
next prev parent reply other threads:[~2020-03-04 2:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-04 2:46 [PATCH 0/3] fstests: random stuff Darrick J. Wong
2020-03-04 2:46 ` Darrick J. Wong [this message]
2020-03-06 9:33 ` [PATCH 1/3] generic/402: skip test if xfs_io can't parse the date value Zorro Lang
2020-03-04 2:46 ` [PATCH 2/3] xfs: refactor calls to xfs_admin Darrick J. Wong
2020-03-06 9:53 ` Zorro Lang
2020-03-04 2:46 ` [PATCH 3/3] xfs: make sure xfs_db/xfs_quota commands are documented Darrick J. Wong
2020-03-06 10:06 ` Zorro Lang
2020-03-06 15:41 ` Darrick J. Wong
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=158328999421.2374922.12052887381904972734.stgit@magnolia \
--to=darrick.wong@oracle.com \
--cc=amir73il@gmail.com \
--cc=fstests@vger.kernel.org \
--cc=guaneryu@gmail.com \
--cc=linux-xfs@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;
as well as URLs for NNTP newsgroup(s).