xfstests: cleanup duplicates in all tests
[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 $testdir/fsx.* $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/fsx
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 numops/' \
61         -e 's/-l [0-9][0-9]*/-l filelen/'`
62
63     echo ""
64     echo "-----------------------------------------------"
65     echo "fsx.$_n : $_filter_param"
66     echo "-----------------------------------------------"
67
68     if [ "$FSTYP" != "xfs" ]
69     then
70         if [ "$_n" = "1" -o "$_n" = "3" ]
71         then
72             # HACK: only xfs handles preallocation (-x) so just skip this test
73             return
74         fi
75     fi
76
77     # This cd and use of -P gets full debug on $here (not TEST_DEV)
78     cd $out
79     if ! $here/ltp/fsx $_param -P $here $seq.$_n &>/dev/null
80     then
81         echo "    fsx ($_param) failed, $? - compare $seqres.$_n.{good,bad,fsxlog}"
82         mv $out/$seq.$_n $seqres.$_n.full
83         od -xAx $seqres.$_n.full > $seqres.$_n.bad
84         od -xAx $seqres.$_n.fsxgood > $seqres.$_n.good
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 # real QA test starts here
125 _supported_fs generic
126 _supported_os IRIX Linux
127
128 size10=`expr 10 \* 1024 \* 1024`        # 10 megabytes
129 filelen=$size10
130 numops1=1000
131 numops2=10000
132
133 # can override the params here
134 _process_args "$@"
135
136 echo "Params are for $param_type" >>$seqres.full
137 echo "Params: n = $numops1 N = $numops2 l = $filelen" >>$seqres.full
138
139 _setup_testdir
140
141 rm -f $seqres.full
142 echo "brevity is wit..."
143
144 _check_test_fs
145
146 # Options:
147 # -d: debug output for all operations
148 # -l flen: the upper bound on file size (default 262144)
149 # -o oplen: the upper bound on operation size
150 # -N numops: total # operations to do (default infinity)
151 # -P: save .fsxlog and .fsxgood files in dirpath (default ./)
152 # -S seed: for random # generator (default 1) 0 gets timestamp
153 # -x: pre-allocate file space, exercising unwritten extents
154
155 _do_test 0 "-d -N $numops1 -S 0"
156 _do_test 1 "-d -N $numops1 -S 0 -x"
157 _do_test 2 "-d -N $numops2 -l $filelen -S 0"
158 _do_test 3 "-d -N $numops2 -l $filelen -S 0 -x"
159
160 rm -f $seq.*.fsx{good,log}
161 exit 0