2 #########################################################################
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: run-convtest,v $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
42 typeset RUNNAME
=`date +%Y%m%d%H%M%S`
43 typeset PRINTDATE
=`date`
44 typeset PDB_INFILE_DIR
45 typeset PDB_OUTFILE_DIR
46 typeset XML_OUTFILE_DIR
53 typeset ODD_BGCOLOR
='#BBBBBB'
54 typeset EVEN_BGCOLOR
='#DCDCDC'
55 typeset PASS_COLOR
='#00ff00'
56 typeset FAIL_COLOR
='#ff4040'
59 # The following variables should be set in the env file
61 typeset TESTCASEDIR
=""
62 typeset RESULTSBASE
=""
64 typeset APORTIS_JAR
=""
65 typeset WORDSMITH_JAR
=""
66 typeset MINICALC_JAR
=""
70 typeset TEST_DRIVER_PL
=""
71 typeset COMPARATOR_PL
=""
73 typeset XML_INFILE_DIR
=""
74 typeset PDB_BASELINE_DIR
=""
75 typeset XML_BASELINE_DIR
=""
76 typeset EM_SCRIPT_HOME
=""
77 typeset QAWRAPPER_SCRIPT_HOME
=""
78 typeset EM_ROM_FILE
=""
79 typeset EM_SESSION_FILE
=""
80 typeset QA_LIB_HOME
=""
81 typeset QA_COMPARATOR_HOME
=""
82 typeset CLASSES_DIR
=""
86 ################################################################################
88 echo "Usage: run-convtest -env <ENVFILE> [-name RUNNAME]"
93 ################################################################################
99 ReportLine
"<TITLE>XMerge Converters Test Results - ${RUNNAME}</TITLE>"
101 ReportLine
"<BODY BGCOLOR=#ffffff>"
102 ReportLine
"<H1 align=center>XMerge Converters Test Results - ${RUNNAME}</H1>"
104 ReportLine
"Test run on: ${PRINTDATE}"
106 ReportLine
"<CENTER>"
107 ReportLine
"<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=2>"
108 ReportLine
"<TR BGCOLOR='#9999CC'>"
109 ReportLine
"<TH>Test Name</TH>"
110 ReportLine
"<TH>Test File</TH>"
111 ReportLine
"<TH>.ext</TH>"
112 ReportLine
"<TH>Result</TH>"
113 ReportLine
"<TH>Comments</TH>"
118 ################################################################################
120 # remove full path from LOGFILE (link will be to current dir)
121 typeset loglink
=${LOGFILE##*/}
124 ReportLine
"<CENTER>"
125 ReportLine
"<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2>"
127 ReportLine
"<TH>Total Tests PASSED</TH>"
128 ReportLine
"<TH>${TOTAL_PASS}</TH>"
131 ReportLine
"<TH>Total Tests FAILED</TH>"
132 ReportLine
"<TH>${TOTAL_FAIL}</TH>"
135 ReportLine
"<TH>Total Tests Run</TH>"
136 ReportLine
"<TH>${TOTAL_RUN}</TH>"
138 ReportLine
"</TABLE>"
139 ReportLine
"</CENTER>"
141 ReportLine
"<A HREF=${loglink}>Full logfile for test run</A>"
143 ReportLine
"<CENTER>"
148 ################################################################################
153 ################################################################################
158 ################################################################################
159 ReportTestComments
() {
160 if [[ $TEST_COMMENTS == "" ]] ; then
161 TEST_COMMENTS
=" "
164 ReportLine
"<TD>${TEST_COMMENTS}</TD>"
167 ################################################################################
172 if [[ $argc -lt 1 ]] ; then
176 while (($i < $argc)) ; do
181 if [[ $arg == '-name' ]] ; then
182 if (( $i < $argc )) ; then
184 echo "RUNNAME=[$RUNNAME]"
190 elif [[ $arg == '-env' ]] ; then
191 if (( $i < $argc )) ; then
203 if [[ $ENVFILE == "" ]] ; then
209 ################################################################################
215 echo "The following values have been set from $ENVFILE:"
216 echo "MASTERLIST=$MASTERLIST"
217 echo "TESTCASEDIR=$TESTCASEDIR"
218 echo "XMERGE_JAR=$XMERGE_JAR"
219 echo "APORTIS_JAR=$APORTIS_JAR"
220 echo "WORDSMITH_JAR=$WORDSMITH_JAR"
221 echo "MINICALC_JAR=$MINICALC_JAR"
222 echo "RESULTSBASE=$RESULTSBASE"
223 echo "PERL5LIB=$PERL5LIB"
224 echo "POSE_EXE=$POSE_EXE"
225 echo "POSE_PRC=$POSE_PRC"
226 echo "TEST_DRIVER_PL=$TEST_DRIVER_PL"
227 echo "COMPARATOR_PL=$COMPARATOR_PL"
228 echo "XML_INFILE_DIR=$XML_INFILE_DIR"
229 echo "PDB_BASELINE_DIR=$PDB_BASELINE_DIR"
230 echo "XML_BASELINE_DIR=$XML_BASELINE_DIR"
231 echo "EM_SCRIPT_HOME=$EM_SCRIPT_HOME"
232 echo "QAWRAPPER_SCRIPT_HOME=$QAWRAPPER_SCRIPT_HOME"
233 echo "EM_ROM_FILE=$EM_ROM_FILE"
234 echo "EM_SESSION_FILE=$EM_SESSION_FILE"
235 echo "QA_LIB_HOME=$QA_LIB_HOME"
236 echo "QA_COMPARATOR_HOME=$QA_COMPARATOR_HOME"
237 echo "CLASSES_DIR=$CLASSES_DIR"
238 echo "COMPLIST=$COMPLIST"
241 ################################################################################
244 export EM_SCRIPT_HOME
245 export QAWRAPPER_SCRIPT_HOME
247 export EM_SESSION_FILE
249 export QA_COMPARATOR_HOME
254 ################################################################################
262 COMPLIST
="${COMPLIST}/tempcomp.${RUNNAME}.list"
263 # create the directories for the results of this test run
264 RESDIR
="${RESULTSBASE}/${RUNNAME}"
268 # Define the directories for the test input files,
269 # test output files, working directories and baseline files
270 PDB_INFILE_DIR
="${RESDIR}/pdb-orig"
271 mkdir
"${PDB_INFILE_DIR}"
272 PDB_OUTFILE_DIR
="${RESDIR}/pdb-new"
273 mkdir
"${PDB_OUTFILE_DIR}"
274 XML_OUTFILE_DIR
="${RESDIR}/xml-new"
275 mkdir
"${XML_OUTFILE_DIR}"
277 LOGFILE
="${RESDIR}/logfile"
278 COMPLOG
="${RESDIR}/complog"
279 REPORT
="${RESDIR}/report.html"
282 echo "Results in: $RESDIR"
283 echo "Report file: $REPORT"
286 ################################################################################
291 ################################################################################
293 # where to pick up converter classes
295 export CLASSPATH
=$CLASSPATH:$XMERGE_JAR
296 export CLASSPATH
=$CLASSPATH:$APORTIS_JAR
297 export CLASSPATH
=$CLASSPATH:$WORDSMITH_JAR
298 export CLASSPATH
=$CLASSPATH:$MINICALC_JAR
301 ################################################################################
307 ################################################################################
312 LogLine
"test_driver output:"
314 # run test_driver in foreground
316 -pose-prc=${POSE_PRC}\
317 -pose-exe=${POSE_EXE}\
318 -xml-orig=${XML_INFILE_DIR}\
319 -pdb-orig=${PDB_INFILE_DIR}\
320 -pdb-new=${PDB_OUTFILE_DIR}\
321 -xml-new=${XML_OUTFILE_DIR}\
322 -test=$testcase -merge >> $LOGFILE 2>&1
324 # cleanup in case zombie POSE processes are hanging around
330 ################################################################################
335 export CLASSPATH
="$CLASSES_DIR/xerces.jar"
337 # create temporary comparator list file for this test case
338 echo $file > $COMPLIST
341 ################################################################################
342 ComparisonCleanup
() {
343 # remove temporary comparator list file used for this test case
347 ################################################################################
352 LogLine
"Comparator output:"
354 -xml-orig=${XML_BASELINE_DIR}\
355 -pdb-orig=${PDB_BASELINE_DIR}\
356 -pdb-new=${PDB_INFILE_DIR}\
357 -xml-new=${XML_OUTFILE_DIR}\
358 -list=$COMPLIST -log=$COMPLOG -type=$type >> $LOGFILE 2>&1
359 # -list=$COMPLIST -log=$COMPLOG -type=$type | tee -a $LOGFILE 2>&1
361 pass
=`grep TRUE $COMPLOG | wc -l`
364 LogLine
"COMPLIST file:"
365 cat $COMPLIST >> $LOGFILE
367 LogLine
"Comparator logfile:"
368 cat $COMPLOG >> $LOGFILE
372 TEST_COMMENTS
="${TEST_COMMENTS}$type comparison ERROR<BR>"
373 echo "$type comparison ERROR"
377 echo "$type comparison OK"
381 ################################################################################
383 typeset xmlfile
="${XML_OUTFILE_DIR}/$1"
384 typeset pdbfile
="${PDB_INFILE_DIR}/$2"
386 if [ ! -f $pdbfile ] ; then
387 TEST_COMMENTS
="${TEST_COMMENTS}[$pdbfile] does not exist<BR>"
388 LogLine
"ERROR: $pdbfile does not exist"
389 echo "ERROR: $pdbfile does not exist"
393 if [ ! -f $xmlfile ] ; then
394 TEST_COMMENTS
="${TEST_COMMENTS}[$xmlfile] does not exist<BR>"
395 LogLine
"ERROR: $xmlfile does not exist"
396 echo "ERROR: $xmlfile does not exist"
403 ################################################################################
412 integer finished_with_test
420 # get chars up to 1st space
421 testcasename
=${line%% *}
422 testcase
="${TESTCASEDIR}/$testcasename"
426 testfile
=${testfile%% *}
431 LogLine
"############################################"
432 LogLine
"Starting the following testcase"
433 LogLine
"testcase = $testcase"
434 LogLine
"testfile = $testfile"
437 ReportLine
"<TR BGCOLOR='${BGCOLOR}'>"
438 ReportLine
"<TD valign=top>$testcasename</TD>"
439 ReportLine
"<TD valign=top>$testfile</TD>"
440 ReportLine
"<TD valign=top>$ext</TD>"
443 echo "testcase = $testcase"
444 echo "testfile = $testfile"
451 while (($finished_with_test == 0)) ; do
454 RunTestCase
$testcase
457 xmlfile
="${testfile}.${ext}"
459 if [[ $ext == "sxc" ]] ; then
460 pdbfile
="${testfile}-Sheet1.pdb"
462 pdbfile
="${testfile}.pdb"
465 CheckOutput
$xmlfile $pdbfile
468 if [[ $res -eq 1 ]] ; then
469 ComparisonSetup
$pdbfile
472 # ignore result until pdb comparator is fixed...
477 if [[ $res -eq 1 ]] ; then
478 ComparisonSetup
$xmlfile
484 if [[ $res -eq 1 ]] ; then
485 TOTAL_PASS
=TOTAL_PASS
+1
486 ReportLine
"<TD valign=top BGCOLOR='${PASS_COLOR}'>PASS</TD>"
489 LogLine
"Test PASSED (on try $try)"
490 echo "Test PASSED (on try $try)"
493 TEST_COMMENTS
="${TEST_COMMENTS}error on try ${try}<BR>"
494 LogLine
"TEST FAILED (on try $try)"
495 echo "TEST FAILED (on try $try)"
497 if [[ $try -eq $MAX_RETRIES ]] ; then
498 TOTAL_FAIL
=TOTAL_FAIL
+1
499 ReportLine
"<TD valign=top BGCOLOR='${FAIL_COLOR}'>FAIL</TD>"
509 TOTAL_RUN
=TOTAL_RUN
+1
511 # toggle BGCOLOR for next report line
512 if [[ $BGCOLOR == $ODD_BGCOLOR ]] ; then
513 BGCOLOR
=$EVEN_BGCOLOR
520 ReportLine
"</TABLE>"
521 ReportLine
"</CENTER>"
525 echo "Total Tests PASSED: "${TOTAL_PASS}
526 echo "Total Tests FAILED: "${TOTAL_FAIL}
527 echo "Total Tests RUN: "${TOTAL_RUN}
528 echo "Results in: $RESDIR"
529 echo "Report file: $REPORT"
532 ################################################################################
533 ################################################################################
535 ################################################################################
536 ################################################################################