3fe9aa006f23ad0c786e46ff0fba54f9c5889153
[xfstests-dev.git] / tests / generic / 112
1 #! /bin/bash
2 # FS QA Test No. 112
3 #
4 # fsx (AIO variant, based on 075)
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2005 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 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=0        # success is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38     cd /
39     rm -rf $testdir/fsx.* $tmp.*
40     _cleanup_testdir
41 }
42
43 # get standard environment, filters and checks
44 . ./common/rc
45 . ./common/filter
46
47 _do_test()
48 {
49     _n="$1"
50     _param="$2"
51
52     out=$testdir/fsx
53     rm -rf $out
54     if ! mkdir $out
55     then
56         echo "    failed to mkdir $out"
57         status=1
58         exit
59     fi
60
61     _filter_param=`echo "$_param" | sed\
62         -e 's/-N [0-9][0-9]*/-N numops/' \
63         -e 's/-l [0-9][0-9]*/-l filelen/'`
64
65     echo ""
66     echo "-----------------------------------------------"
67     echo "fsx.$_n : $_filter_param"
68     echo "-----------------------------------------------"
69
70     if [ "$FSTYP" != "xfs" ]
71     then
72         if [ "$_n" = "1" -o "$_n" = "3" ]
73         then
74             # HACK: only xfs handles preallocation (-x) so just skip this test
75             return
76         fi
77     fi
78
79     # This cd and use of -P gets full debug on $here (not TEST_DEV)
80     cd $out
81     if ! $here/ltp/fsx $_param -P $here $seq.$_n &>/dev/null
82     then
83         echo "    fsx ($_param) returned $? - see $seq.$_n.full"
84         mv $seq.$_n.fsxlog $seqres.$_n.full
85         status=1
86         exit
87     fi
88
89     cd $here
90     _check_test_fs
91 }
92
93 _usage()
94 {
95     echo "$0: [-l filelen] [-n numops1] [-N numops2]"
96 }
97
98 _process_args()
99 {
100     while getopts "l:n:N:?" c $@
101     do
102         case $c
103         in
104             l)
105                 filelen=$OPTARG
106                 param_type="$param_type, overidde -l"
107                 ;;
108             N)
109                 numops2=$OPTARG
110                 param_type="$param_type, overidde -N"
111                 ;;
112             n)
113                 numops1=$OPTARG
114                 param_type="$param_type, overidde -n"
115                 ;;
116             ?)
117                 _usage
118                 exit    
119                 ;;
120         esac
121     done
122 }
123
124
125 # real QA test starts here
126 _supported_fs generic
127 _supported_os Linux
128
129 [ -x $here/ltp/aio-stress ] || \
130         _notrun "fsx not built with AIO for this platform"
131
132 size10=`expr 10 \* 1024 \* 1024`        # 10 megabytes
133 filelen=$size10
134 numops1=1000
135 numops2=10000
136
137 # can override the params here
138 _process_args "$@"
139
140 echo "Params are for $param_type" >>$seqres.full
141 echo "Params: n = $numops1 N = $numops2 l = $filelen" >>$seqres.full
142
143 _setup_testdir
144
145 rm -f $seqres.full
146 echo "brevity is wit..."
147
148 _check_test_fs
149
150 # Options:
151 # -d: debug output for all operations
152 # -l flen: the upper bound on file size (default 262144)
153 # -o oplen: the upper bound on operation size
154 # -N numops: total # operations to do (default infinity)
155 # -P: save .fsxlog and .fsxgood files in dirpath (default ./)
156 # -S seed: for random # generator (default 1) 0 gets timestamp
157 # -x: pre-allocate file space, exercising unwritten extents
158 # -A: use the AIO system calls
159
160 _do_test 0 "-A -d -N $numops1 -S 0"
161 _do_test 1 "-A -d -N $numops1 -S 0 -x"
162 _do_test 2 "-A -d -N $numops2 -l $filelen -S 0"
163 _do_test 3 "-A -d -N $numops2 -l $filelen -S 0 -x"
164
165 rm -f $seq.*.fsx{good,log}
166 exit 0