1cdf0e10cSrcweir#!/bin/ksh
2*e76eebc6SAndrew Rist#**************************************************************
3*e76eebc6SAndrew Rist#
4*e76eebc6SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
5*e76eebc6SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
6*e76eebc6SAndrew Rist#  distributed with this work for additional information
7*e76eebc6SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
8*e76eebc6SAndrew Rist#  to you under the Apache License, Version 2.0 (the
9*e76eebc6SAndrew Rist#  "License"); you may not use this file except in compliance
10*e76eebc6SAndrew Rist#  with the License.  You may obtain a copy of the License at
11*e76eebc6SAndrew Rist#
12*e76eebc6SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
13*e76eebc6SAndrew Rist#
14*e76eebc6SAndrew Rist#  Unless required by applicable law or agreed to in writing,
15*e76eebc6SAndrew Rist#  software distributed under the License is distributed on an
16*e76eebc6SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17*e76eebc6SAndrew Rist#  KIND, either express or implied.  See the License for the
18*e76eebc6SAndrew Rist#  specific language governing permissions and limitations
19*e76eebc6SAndrew Rist#  under the License.
20*e76eebc6SAndrew Rist#
21*e76eebc6SAndrew Rist#**************************************************************
22cdf0e10cSrcweir
23cdf0e10cSrcweir#set -x
24cdf0e10cSrcweirumask 0
25cdf0e10cSrcweir
26cdf0e10cSrcweirinteger TOTAL_PASS=0
27cdf0e10cSrcweirinteger TOTAL_FAIL=0
28cdf0e10cSrcweirinteger TOTAL_RUN=0
29cdf0e10cSrcweirinteger MAX_RETRIES=5
30cdf0e10cSrcweirtypeset RUNNAME=`date +%Y%m%d%H%M%S`
31cdf0e10cSrcweirtypeset PRINTDATE=`date`
32cdf0e10cSrcweirtypeset PDB_INFILE_DIR
33cdf0e10cSrcweirtypeset PDB_OUTFILE_DIR
34cdf0e10cSrcweirtypeset XML_OUTFILE_DIR
35cdf0e10cSrcweirtypeset REPORT
36cdf0e10cSrcweirtypeset RESDIR
37cdf0e10cSrcweirtypeset LOGFILE
38cdf0e10cSrcweirtypeset COMPLOG
39cdf0e10cSrcweirtypeset TEST_COMMENTS
40cdf0e10cSrcweirtypeset BGCOLOR
41cdf0e10cSrcweirtypeset ODD_BGCOLOR='#BBBBBB'
42cdf0e10cSrcweirtypeset EVEN_BGCOLOR='#DCDCDC'
43cdf0e10cSrcweirtypeset PASS_COLOR='#00ff00'
44cdf0e10cSrcweirtypeset FAIL_COLOR='#ff4040'
45cdf0e10cSrcweir
46cdf0e10cSrcweirtypeset ENVFILE=""
47cdf0e10cSrcweir# The following variables should be set in the env file
48cdf0e10cSrcweirtypeset MASTERLIST=""
49cdf0e10cSrcweirtypeset TESTCASEDIR=""
50cdf0e10cSrcweirtypeset RESULTSBASE=""
51cdf0e10cSrcweirtypeset XMERGE_JAR=""
52cdf0e10cSrcweirtypeset APORTIS_JAR=""
53cdf0e10cSrcweirtypeset WORDSMITH_JAR=""
54cdf0e10cSrcweirtypeset MINICALC_JAR=""
55cdf0e10cSrcweirtypeset PERL5LIB=""
56cdf0e10cSrcweirtypeset POSE_EXE=""
57cdf0e10cSrcweirtypeset POSE_PRC=""
58cdf0e10cSrcweirtypeset TEST_DRIVER_PL=""
59cdf0e10cSrcweirtypeset COMPARATOR_PL=""
60cdf0e10cSrcweirtypeset COMPLIST=""
61cdf0e10cSrcweirtypeset XML_INFILE_DIR=""
62cdf0e10cSrcweirtypeset PDB_BASELINE_DIR=""
63cdf0e10cSrcweirtypeset XML_BASELINE_DIR=""
64cdf0e10cSrcweirtypeset EM_SCRIPT_HOME=""
65cdf0e10cSrcweirtypeset QAWRAPPER_SCRIPT_HOME=""
66cdf0e10cSrcweirtypeset EM_ROM_FILE=""
67cdf0e10cSrcweirtypeset EM_SESSION_FILE=""
68cdf0e10cSrcweirtypeset QA_LIB_HOME=""
69cdf0e10cSrcweirtypeset QA_COMPARATOR_HOME=""
70cdf0e10cSrcweirtypeset CLASSES_DIR=""
71cdf0e10cSrcweir
72cdf0e10cSrcweir
73cdf0e10cSrcweir
74cdf0e10cSrcweir################################################################################
75cdf0e10cSrcweirUsage() {
76cdf0e10cSrcweir	echo "Usage: run-convtest -env <ENVFILE> [-name RUNNAME]"
77cdf0e10cSrcweir	exit 1
78cdf0e10cSrcweir}
79cdf0e10cSrcweir
80cdf0e10cSrcweir
81cdf0e10cSrcweir################################################################################
82cdf0e10cSrcweirStartReportFile() {
83cdf0e10cSrcweir	typeset line=`date`
84cdf0e10cSrcweir
85cdf0e10cSrcweir	ReportLine "<HTML>"
86cdf0e10cSrcweir	ReportLine "<HEAD>"
87cdf0e10cSrcweir	ReportLine "<TITLE>XMerge Converters Test Results - ${RUNNAME}</TITLE>"
88cdf0e10cSrcweir	ReportLine "</HEAD>"
89cdf0e10cSrcweir	ReportLine "<BODY BGCOLOR=#ffffff>"
90cdf0e10cSrcweir	ReportLine "<H1 align=center>XMerge Converters Test Results - ${RUNNAME}</H1>"
91cdf0e10cSrcweir	ReportLine "<P>"
92cdf0e10cSrcweir	ReportLine "Test run on: ${PRINTDATE}"
93cdf0e10cSrcweir	ReportLine "<P>"
94cdf0e10cSrcweir	ReportLine "<CENTER>"
95cdf0e10cSrcweir	ReportLine "<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=2>"
96cdf0e10cSrcweir	ReportLine "<TR BGCOLOR='#9999CC'>"
97cdf0e10cSrcweir	ReportLine "<TH>Test Name</TH>"
98cdf0e10cSrcweir	ReportLine "<TH>Test File</TH>"
99cdf0e10cSrcweir	ReportLine "<TH>.ext</TH>"
100cdf0e10cSrcweir	ReportLine "<TH>Result</TH>"
101cdf0e10cSrcweir	ReportLine "<TH>Comments</TH>"
102cdf0e10cSrcweir	ReportLine "</TR>"
103cdf0e10cSrcweir}
104cdf0e10cSrcweir
105cdf0e10cSrcweir
106cdf0e10cSrcweir################################################################################
107cdf0e10cSrcweirEndReportFile() {
108cdf0e10cSrcweir	# remove full path from LOGFILE (link will be to current dir)
109cdf0e10cSrcweir	typeset loglink=${LOGFILE##*/}
110cdf0e10cSrcweir
111cdf0e10cSrcweir	ReportLine "<P>"
112cdf0e10cSrcweir	ReportLine "<CENTER>"
113cdf0e10cSrcweir	ReportLine "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2>"
114cdf0e10cSrcweir	ReportLine "<TR>"
115cdf0e10cSrcweir	ReportLine "<TH>Total Tests PASSED</TH>"
116cdf0e10cSrcweir	ReportLine "<TH>${TOTAL_PASS}</TH>"
117cdf0e10cSrcweir	ReportLine "</TR>"
118cdf0e10cSrcweir	ReportLine "<TR>"
119cdf0e10cSrcweir	ReportLine "<TH>Total Tests FAILED</TH>"
120cdf0e10cSrcweir	ReportLine "<TH>${TOTAL_FAIL}</TH>"
121cdf0e10cSrcweir	ReportLine "</TR>"
122cdf0e10cSrcweir	ReportLine "<TR>"
123cdf0e10cSrcweir	ReportLine "<TH>Total Tests Run</TH>"
124cdf0e10cSrcweir	ReportLine "<TH>${TOTAL_RUN}</TH>"
125cdf0e10cSrcweir	ReportLine "</TR>"
126cdf0e10cSrcweir	ReportLine "</TABLE>"
127cdf0e10cSrcweir	ReportLine "</CENTER>"
128cdf0e10cSrcweir	ReportLine "<P>"
129cdf0e10cSrcweir	ReportLine "<A HREF=${loglink}>Full logfile for test run</A>"
130cdf0e10cSrcweir	ReportLine "<P>"
131cdf0e10cSrcweir	ReportLine "<CENTER>"
132cdf0e10cSrcweir	ReportLine "</BODY>"
133cdf0e10cSrcweir	ReportLine "</HTML>"
134cdf0e10cSrcweir}
135cdf0e10cSrcweir
136cdf0e10cSrcweir################################################################################
137cdf0e10cSrcweirReportLine() {
138cdf0e10cSrcweir	echo $1 >> $REPORT
139cdf0e10cSrcweir}
140cdf0e10cSrcweir
141cdf0e10cSrcweir################################################################################
142cdf0e10cSrcweirLogLine() {
143cdf0e10cSrcweir	echo $1 >> $LOGFILE
144cdf0e10cSrcweir}
145cdf0e10cSrcweir
146cdf0e10cSrcweir################################################################################
147cdf0e10cSrcweirReportTestComments() {
148cdf0e10cSrcweir	if [[ $TEST_COMMENTS == "" ]] ; then
149cdf0e10cSrcweir		TEST_COMMENTS="&nbsp;"
150cdf0e10cSrcweir	fi
151cdf0e10cSrcweir
152cdf0e10cSrcweir	ReportLine "<TD>${TEST_COMMENTS}</TD>"
153cdf0e10cSrcweir}
154cdf0e10cSrcweir
155cdf0e10cSrcweir################################################################################
156cdf0e10cSrcweirGetParams() {
157cdf0e10cSrcweir	integer argc=$#
158cdf0e10cSrcweir	integer i=0
159cdf0e10cSrcweir
160cdf0e10cSrcweir	if [[ $argc -lt 1 ]] ; then
161cdf0e10cSrcweir		Usage
162cdf0e10cSrcweir	fi
163cdf0e10cSrcweir
164cdf0e10cSrcweir	while (($i < $argc)) ; do
165cdf0e10cSrcweir		arg=$1
166cdf0e10cSrcweir		shift
167cdf0e10cSrcweir    		i=i+1
168cdf0e10cSrcweir
169cdf0e10cSrcweir		if [[ $arg == '-name' ]] ; then
170cdf0e10cSrcweir			if (( $i < $argc )) ; then
171cdf0e10cSrcweir				RUNNAME=$1
172cdf0e10cSrcweir				echo "RUNNAME=[$RUNNAME]"
173cdf0e10cSrcweir				shift
174cdf0e10cSrcweir				i=i+1
175cdf0e10cSrcweir			else
176cdf0e10cSrcweir				Usage
177cdf0e10cSrcweir			fi
178cdf0e10cSrcweir		elif [[ $arg == '-env' ]] ; then
179cdf0e10cSrcweir			if (( $i < $argc )) ; then
180cdf0e10cSrcweir				ENVFILE=$1
181cdf0e10cSrcweir				shift
182cdf0e10cSrcweir				i=i+1
183cdf0e10cSrcweir			else
184cdf0e10cSrcweir				Usage
185cdf0e10cSrcweir			fi
186cdf0e10cSrcweir		else
187cdf0e10cSrcweir			Usage
188cdf0e10cSrcweir		fi
189cdf0e10cSrcweir	done
190cdf0e10cSrcweir
191cdf0e10cSrcweir	if [[ $ENVFILE == "" ]] ; then
192cdf0e10cSrcweir		Usage
193cdf0e10cSrcweir	fi
194cdf0e10cSrcweir}
195cdf0e10cSrcweir
196cdf0e10cSrcweir
197cdf0e10cSrcweir################################################################################
198cdf0e10cSrcweirReadEnvFile() {
199cdf0e10cSrcweir	. $ENVFILE
200cdf0e10cSrcweir
201cdf0e10cSrcweir
202cdf0e10cSrcweir	echo ""
203cdf0e10cSrcweir	echo "The following values have been set from $ENVFILE:"
204cdf0e10cSrcweir	echo "MASTERLIST=$MASTERLIST"
205cdf0e10cSrcweir	echo "TESTCASEDIR=$TESTCASEDIR"
206cdf0e10cSrcweir	echo "XMERGE_JAR=$XMERGE_JAR"
207cdf0e10cSrcweir	echo "APORTIS_JAR=$APORTIS_JAR"
208cdf0e10cSrcweir	echo "WORDSMITH_JAR=$WORDSMITH_JAR"
209cdf0e10cSrcweir	echo "MINICALC_JAR=$MINICALC_JAR"
210cdf0e10cSrcweir	echo "RESULTSBASE=$RESULTSBASE"
211cdf0e10cSrcweir	echo "PERL5LIB=$PERL5LIB"
212cdf0e10cSrcweir	echo "POSE_EXE=$POSE_EXE"
213cdf0e10cSrcweir	echo "POSE_PRC=$POSE_PRC"
214cdf0e10cSrcweir	echo "TEST_DRIVER_PL=$TEST_DRIVER_PL"
215cdf0e10cSrcweir	echo "COMPARATOR_PL=$COMPARATOR_PL"
216cdf0e10cSrcweir	echo "XML_INFILE_DIR=$XML_INFILE_DIR"
217cdf0e10cSrcweir	echo "PDB_BASELINE_DIR=$PDB_BASELINE_DIR"
218cdf0e10cSrcweir	echo "XML_BASELINE_DIR=$XML_BASELINE_DIR"
219cdf0e10cSrcweir	echo "EM_SCRIPT_HOME=$EM_SCRIPT_HOME"
220cdf0e10cSrcweir	echo "QAWRAPPER_SCRIPT_HOME=$QAWRAPPER_SCRIPT_HOME"
221cdf0e10cSrcweir	echo "EM_ROM_FILE=$EM_ROM_FILE"
222cdf0e10cSrcweir	echo "EM_SESSION_FILE=$EM_SESSION_FILE"
223cdf0e10cSrcweir	echo "QA_LIB_HOME=$QA_LIB_HOME"
224cdf0e10cSrcweir	echo "QA_COMPARATOR_HOME=$QA_COMPARATOR_HOME"
225cdf0e10cSrcweir	echo "CLASSES_DIR=$CLASSES_DIR"
226cdf0e10cSrcweir	echo "COMPLIST=$COMPLIST"
227cdf0e10cSrcweir}
228cdf0e10cSrcweir
229cdf0e10cSrcweir################################################################################
230cdf0e10cSrcweirPOSESetup() {
231cdf0e10cSrcweir	export PERL5LIB
232cdf0e10cSrcweir	export EM_SCRIPT_HOME
233cdf0e10cSrcweir	export QAWRAPPER_SCRIPT_HOME
234cdf0e10cSrcweir	export EM_ROM_FILE
235cdf0e10cSrcweir	export EM_SESSION_FILE
236cdf0e10cSrcweir	export QA_LIB_HOME
237cdf0e10cSrcweir	export QA_COMPARATOR_HOME
238cdf0e10cSrcweir   	export CLASSES_DIR
239cdf0e10cSrcweir
240cdf0e10cSrcweir}
241cdf0e10cSrcweir
242cdf0e10cSrcweir################################################################################
243cdf0e10cSrcweirTestSetup() {
244cdf0e10cSrcweir
245cdf0e10cSrcweir
246cdf0e10cSrcweir	POSESetup
247cdf0e10cSrcweir
248cdf0e10cSrcweir	export ZENDEBUG=1
249cdf0e10cSrcweir
250cdf0e10cSrcweir	COMPLIST="${COMPLIST}/tempcomp.${RUNNAME}.list"
251cdf0e10cSrcweir	# create the directories for the results of this test run
252cdf0e10cSrcweir	RESDIR="${RESULTSBASE}/${RUNNAME}"
253cdf0e10cSrcweir	\rm -Rf $RESDIR
254cdf0e10cSrcweir	mkdir $RESDIR
255cdf0e10cSrcweir
256cdf0e10cSrcweir	# Define the directories for the test input files,
257cdf0e10cSrcweir	# test output files, working directories and baseline files
258cdf0e10cSrcweir	PDB_INFILE_DIR="${RESDIR}/pdb-orig"
259cdf0e10cSrcweir	mkdir "${PDB_INFILE_DIR}"
260cdf0e10cSrcweir	PDB_OUTFILE_DIR="${RESDIR}/pdb-new"
261cdf0e10cSrcweir	mkdir "${PDB_OUTFILE_DIR}"
262cdf0e10cSrcweir	XML_OUTFILE_DIR="${RESDIR}/xml-new"
263cdf0e10cSrcweir	mkdir "${XML_OUTFILE_DIR}"
264cdf0e10cSrcweir
265cdf0e10cSrcweir	LOGFILE="${RESDIR}/logfile"
266cdf0e10cSrcweir	COMPLOG="${RESDIR}/complog"
267cdf0e10cSrcweir	REPORT="${RESDIR}/report.html"
268cdf0e10cSrcweir	StartReportFile
269cdf0e10cSrcweir
270cdf0e10cSrcweir	echo "Results in: $RESDIR"
271cdf0e10cSrcweir	echo "Report file: $REPORT"
272cdf0e10cSrcweir}
273cdf0e10cSrcweir
274cdf0e10cSrcweir################################################################################
275cdf0e10cSrcweirTestCleanup() {
276cdf0e10cSrcweir	EndReportFile
277cdf0e10cSrcweir}
278cdf0e10cSrcweir
279cdf0e10cSrcweir################################################################################
280cdf0e10cSrcweirTestCaseSetup() {
281cdf0e10cSrcweir	# where to pick up converter classes
282cdf0e10cSrcweir	export CLASSPATH=""
283cdf0e10cSrcweir	export CLASSPATH=$CLASSPATH:$XMERGE_JAR
284cdf0e10cSrcweir	export CLASSPATH=$CLASSPATH:$APORTIS_JAR
285cdf0e10cSrcweir	export CLASSPATH=$CLASSPATH:$WORDSMITH_JAR
286cdf0e10cSrcweir	export CLASSPATH=$CLASSPATH:$MINICALC_JAR
287cdf0e10cSrcweir}
288cdf0e10cSrcweir
289cdf0e10cSrcweir################################################################################
290cdf0e10cSrcweirTestCaseCleanup() {
291cdf0e10cSrcweir	# empty function
292cdf0e10cSrcweir	a=42
293cdf0e10cSrcweir}
294cdf0e10cSrcweir
295cdf0e10cSrcweir################################################################################
296cdf0e10cSrcweirRunTestCase() {
297cdf0e10cSrcweir	testcase=$1
298cdf0e10cSrcweir
299cdf0e10cSrcweir	LogLine ""
300cdf0e10cSrcweir	LogLine "test_driver output:"
301cdf0e10cSrcweir
302cdf0e10cSrcweir	# run test_driver in foreground
303cdf0e10cSrcweir	$TEST_DRIVER_PL\
304cdf0e10cSrcweir		-pose-prc=${POSE_PRC}\
305cdf0e10cSrcweir		-pose-exe=${POSE_EXE}\
306cdf0e10cSrcweir		-xml-orig=${XML_INFILE_DIR}\
307cdf0e10cSrcweir		-pdb-orig=${PDB_INFILE_DIR}\
308cdf0e10cSrcweir		-pdb-new=${PDB_OUTFILE_DIR}\
309cdf0e10cSrcweir		-xml-new=${XML_OUTFILE_DIR}\
310cdf0e10cSrcweir		-test=$testcase -merge >> $LOGFILE 2>&1
311cdf0e10cSrcweir
312cdf0e10cSrcweir	# cleanup in case zombie POSE processes are hanging around
313cdf0e10cSrcweir	pkill pose
314cdf0e10cSrcweir	pkill -9 pose
315cdf0e10cSrcweir}
316cdf0e10cSrcweir
317cdf0e10cSrcweir
318cdf0e10cSrcweir################################################################################
319cdf0e10cSrcweirComparisonSetup() {
320cdf0e10cSrcweir	typeset file=$1
321cdf0e10cSrcweir
322cdf0e10cSrcweir
323cdf0e10cSrcweir	export CLASSPATH="$CLASSES_DIR/xerces.jar"
324cdf0e10cSrcweir
325cdf0e10cSrcweir	# create temporary comparator list file for this test case
326cdf0e10cSrcweir	echo $file > $COMPLIST
327cdf0e10cSrcweir}
328cdf0e10cSrcweir
329cdf0e10cSrcweir################################################################################
330cdf0e10cSrcweirComparisonCleanup() {
331cdf0e10cSrcweir	# remove temporary comparator list file used for this test case
332cdf0e10cSrcweir	\rm -f $COMPLIST
333cdf0e10cSrcweir}
334cdf0e10cSrcweir
335cdf0e10cSrcweir################################################################################
336cdf0e10cSrcweirRunComparison() {
337cdf0e10cSrcweir	typeset type=$1
338cdf0e10cSrcweir
339cdf0e10cSrcweir	LogLine ""
340cdf0e10cSrcweir	LogLine "Comparator output:"
341cdf0e10cSrcweir	$COMPARATOR_PL\
342cdf0e10cSrcweir		-xml-orig=${XML_BASELINE_DIR}\
343cdf0e10cSrcweir		-pdb-orig=${PDB_BASELINE_DIR}\
344cdf0e10cSrcweir		-pdb-new=${PDB_INFILE_DIR}\
345cdf0e10cSrcweir		-xml-new=${XML_OUTFILE_DIR}\
346cdf0e10cSrcweir		-list=$COMPLIST -log=$COMPLOG -type=$type >> $LOGFILE 2>&1
347cdf0e10cSrcweir#		-list=$COMPLIST -log=$COMPLOG -type=$type | tee -a $LOGFILE 2>&1
348cdf0e10cSrcweir
349cdf0e10cSrcweir	pass=`grep TRUE $COMPLOG | wc -l`
350cdf0e10cSrcweir
351cdf0e10cSrcweir	LogLine ""
352cdf0e10cSrcweir	LogLine "COMPLIST file:"
353cdf0e10cSrcweir	cat $COMPLIST >> $LOGFILE
354cdf0e10cSrcweir	LogLine ""
355cdf0e10cSrcweir	LogLine "Comparator logfile:"
356cdf0e10cSrcweir	cat $COMPLOG >> $LOGFILE
357cdf0e10cSrcweir
358cdf0e10cSrcweir	if [ $pass -eq 0 ]
359cdf0e10cSrcweir	then
360cdf0e10cSrcweir		TEST_COMMENTS="${TEST_COMMENTS}$type comparison ERROR<BR>"
361cdf0e10cSrcweir		echo "$type comparison ERROR"
362cdf0e10cSrcweir		return 0
363cdf0e10cSrcweir	fi
364cdf0e10cSrcweir
365cdf0e10cSrcweir	echo "$type comparison OK"
366cdf0e10cSrcweir	return 1
367cdf0e10cSrcweir}
368cdf0e10cSrcweir
369cdf0e10cSrcweir################################################################################
370cdf0e10cSrcweirCheckOutput() {
371cdf0e10cSrcweir	typeset xmlfile="${XML_OUTFILE_DIR}/$1"
372cdf0e10cSrcweir	typeset pdbfile="${PDB_INFILE_DIR}/$2"
373cdf0e10cSrcweir
374cdf0e10cSrcweir	if [ ! -f $pdbfile ] ; then
375cdf0e10cSrcweir		TEST_COMMENTS="${TEST_COMMENTS}[$pdbfile] does not exist<BR>"
376cdf0e10cSrcweir		LogLine "ERROR: $pdbfile does not exist"
377cdf0e10cSrcweir		echo "ERROR: $pdbfile does not exist"
378cdf0e10cSrcweir		return 0
379cdf0e10cSrcweir	fi
380cdf0e10cSrcweir
381cdf0e10cSrcweir	if [ ! -f $xmlfile ] ; then
382cdf0e10cSrcweir		TEST_COMMENTS="${TEST_COMMENTS}[$xmlfile] does not exist<BR>"
383cdf0e10cSrcweir		LogLine "ERROR: $xmlfile does not exist"
384cdf0e10cSrcweir		echo "ERROR: $xmlfile does not exist"
385cdf0e10cSrcweir		return 0
386cdf0e10cSrcweir	fi
387cdf0e10cSrcweir
388cdf0e10cSrcweir	return 1
389cdf0e10cSrcweir}
390cdf0e10cSrcweir
391cdf0e10cSrcweir################################################################################
392cdf0e10cSrcweirRunTest() {
393cdf0e10cSrcweir	typeset testcasename
394cdf0e10cSrcweir	typeset testcase
395cdf0e10cSrcweir	typeset testfile
396cdf0e10cSrcweir	typeset pdbfile
397cdf0e10cSrcweir	typeset xmlfile
398cdf0e10cSrcweir	typeset ext
399cdf0e10cSrcweir	integer try
400cdf0e10cSrcweir	integer finished_with_test
401cdf0e10cSrcweir	integer test_pass
402cdf0e10cSrcweir
403cdf0e10cSrcweir	TestSetup
404cdf0e10cSrcweir
405cdf0e10cSrcweir	BGCOLOR=$ODD_BGCOLOR
406cdf0e10cSrcweir
407cdf0e10cSrcweir	while read line ; do
408cdf0e10cSrcweir		# get chars up to 1st space
409cdf0e10cSrcweir		testcasename=${line%% *}
410cdf0e10cSrcweir		testcase="${TESTCASEDIR}/$testcasename"
411cdf0e10cSrcweir
412cdf0e10cSrcweir		# get 2nd word
413cdf0e10cSrcweir		testfile=${line#* }
414cdf0e10cSrcweir		testfile=${testfile%% *}
415cdf0e10cSrcweir
416cdf0e10cSrcweir		# get last word
417cdf0e10cSrcweir		ext=${line##* }
418cdf0e10cSrcweir
419cdf0e10cSrcweir		LogLine "############################################"
420cdf0e10cSrcweir		LogLine "Starting the following testcase"
421cdf0e10cSrcweir		LogLine "testcase = $testcase"
422cdf0e10cSrcweir		LogLine "testfile = $testfile"
423cdf0e10cSrcweir		LogLine "ext = $ext"
424cdf0e10cSrcweir
425cdf0e10cSrcweir		ReportLine "<TR BGCOLOR='${BGCOLOR}'>"
426cdf0e10cSrcweir		ReportLine "<TD valign=top>$testcasename</TD>"
427cdf0e10cSrcweir		ReportLine "<TD valign=top>$testfile</TD>"
428cdf0e10cSrcweir		ReportLine "<TD valign=top>$ext</TD>"
429cdf0e10cSrcweir
430cdf0e10cSrcweir		echo ""
431cdf0e10cSrcweir		echo "testcase = $testcase"
432cdf0e10cSrcweir		echo "testfile = $testfile"
433cdf0e10cSrcweir		echo "ext = $ext"
434cdf0e10cSrcweir
435cdf0e10cSrcweir		try=1
436cdf0e10cSrcweir		finished_with_test=0
437cdf0e10cSrcweir		TEST_COMMENTS=""
438cdf0e10cSrcweir
439cdf0e10cSrcweir		while (($finished_with_test == 0)) ; do
440cdf0e10cSrcweir
441cdf0e10cSrcweir			TestCaseSetup
442cdf0e10cSrcweir			RunTestCase $testcase
443cdf0e10cSrcweir			TestCaseCleanup
444cdf0e10cSrcweir
445cdf0e10cSrcweir			xmlfile="${testfile}.${ext}"
446cdf0e10cSrcweir
447cdf0e10cSrcweir			if [[ $ext == "sxc" ]] ; then
448cdf0e10cSrcweir				pdbfile="${testfile}-Sheet1.pdb"
449cdf0e10cSrcweir			else
450cdf0e10cSrcweir				pdbfile="${testfile}.pdb"
451cdf0e10cSrcweir			fi
452cdf0e10cSrcweir
453cdf0e10cSrcweir			CheckOutput $xmlfile $pdbfile
454cdf0e10cSrcweir			res=$?
455cdf0e10cSrcweir
456cdf0e10cSrcweir			if [[ $res -eq 1 ]] ; then
457cdf0e10cSrcweir				ComparisonSetup $pdbfile
458cdf0e10cSrcweir				RunComparison pdb
459cdf0e10cSrcweir				res=$?
460cdf0e10cSrcweir# ignore result until pdb comparator is fixed...
461cdf0e10cSrcweirres=1
462cdf0e10cSrcweir				ComparisonCleanup
463cdf0e10cSrcweir			fi
464cdf0e10cSrcweir
465cdf0e10cSrcweir			if [[ $res -eq 1 ]] ; then
466cdf0e10cSrcweir				ComparisonSetup $xmlfile
467cdf0e10cSrcweir				RunComparison xml
468cdf0e10cSrcweir				res=$?
469cdf0e10cSrcweir				ComparisonCleanup
470cdf0e10cSrcweir			fi
471cdf0e10cSrcweir
472cdf0e10cSrcweir			if [[ $res -eq 1 ]] ; then
473cdf0e10cSrcweir				TOTAL_PASS=TOTAL_PASS+1
474cdf0e10cSrcweir				ReportLine "<TD valign=top BGCOLOR='${PASS_COLOR}'>PASS</TD>"
475cdf0e10cSrcweir				ReportTestComments
476cdf0e10cSrcweir				ReportLine "</TR>"
477cdf0e10cSrcweir				LogLine "Test PASSED (on try $try)"
478cdf0e10cSrcweir				echo "Test PASSED (on try $try)"
479cdf0e10cSrcweir				finished_with_test=1
480cdf0e10cSrcweir			else
481cdf0e10cSrcweir				TEST_COMMENTS="${TEST_COMMENTS}error on try ${try}<BR>"
482cdf0e10cSrcweir				LogLine "TEST FAILED (on try $try)"
483cdf0e10cSrcweir				echo "TEST FAILED (on try $try)"
484cdf0e10cSrcweir
485cdf0e10cSrcweir				if [[ $try -eq $MAX_RETRIES ]] ; then
486cdf0e10cSrcweir					TOTAL_FAIL=TOTAL_FAIL+1
487cdf0e10cSrcweir					ReportLine "<TD valign=top BGCOLOR='${FAIL_COLOR}'>FAIL</TD>"
488cdf0e10cSrcweir					ReportTestComments
489cdf0e10cSrcweir					ReportLine "</TR>"
490cdf0e10cSrcweir					finished_with_test=1
491cdf0e10cSrcweir				fi
492cdf0e10cSrcweir			fi
493cdf0e10cSrcweir
494cdf0e10cSrcweir			try=try+1
495cdf0e10cSrcweir		done
496cdf0e10cSrcweir
497cdf0e10cSrcweir		TOTAL_RUN=TOTAL_RUN+1
498cdf0e10cSrcweir
499cdf0e10cSrcweir		# toggle BGCOLOR for next report line
500cdf0e10cSrcweir		if [[ $BGCOLOR == $ODD_BGCOLOR ]] ; then
501cdf0e10cSrcweir			BGCOLOR=$EVEN_BGCOLOR
502cdf0e10cSrcweir		else
503cdf0e10cSrcweir			BGCOLOR=$ODD_BGCOLOR
504cdf0e10cSrcweir		fi
505cdf0e10cSrcweir
506cdf0e10cSrcweir	done < $MASTERLIST
507cdf0e10cSrcweir
508cdf0e10cSrcweir	ReportLine "</TABLE>"
509cdf0e10cSrcweir	ReportLine "</CENTER>"
510cdf0e10cSrcweir
511cdf0e10cSrcweir	TestCleanup
512cdf0e10cSrcweir
513cdf0e10cSrcweir	echo "Total Tests PASSED: "${TOTAL_PASS}
514cdf0e10cSrcweir	echo "Total Tests FAILED: "${TOTAL_FAIL}
515cdf0e10cSrcweir	echo "Total Tests RUN: "${TOTAL_RUN}
516cdf0e10cSrcweir	echo "Results in: $RESDIR"
517cdf0e10cSrcweir	echo "Report file: $REPORT"
518cdf0e10cSrcweir}
519cdf0e10cSrcweir
520cdf0e10cSrcweir################################################################################
521cdf0e10cSrcweir################################################################################
522cdf0e10cSrcweir# main
523cdf0e10cSrcweir################################################################################
524cdf0e10cSrcweir################################################################################
525cdf0e10cSrcweir
526cdf0e10cSrcweirGetParams $@
527cdf0e10cSrcweirReadEnvFile
528cdf0e10cSrcweirRunTest
529cdf0e10cSrcweir
530cdf0e10cSrcweirexit 0
531