Added qa machine porky to common.confing.
[xfstests-dev.git] / common
1 ##/bin/sh 
2 #
3 # Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
4
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of version 2 of the GNU General Public License as
7 # published by the Free Software Foundation.
8
9 # This program is distributed in the hope that it would be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 # Further, this software is distributed without any warranty that it is
14 # free of the rightful claim of any third person regarding infringement
15 # or the like.  Any license provided herein, whether implied or
16 # otherwise, applies only to this software file.  Patent licenses, if
17 # any, provided herein do not apply to combinations of this program with
18 # other software, or any other product whatsoever.
19
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write the Free Software Foundation, Inc., 59
22 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
23
24 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 # Mountain View, CA  94043, or:
26
27 # http://www.sgi.com 
28
29 # For further information regarding this notice, see: 
30
31 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
32 #
33 # common procedures for QA scripts
34 #
35 # $Header: /disk7/depot/linux/pcp/dev/qa/RCS/common,v 2.52 2000/04/05 18:24:51 kenmcd Exp $
36 #
37
38 _setenvironment()
39 {
40     MSGVERB="text:action"
41     export MSGVERB
42 }
43
44 here=`pwd`
45 rm -f $here/$iam.out
46 _setenvironment
47
48 check=${check-true}
49
50 diff=diff
51 if [ ! -z "$DISPLAY" ]
52 then
53     which xdiff >/dev/null 2>&1 && diff=xdiff
54     which gdiff >/dev/null 2>&1 && diff=gdiff
55     which tkdiff >/dev/null 2>&1 && diff=tkdiff
56     which xxdiff >/dev/null 2>&1 && diff=xxdiff
57 fi
58 verbose=false
59 group=false
60 xgroup=false
61 showme=false
62 sortme=false
63 expunge=true
64 have_test_arg=false
65 rm -f $tmp.list $tmp.tmp $tmp.sed
66
67 export FSTYP=xfs
68
69 for r
70 do
71
72     if $group
73     then
74         # arg after -g
75         group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
76 s/ .*//p
77 }'`
78         if [ -z "$group_list" ]
79         then
80             echo "Group \"$r\" is empty or not defined?"
81             exit 1
82         fi
83         [ ! -s $tmp.list ] && touch $tmp.list
84         for t in $group_list
85         do
86             if grep -s "^$t\$" $tmp.list >/dev/null
87             then
88                 :
89             else
90                 echo "$t" >>$tmp.list
91             fi
92         done
93         group=false
94         continue
95
96     elif $xgroup
97     then
98         # arg after -x
99         [ ! -s $tmp.list ] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list 2>/dev/null
100         group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
101 s/ .*//p
102 }'`
103         if [ -z "$group_list" ]
104         then
105             echo "Group \"$r\" is empty or not defined?"
106             exit 1
107         fi
108         numsed=0
109         rm -f $tmp.sed
110         for t in $group_list
111         do
112             if [ $numsed -gt 100 ]
113             then
114                 sed -f $tmp.sed <$tmp.list >$tmp.tmp
115                 mv $tmp.tmp $tmp.list
116                 numsed=0
117                 rm -f $tmp.sed
118             fi
119             echo "/^$t\$/d" >>$tmp.sed
120             numsed=`expr $numsed + 1`
121         done
122         sed -f $tmp.sed <$tmp.list >$tmp.tmp
123         mv $tmp.tmp $tmp.list
124         xgroup=false
125         continue
126     fi
127
128     xpand=true
129     case "$r"
130     in
131
132         -\?)    # usage
133             echo "Usage: $0 [options] [testlist]"'
134
135 common options
136     -v                  verbose
137
138 check options
139     -xfs                test XFS
140     -udf                test UDF
141     -nfs                test NFS
142     -g group[,group...] include tests from these groups
143     -l                  line mode diff [xdiff]
144     -n                  show me, do not run tests
145     -q                  quick [deprecated]
146     -T                  output timestamps
147     -x group[,group...] exclude tests from these groups
148     -r                  randomize order
149 '
150             exit 0
151             ;;
152
153         -udf)   # -udf ... set FSTYP to udf
154             FSTYP=udf
155             xpand=false
156             ;;
157
158         -xfs)   # -xfs ... set FSTYP to xfs
159             FSTYP=xfs
160             xpand=false
161             ;;
162
163         -nfs)   # -nfs ... set FSTYP to nfs
164             FSTYP=nfs
165             xpand=false
166             ;;
167
168         -g)     # -g group ... pick from group file
169             group=true
170             xpand=false
171             ;;
172
173         -l)     # line mode for diff, not gdiff over modems
174             diff=diff
175             xpand=false
176             ;;
177
178         -q)     # "quick", no longer used - always quick :-)
179             xpand=false
180             ;;
181
182         -n)     # show me, don't do it
183             showme=true
184             xpand=false
185             ;;
186
187         -T)     # turn on timestamp output
188             timestamp=true
189             xpand=false
190             ;;
191
192         -v)
193             verbose=true
194             xpand=false
195             ;;
196         -x)     # -x group ... exclude from group file
197             xgroup=true
198             xpand=false
199             ;;
200         '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
201             echo "No tests?"
202             status=1
203             exit $status
204             ;;
205
206         [0-9]*-[0-9]*)
207             eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
208             ;;
209
210         [0-9]*-)
211             eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
212             end=`echo [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] | sed -e 's/\[0-9]//g' -e 's/  *$//' -e 's/.* //'`
213             if [ -z "$end" ]
214             then
215                 echo "No tests in range \"$r\"?"
216                 status=1
217                 exit $status
218             fi
219             ;;
220
221         *)
222             start=$r
223             end=$r
224             ;;
225
226     esac
227
228     # get rid of leading 0s as can be interpreted as octal
229     start=`echo $start | sed 's/^0*//'`
230     end=`echo $end | sed 's/^0*//'`
231
232     if $xpand
233     then
234         have_test_arg=true
235         $AWK_PROG </dev/null '
236 BEGIN   { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
237         | while read id
238         do
239             if grep -s "^$id " group >/dev/null
240             then
241                 # in group file ... OK
242                 echo $id >>$tmp.list
243             else
244                 if [ -f expunged ] && $expunge && egrep "^$id([         ]|\$)" expunged >/dev/null
245                 then
246                     # expunged ... will be reported, but not run, later
247                     echo $id >>$tmp.list
248                 else
249                     # oops
250                     echo "$id - unknown test, ignored"
251                 fi
252             fi
253         done
254     fi
255
256 done
257
258 if [ -s $tmp.list ]
259 then
260     # found some valid test numbers ... this is good
261     :
262 else
263     if $have_test_arg
264     then
265         # had test numbers, but none in group file ... do nothing
266         touch $tmp.list
267     else
268         # no test numbers, do everything from group file
269         sed -n -e '/^[0-9][0-9][0-9]*/s/[       ].*//p' <group >$tmp.list
270     fi
271 fi
272
273 # should be sort -n, but this did not work for Linux when this
274 # was ported from IRIX
275 #
276 list=`sort $tmp.list`
277 rm -f $tmp.list $tmp.tmp $tmp.sed
278
279 case "$FSTYP" in
280     xfs)
281          [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
282          [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
283          [ "$XFS_CHECK_PROG" = "" ] && _fatal "xfs_check not found"
284          [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
285          [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found" 
286          ;;
287     udf)
288          [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"
289          ;;
290     nfs)
291          ;;
292 esac