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