merge the formfield patch from ooo-build
[ooovba.git] / xmerge / source / palmtests / qa-wrapper / bin / run-convtest
blobfa75a39c9f9f09e74e94324184e9c46c6a01c94f
1 #!/bin/ksh
2 #########################################################################
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 #
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: run-convtest,v $
14 # $Revision: 1.4 $
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 #*************************************************************************
35 #set -x
36 umask 0
38 integer TOTAL_PASS=0
39 integer TOTAL_FAIL=0
40 integer TOTAL_RUN=0
41 integer MAX_RETRIES=5
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
47 typeset REPORT
48 typeset RESDIR
49 typeset LOGFILE
50 typeset COMPLOG
51 typeset TEST_COMMENTS
52 typeset BGCOLOR
53 typeset ODD_BGCOLOR='#BBBBBB'
54 typeset EVEN_BGCOLOR='#DCDCDC'
55 typeset PASS_COLOR='#00ff00'
56 typeset FAIL_COLOR='#ff4040'
58 typeset ENVFILE=""
59 # The following variables should be set in the env file
60 typeset MASTERLIST=""
61 typeset TESTCASEDIR=""
62 typeset RESULTSBASE=""
63 typeset XMERGE_JAR=""
64 typeset APORTIS_JAR=""
65 typeset WORDSMITH_JAR=""
66 typeset MINICALC_JAR=""
67 typeset PERL5LIB=""
68 typeset POSE_EXE=""
69 typeset POSE_PRC=""
70 typeset TEST_DRIVER_PL=""
71 typeset COMPARATOR_PL=""
72 typeset COMPLIST=""
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 ################################################################################
87 Usage() {
88 echo "Usage: run-convtest -env <ENVFILE> [-name RUNNAME]"
89 exit 1
93 ################################################################################
94 StartReportFile() {
95 typeset line=`date`
97 ReportLine "<HTML>"
98 ReportLine "<HEAD>"
99 ReportLine "<TITLE>XMerge Converters Test Results - ${RUNNAME}</TITLE>"
100 ReportLine "</HEAD>"
101 ReportLine "<BODY BGCOLOR=#ffffff>"
102 ReportLine "<H1 align=center>XMerge Converters Test Results - ${RUNNAME}</H1>"
103 ReportLine "<P>"
104 ReportLine "Test run on: ${PRINTDATE}"
105 ReportLine "<P>"
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>"
114 ReportLine "</TR>"
118 ################################################################################
119 EndReportFile() {
120 # remove full path from LOGFILE (link will be to current dir)
121 typeset loglink=${LOGFILE##*/}
123 ReportLine "<P>"
124 ReportLine "<CENTER>"
125 ReportLine "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2>"
126 ReportLine "<TR>"
127 ReportLine "<TH>Total Tests PASSED</TH>"
128 ReportLine "<TH>${TOTAL_PASS}</TH>"
129 ReportLine "</TR>"
130 ReportLine "<TR>"
131 ReportLine "<TH>Total Tests FAILED</TH>"
132 ReportLine "<TH>${TOTAL_FAIL}</TH>"
133 ReportLine "</TR>"
134 ReportLine "<TR>"
135 ReportLine "<TH>Total Tests Run</TH>"
136 ReportLine "<TH>${TOTAL_RUN}</TH>"
137 ReportLine "</TR>"
138 ReportLine "</TABLE>"
139 ReportLine "</CENTER>"
140 ReportLine "<P>"
141 ReportLine "<A HREF=${loglink}>Full logfile for test run</A>"
142 ReportLine "<P>"
143 ReportLine "<CENTER>"
144 ReportLine "</BODY>"
145 ReportLine "</HTML>"
148 ################################################################################
149 ReportLine() {
150 echo $1 >> $REPORT
153 ################################################################################
154 LogLine() {
155 echo $1 >> $LOGFILE
158 ################################################################################
159 ReportTestComments() {
160 if [[ $TEST_COMMENTS == "" ]] ; then
161 TEST_COMMENTS="&nbsp;"
164 ReportLine "<TD>${TEST_COMMENTS}</TD>"
167 ################################################################################
168 GetParams() {
169 integer argc=$#
170 integer i=0
172 if [[ $argc -lt 1 ]] ; then
173 Usage
176 while (($i < $argc)) ; do
177 arg=$1
178 shift
179 i=i+1
181 if [[ $arg == '-name' ]] ; then
182 if (( $i < $argc )) ; then
183 RUNNAME=$1
184 echo "RUNNAME=[$RUNNAME]"
185 shift
186 i=i+1
187 else
188 Usage
190 elif [[ $arg == '-env' ]] ; then
191 if (( $i < $argc )) ; then
192 ENVFILE=$1
193 shift
194 i=i+1
195 else
196 Usage
198 else
199 Usage
201 done
203 if [[ $ENVFILE == "" ]] ; then
204 Usage
209 ################################################################################
210 ReadEnvFile() {
211 . $ENVFILE
214 echo ""
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 ################################################################################
242 POSESetup() {
243 export PERL5LIB
244 export EM_SCRIPT_HOME
245 export QAWRAPPER_SCRIPT_HOME
246 export EM_ROM_FILE
247 export EM_SESSION_FILE
248 export QA_LIB_HOME
249 export QA_COMPARATOR_HOME
250 export CLASSES_DIR
254 ################################################################################
255 TestSetup() {
258 POSESetup
260 export ZENDEBUG=1
262 COMPLIST="${COMPLIST}/tempcomp.${RUNNAME}.list"
263 # create the directories for the results of this test run
264 RESDIR="${RESULTSBASE}/${RUNNAME}"
265 \rm -Rf $RESDIR
266 mkdir $RESDIR
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"
280 StartReportFile
282 echo "Results in: $RESDIR"
283 echo "Report file: $REPORT"
286 ################################################################################
287 TestCleanup() {
288 EndReportFile
291 ################################################################################
292 TestCaseSetup() {
293 # where to pick up converter classes
294 export CLASSPATH=""
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 ################################################################################
302 TestCaseCleanup() {
303 # empty function
304 a=42
307 ################################################################################
308 RunTestCase() {
309 testcase=$1
311 LogLine ""
312 LogLine "test_driver output:"
314 # run test_driver in foreground
315 $TEST_DRIVER_PL\
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
325 pkill pose
326 pkill -9 pose
330 ################################################################################
331 ComparisonSetup() {
332 typeset file=$1
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
344 \rm -f $COMPLIST
347 ################################################################################
348 RunComparison() {
349 typeset type=$1
351 LogLine ""
352 LogLine "Comparator output:"
353 $COMPARATOR_PL\
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`
363 LogLine ""
364 LogLine "COMPLIST file:"
365 cat $COMPLIST >> $LOGFILE
366 LogLine ""
367 LogLine "Comparator logfile:"
368 cat $COMPLOG >> $LOGFILE
370 if [ $pass -eq 0 ]
371 then
372 TEST_COMMENTS="${TEST_COMMENTS}$type comparison ERROR<BR>"
373 echo "$type comparison ERROR"
374 return 0
377 echo "$type comparison OK"
378 return 1
381 ################################################################################
382 CheckOutput() {
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"
390 return 0
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"
397 return 0
400 return 1
403 ################################################################################
404 RunTest() {
405 typeset testcasename
406 typeset testcase
407 typeset testfile
408 typeset pdbfile
409 typeset xmlfile
410 typeset ext
411 integer try
412 integer finished_with_test
413 integer test_pass
415 TestSetup
417 BGCOLOR=$ODD_BGCOLOR
419 while read line ; do
420 # get chars up to 1st space
421 testcasename=${line%% *}
422 testcase="${TESTCASEDIR}/$testcasename"
424 # get 2nd word
425 testfile=${line#* }
426 testfile=${testfile%% *}
428 # get last word
429 ext=${line##* }
431 LogLine "############################################"
432 LogLine "Starting the following testcase"
433 LogLine "testcase = $testcase"
434 LogLine "testfile = $testfile"
435 LogLine "ext = $ext"
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>"
442 echo ""
443 echo "testcase = $testcase"
444 echo "testfile = $testfile"
445 echo "ext = $ext"
447 try=1
448 finished_with_test=0
449 TEST_COMMENTS=""
451 while (($finished_with_test == 0)) ; do
453 TestCaseSetup
454 RunTestCase $testcase
455 TestCaseCleanup
457 xmlfile="${testfile}.${ext}"
459 if [[ $ext == "sxc" ]] ; then
460 pdbfile="${testfile}-Sheet1.pdb"
461 else
462 pdbfile="${testfile}.pdb"
465 CheckOutput $xmlfile $pdbfile
466 res=$?
468 if [[ $res -eq 1 ]] ; then
469 ComparisonSetup $pdbfile
470 RunComparison pdb
471 res=$?
472 # ignore result until pdb comparator is fixed...
473 res=1
474 ComparisonCleanup
477 if [[ $res -eq 1 ]] ; then
478 ComparisonSetup $xmlfile
479 RunComparison xml
480 res=$?
481 ComparisonCleanup
484 if [[ $res -eq 1 ]] ; then
485 TOTAL_PASS=TOTAL_PASS+1
486 ReportLine "<TD valign=top BGCOLOR='${PASS_COLOR}'>PASS</TD>"
487 ReportTestComments
488 ReportLine "</TR>"
489 LogLine "Test PASSED (on try $try)"
490 echo "Test PASSED (on try $try)"
491 finished_with_test=1
492 else
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>"
500 ReportTestComments
501 ReportLine "</TR>"
502 finished_with_test=1
506 try=try+1
507 done
509 TOTAL_RUN=TOTAL_RUN+1
511 # toggle BGCOLOR for next report line
512 if [[ $BGCOLOR == $ODD_BGCOLOR ]] ; then
513 BGCOLOR=$EVEN_BGCOLOR
514 else
515 BGCOLOR=$ODD_BGCOLOR
518 done < $MASTERLIST
520 ReportLine "</TABLE>"
521 ReportLine "</CENTER>"
523 TestCleanup
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 ################################################################################
534 # main
535 ################################################################################
536 ################################################################################
538 GetParams $@
539 ReadEnvFile
540 RunTest
542 exit 0