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