fstests: move test group info to test files
[xfstests-dev.git] / tests / generic / 273
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011-2012 Fujitsu, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 273
6 #
7 # reservation test with heavy cp workload
8 #
9 #creator
10
11 . ./common/preamble
12 _begin_fstest auto rw
13
14 status=0        # success is the default!
15
16 # Override the default cleanup function.
17 _cleanup()
18 {
19         cd /
20         rm -rf $tmp.*
21         _scratch_unmount
22 }
23
24 . ./common/filter
25
26 threads=50
27 count=2
28
29 _threads_set()
30 {
31         _cpu_num=`$here/src/feature -o`
32         threads=$(($_cpu_num * 50))
33         if [ $threads -gt 200 ]
34         then
35                 threads=200
36         fi
37 }
38
39 _file_create()
40 {
41         block_size=$1
42         _i=0
43
44         if ! mkdir $SCRATCH_MNT/origin
45         then
46                 echo "mkdir origin err"
47                 status=1
48                 exit
49         fi
50
51         cd $SCRATCH_MNT/origin
52
53         _disksize=`$DF_PROG -B 1 $SCRATCH_MNT | tail -1 | $AWK_PROG '{ print $5 }'`
54         _disksize=$(($_disksize / 3))
55         _num=$(($_disksize / $count / $threads / $block_size))
56         _count=$count
57         while [ $_i -lt $_num ]
58         do
59                 dd if=/dev/zero of=file_$_i bs=$block_size count=$_count >/dev/null 2>&1
60                 _i=$(($_i + 1))
61         done
62
63         cd $here
64 }
65
66 _porter()
67 {
68         _suffix=$1
69
70         if ! mkdir $SCRATCH_MNT/sub_$_suffix
71         then
72                 echo "mkdir sub_xxx err"
73                 status=1
74                 exit
75         fi
76
77         cp -r $SCRATCH_MNT/origin $SCRATCH_MNT/sub_$_suffix >>$seqres.full 2>&1
78         if [ $? -ne 0 ]
79         then
80                 echo "_porter $_suffix not complete"
81         fi
82         
83         sync
84 }
85
86 _do_workload()
87 {
88         _pids=""
89         _pid=1
90         block_size=$(_get_block_size $SCRATCH_MNT)
91         
92         _threads_set
93         _file_create $block_size
94
95         _threads=$threads
96
97         while [ $_pid -lt $_threads ]
98         do
99                 _porter $_pid &
100                 _pids="$_pids $!"
101                 _pid=$(($_pid + 1))
102         done
103
104         wait $_pids
105 }
106
107 # real QA test starts here
108 _supported_fs generic
109 _require_scratch
110
111 echo "------------------------------"
112 echo "start the workload"
113 echo "------------------------------"
114
115 _scratch_unmount 2>/dev/null
116 _scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seqres.full 2>&1
117 _scratch_mount
118
119 _do_workload
120
121 status=0
122 exit