xfstests: cleanup duplicates in all tests
[xfstests-dev.git] / tests / generic / 074
1 #! /bin/bash
2 # FS QA Test No. 074
3 #
4 # fstest
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=0        # success is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     rm -rf $testdir/fstest.$$.* $tmp.*
38     _cleanup_testdir
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 _do_test()
46 {
47     _n="$1"
48     _param="$2"
49
50     out=$testdir/fstest.$$.$_n
51     rm -rf $out
52     if ! mkdir $out
53     then
54         echo "    failed to mkdir $out"
55         status=1
56         exit
57     fi
58
59     _filter_param=`echo "$_param" | sed\
60         -e 's/-n [0-9][0-9]*/-n children/' \
61         -e 's/-l [0-9][0-9]*/-l loops/' \
62         -e 's/-f [0-9][0-9]*/-f files/'`
63     
64     echo ""
65     echo "-----------------------------------------------"
66     echo "fstest.$_n : $_filter_param"
67     echo "-----------------------------------------------"
68     if ! $here/src/fstest $_param -p $out >>$seqres.full
69     then
70         echo "    fstest ($_param) returned $? - see $seqres.full"
71         status=1
72         exit
73     fi
74
75     _check_test_fs
76 }
77
78 _usage()
79 {
80     echo "$0: [-f files] [-l loops] [-n children]"
81 }
82
83 _process_args()
84 {
85     while getopts "f:l:n:?" c $@
86     do
87         case $c
88         in
89             f)
90                 numfiles=$OPTARG
91                 param_type="$param_type, overidde -f"
92                 ;;
93             l)
94                 numloops=$OPTARG
95                 param_type="$param_type, overidde -l"
96                 ;;
97             n)
98                 numchildren=$OPTARG
99                 param_type="$param_type, overidde -n"
100                 ;;
101             ?)
102                 _usage
103                 exit    
104                 ;;
105         esac
106     done
107 }
108
109 # real QA test starts here
110 rm -f $seqres.full
111
112 _supported_fs generic
113 _supported_os IRIX Linux
114
115 #
116 # set params
117 # These params can take a while on different CPUs/OSs
118 # so we set them differently for different machines
119 #
120 if [ $HOSTOS == "IRIX" ]; then 
121     if uname -R | grep -iq debug; then 
122         # e.g. getting around 37secs for 1,1,1 on IP30 debug
123         numchildren=2
124         numloops=1
125         numfiles=2
126         param_type="IRIX debug"
127     else
128         # getting around 1 sec 1,1,1 - 10secs 1,10,1 on IP30 nondebug
129         numloops=2
130         numfiles=3
131         numchildren=3
132         param_type="IRIX nondebug"
133     fi
134 elif [ $HOSTOS == "Linux" ]; then
135     if uname -a | grep -q SMP; then
136         numloops=10
137         numfiles=5
138         numchildren=3
139         param_type="Linux SMP"
140     else
141         numloops=2
142         numfiles=3
143         numchildren=3
144         param_type="Linux UP"
145     fi
146 else
147     numloops=1
148     numfiles=1
149     numchildren=1
150     param_type="Default"
151 fi
152
153 # can override the params here
154 _process_args "$@"
155
156 echo "Params are for $param_type" >>$seqres.full
157 echo "Params: n = $numchildren l = $numloops f = $numfiles" >>$seqres.full
158
159 _setup_testdir
160
161 _check_test_fs
162
163 # Options:
164 # -F                    generate files with holes  (default=no)
165 # -n num_children       set number of child processes (default=1)
166 # -f num_files          set number of files (default=1)
167 # -s file_size          set file sizes (default=1MiB)
168 # -b block_size         set block (IO) size (default=1024)
169 # -l loops              set loop count (default=100)
170 # -m                    use mmap (default=no)
171 # -S                    use synchronous IO (default=no)
172 # -P                    preallocate space (default=no)
173
174 size10=`expr 10 \* 1024 \* 1024`        # 10 megabytes
175 size30=`expr 30 \* 1024 \* 1024`        # 30 megabytes
176
177 _do_test 0 "-l $numloops"
178
179 _do_test 1 "-l $numloops -s $size10 -b 8192 -m"
180
181 _do_test 2 "-n $numchildren -F -l $numloops -f $numfiles -s $size30 -b 512"
182
183 _do_test 3 "-n $numchildren -F -l $numloops -f $numfiles -s $size30 -b 512 -m"
184
185 _do_test 4 "-n $numchildren -F -l $numloops -f $numfiles -s $size10 -b 512 -mS"