From 4f9dd7359651b5d3507bd3734b2c09649a3cb0f6 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Mon, 14 Sep 2020 18:43:08 -0700 Subject: [PATCH] generic/60[01]: fix test failure when setting new grace limit 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 Reviewed-by: Christoph Hellwig Reviewed-by: Zorro Lang Signed-off-by: Eryu Guan --- tests/generic/600 | 4 +++- tests/generic/601 | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 -- 2.30.2