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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
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
# 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