summaryrefslogtreecommitdiff
path: root/tests/generic/600
blob: a4233ecc5fc862c847fccac4a3340874688cfeec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2020 Red Hat, Inc.  All Rights Reserved.
#
# FS QA Test No. 600
#
# Test individual user ID quota grace period extension
# This is the linux quota-tools version of the test
#
# This test only exercises user quota because it's not known whether the
# filesystem can set individual grace timers for each quota type
#
. ./common/preamble
_begin_fstest auto quick quota

# Import common functions.
. ./common/filter
. ./common/quota

# real QA test starts here
_supported_fs generic
_require_scratch
_require_quota
_require_user
_require_setquota_project

_scratch_mkfs >$seqres.full 2>&1
_qmount_option "usrquota"
_qmount

echo "Silence is golden"

# Set a default user inode grace period of 1 second
setquota -t -u 0 1 $SCRATCH_MNT
# Soft inode limit 1, hard limit 5
setquota -u $qa_user 0 0 1 5 $SCRATCH_MNT
# Run qa user over soft limit and go over grace period
su $qa_user -c "touch $SCRATCH_MNT/file1 $SCRATCH_MNT/file2"
sleep 3
# Extend grace to now + 100s
now=`date +%s`
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}'`

# 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

# success, all done
status=0
exit