common/rc: Add _require_{chown,chmod}()
[xfstests-dev.git] / tests / generic / 233
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FSQA Test No. 233
6 #
7 # Run fsstress with quotas enabled and limits set low and verify accounted
8 # quotas in the end
9 #
10 # Derived from test 231
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
19
20 # get standard environment, filters and checks
21 . ./common/rc
22 . ./common/filter
23 . ./common/quota
24
25 _filter_num()
26 {
27         tee -a $seqres.full |\
28         sed -e 's/[0-9][0-9]* inodes/I inodes/g' \
29             -e 's/[0-9][0-9]* paths/P paths/g' \
30             -e 's/seed = [0-9][0-9]*/seed = S/'
31 }
32
33 _fsstress()
34 {
35         echo ""
36         echo "Testing fsstress"
37         echo ""
38
39         out=$SCRATCH_MNT/fsstress.$$
40         count=5000
41         args=`_scale_fsstress_args -z \
42 -f rmdir=20 -f link=10 -f creat=10 -f mkdir=10 -f unlink=20 -f symlink=10 \
43 -f rename=10 -f fsync=2 -f write=15 -f dwrite=15 \
44 -n $count -d $out -p 7`
45
46         # io_uring accounts memory it needs under the rlimit memlocked option,
47         # which can be quite low on some setups (especially 64K pagesize). root
48         # isn't under this restriction, but regular users are. To avoid the
49         # io_uring_queue_init fail on ENOMEM, set max locked memory to unlimited
50         # temporarily.
51         ulimit -l unlimited
52         echo "fsstress $args" >> $seqres.full
53         if ! su $qa_user -c "$FSSTRESS_PROG $args" | tee -a $seqres.full | _filter_num
54         then
55                 echo "    fsstress $args returned $?"
56                 cat $tmp.out | tee -a $seqres.full
57                 status=1
58         fi
59 }
60
61 # real QA test starts here
62 _supported_fs generic
63 _require_scratch
64 _require_quota
65 _require_user
66
67 _scratch_mkfs > $seqres.full 2>&1
68 _scratch_mount "-o usrquota,grpquota"
69 chmod 777 $SCRATCH_MNT
70 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
71 quotaon -u -g $SCRATCH_MNT 2>/dev/null
72 setquota -u $qa_user 32000 32000 1000 1000 $SCRATCH_MNT 2>/dev/null
73
74 _fsstress
75 _check_quota_usage
76 _scratch_unmount
77 status=0
78 exit