Add GPL license plate to SGI's test files.
[xfstests-dev.git] / 075
1 #! /bin/sh
2 #
3 #-----------------------------------------------------------------------
4 # Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
9 #
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18 #
19 #-----------------------------------------------------------------------
20 #
21 # FS QA Test No. 075
22 #
23 # fsx (non-AIO variant)
24 #
25 # creator
26 owner=nathans@sgi.com
27
28 seq=`basename $0`
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" = "nfs" ]
71     then
72         if [ "$_n" = "1" -o "$_n" = "3" ]
73         then
74             # HACK: nfs don't handle 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) failed, $? - compare $seq.$_n.{good,bad,fsxlog}"
84         mv $out/$seq.$_n $here/$seq.$_n.full
85         od -xAx $here/$seq.$_n.full > $here/$seq.$_n.bad
86         od -xAx $here/$seq.$_n.fsxgood > $here/$seq.$_n.good
87         status=1
88         exit
89     fi
90
91     cd $here
92     _check_test_fs
93 }
94
95 _usage()
96 {
97     echo "$0: [-l filelen] [-n numops1] [-N numops2]"
98 }
99
100 _process_args()
101 {
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
127 # real QA test starts here
128 _supported_fs xfs udf nfs
129 _supported_os IRIX Linux
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" >>$seq.full
140 echo "Params: n = $numops1 N = $numops2 l = $filelen" >>$seq.full
141
142 _setup_testdir
143
144 rm -f $here/$seq.full
145 echo "brevity is wit..."
146
147 _check_test_fs
148
149 # Options:
150 # -d: debug output for all operations
151 # -l flen: the upper bound on file size (default 262144)
152 # -o oplen: the upper bound on operation size
153 # -N numops: total # operations to do (default infinity)
154 # -P: save .fsxlog and .fsxgood files in dirpath (default ./)
155 # -S seed: for random # generator (default 1) 0 gets timestamp
156 # -x: pre-allocate file space, exercising unwritten extents
157
158 _do_test 0 "-d -N $numops1 -S 0"
159 _do_test 1 "-d -N $numops1 -S 0 -x"
160 _do_test 2 "-d -N $numops2 -l $filelen -S 0"
161 _do_test 3 "-d -N $numops2 -l $filelen -S 0 -x"
162
163 rm -f $seq.*.fsx{good,log}
164 exit 0