generic: copy_file_range swapfile test
[xfstests-dev.git] / tests / generic / 231
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. 231
6 #
7 # Run fsx with quotas enabled and verify accounted quotas in the end
8 #
9 # Derived from test 127
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 FSX_FILE_SIZE=64000000
25 FSX_ARGS="-q -l $FSX_FILE_SIZE -o 65536 -N 20000"
26
27 _fsx()
28 {
29         tasks=$1
30         echo "=== FSX Standard Mode, Memory Mapping, $tasks Tasks ==="
31         for (( i = 1; i <= $tasks; i++ )); do
32                 SEED=$RANDOM
33                 echo "ltp/fsx $FSX_ARGS -S $SEED $SCRATCH_MNT/fsx_file$i" >>$seqres.full
34                 su $qa_user -c "ltp/fsx $FSX_ARGS -S $SEED \
35                         $FSX_AVOID $SCRATCH_MNT/fsx_file$i" >$tmp.output$i 2>&1 &
36         done
37
38         for (( i = 1; i <= $tasks; i++ )); do
39                 if ! wait %$i; then
40                         cat $tmp.output$i | tee -a $seqres.full
41                         wait
42                         return 1
43                 fi
44                 $XFS_IO_PROG -c 'fsync' $SCRATCH_MNT/fsx_file$i
45                 cat $tmp.output$i | tee -a $seqres.full
46         done
47         return 0
48 }
49
50 # real QA test starts here
51 _supported_fs generic
52 _supported_os Linux
53 _require_scratch
54 _require_quota
55 _require_user
56
57 rm -f $seqres.full
58 _scratch_mkfs >> $seqres.full 2>&1
59 _scratch_mount "-o usrquota,grpquota"
60 chmod 777 $SCRATCH_MNT
61 quotacheck -u -g $SCRATCH_MNT 2>/dev/null
62 quotaon -u -g $SCRATCH_MNT 2>/dev/null
63
64 if ! _fsx 1; then
65         _scratch_unmount 2>/dev/null
66         status=1
67         exit
68 fi
69
70 if ! _check_quota_usage; then
71         _scratch_unmount 2>/dev/null
72         status=1
73         exit
74 fi
75
76 if ! _fsx 4; then
77         _scratch_unmount 2>/dev/null
78         status=1
79         exit
80 fi
81
82 if ! _check_quota_usage; then
83         _scratch_unmount 2>/dev/null
84         status=1
85         exit
86 fi
87
88 #flush cache after write
89 FSX_ARGS="-f $FSX_ARGS"
90 if ! _fsx 1; then
91         _scratch_unmount 2>/dev/null
92         status=1
93         exit
94 fi
95
96 if ! _check_quota_usage; then
97         _scratch_unmount 2>/dev/null
98         status=1
99         exit
100 fi
101
102 _scratch_unmount 2>/dev/null
103 status=0
104 exit