fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 234
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 Jan Kara.  All Rights Reserved.
4 # Copyright (c) 2005 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # FS QA Test No. 234
7 #
8 # Stress setquota and setinfo handling.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
18
19 # get standard environment, filters and checks
20 . ./common/rc
21 . ./common/filter
22 . ./common/quota
23
24 test_setting()
25 {
26         echo; echo "### test limits and info setting"
27         count=2000
28         procs=5
29         idmod=200000
30         seed=$RANDOM
31         RANDOM=$seed
32         echo "Starting test with procs=$procs, idmod=$idmod, and seed=$seed" >>$seqres.full
33
34         for (( i = 0; i < $procs; i++ )); do
35                 ( SETUCOUNT=1; SETGCOUNT=1; SETUIDS[0]=0; SETGIDS[0]=0
36                 for (( j = 0; j < $count; j++ )); do
37                         OP=$(($RANDOM%22))
38                         UG=$(($OP%2))
39                         OP=$(($OP/2))
40                         if [ $UG -eq 1 ]; then
41                                 type='u'
42                         else
43                                 type='g'
44                         fi
45                         if [ $OP -eq 10 ]; then
46                                 setquota -t -$type $j $j $SCRATCH_MNT
47                         elif [ $OP -lt 5 ]; then
48                                 ID=$((($RANDOM*32768+$RANDOM)%$idmod))
49                                 if [ $UG -eq 1 ]; then
50                                         SETUIDS[$SETUCOUNT]=$ID
51                                         SETUCOUNT=$(($SETUCOUNT+1))
52                                 else
53                                         SETGIDS[$SETGCOUNT]=$ID
54                                         SETGCOUNT=$(($SETGCOUNT+1))
55                                 fi
56                                 setquota -$type $ID $j $j $j $j $SCRATCH_MNT
57                         else
58                                 if [ $UG -eq 1 ]; then
59                                         ID=${SETUIDS[$(($RANDOM%$SETUCOUNT))]}
60                                 else
61                                         ID=${SETGIDS[$(($RANDOM%$SETGCOUNT))]}
62                                 fi
63                                 setquota -$type $ID 0 0 0 0 $SCRATCH_MNT
64                         fi
65                 done )&
66         done
67         wait
68         echo "### done with testing"
69 }
70
71 # real QA test starts here
72 _supported_fs generic
73 _supported_os Linux
74 _require_scratch
75 _require_quota
76
77 # real QA test starts here
78 rm -f $seqres.full
79
80 _scratch_mkfs >> $seqres.full 2>&1
81 _scratch_mount "-o usrquota,grpquota"
82 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
83 quotaon -u -g $SCRATCH_MNT 2>/dev/null
84 test_setting
85 _scratch_unmount
86
87 status=0
88 exit