diff mbox series

[02/24] generic/60[01]: fix test failure when setting new grace limit

Message ID 160013418837.2923511.12713913160160876814.stgit@magnolia
State Accepted
Headers show
Series fstests: tons of random fixes | expand

Commit Message

Darrick J. Wong Sept. 15, 2020, 1:43 a.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

The setquota command can extend a quota grace period by a certain number
of seconds.  The extension is provided as a number of seconds relative
to right now.  However, if the system clock increments the seconds count
after this test assigns $now but before setquota gets called, the test
will fail because $get and $set will be off by that 1 second.  Allow for
that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 tests/generic/600 |    4 +++-
 tests/generic/601 |    4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

Comments

Christoph Hellwig Sept. 17, 2020, 7:51 a.m. UTC | #1
On Mon, Sep 14, 2020 at 06:43:08PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> The setquota command can extend a quota grace period by a certain number
> of seconds.  The extension is provided as a number of seconds relative
> to right now.  However, if the system clock increments the seconds count
> after this test assigns $now but before setquota gets called, the test
> will fail because $get and $set will be off by that 1 second.  Allow for
> that.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/tests/generic/600 b/tests/generic/600
index 7ea0d6c2..42e4ee55 100755
--- a/tests/generic/600
+++ b/tests/generic/600
@@ -60,7 +60,9 @@  let set=now+100
 setquota -T -u $qa_user 0 100 $SCRATCH_MNT 2>&1 | grep -v "^setquota"
 get=`repquota -up $SCRATCH_MNT | grep  "^$qa_user" | awk '{print $NF}'`
 
-if [ "$get" != "$set" ]; then
+# Either the new expiry must match; or be one second after the set time, to
+# deal with the seconds counter incrementing.
+if [ "$get" != "$set" ] && [ "$get" -ne "$((set + 1))" ]; then
 	echo "set grace to $set but got grace $get"
 fi
 
diff --git a/tests/generic/601 b/tests/generic/601
index 1baa6a90..b412ee8a 100755
--- a/tests/generic/601
+++ b/tests/generic/601
@@ -71,7 +71,9 @@  $XFS_QUOTA_PROG -x -c "timer -u -i 100 $qa_user" $SCRATCH_MNT
 # raw ("since epoch") grace expiry
 get=`repquota -up $SCRATCH_MNT | grep  "^$qa_user" | awk '{print $NF}'`
 
-if [ "$get" != "$set" ]; then
+# Either the new expiry must match; or be one second after the set time, to
+# deal with the seconds counter incrementing.
+if [ "$get" != "$set" ] && [ "$get" -ne "$((set + 1))" ]; then
 	echo "set grace to $set but got grace $get"
 fi