PageRenderTime 60ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/libreoffice-3.6.0.2/xmerge/source/palmtests/qa-wrapper/bin/run-convtest

#
Korn Shell | 538 lines | 380 code | 88 blank | 70 comment | 26 complexity | 1c57c9d15c3017018dfb65c2b41bcdb3 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception, LGPL-2.1, AGPL-1.0, BSD-3-Clause-No-Nuclear-License-2014, GPL-3.0, LGPL-3.0
  1. #!/bin/ksh
  2. #########################################################################
  3. #*************************************************************************
  4. #
  5. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  6. #
  7. # Copyright 2000, 2010 Oracle and/or its affiliates.
  8. #
  9. # OpenOffice.org - a multi-platform office productivity suite
  10. #
  11. # This file is part of OpenOffice.org.
  12. #
  13. # OpenOffice.org is free software: you can redistribute it and/or modify
  14. # it under the terms of the GNU Lesser General Public License version 3
  15. # only, as published by the Free Software Foundation.
  16. #
  17. # OpenOffice.org is distributed in the hope that it will be useful,
  18. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. # GNU Lesser General Public License version 3 for more details
  21. # (a copy is included in the LICENSE file that accompanied this code).
  22. #
  23. # You should have received a copy of the GNU Lesser General Public License
  24. # version 3 along with OpenOffice.org. If not, see
  25. # <http://www.openoffice.org/license.html>
  26. # for a copy of the LGPLv3 License.
  27. #
  28. #*************************************************************************
  29. #set -x
  30. umask 0
  31. integer TOTAL_PASS=0
  32. integer TOTAL_FAIL=0
  33. integer TOTAL_RUN=0
  34. integer MAX_RETRIES=5
  35. typeset RUNNAME=`date +%Y%m%d%H%M%S`
  36. typeset PRINTDATE=`date`
  37. typeset PDB_INFILE_DIR
  38. typeset PDB_OUTFILE_DIR
  39. typeset XML_OUTFILE_DIR
  40. typeset REPORT
  41. typeset RESDIR
  42. typeset LOGFILE
  43. typeset COMPLOG
  44. typeset TEST_COMMENTS
  45. typeset BGCOLOR
  46. typeset ODD_BGCOLOR='#BBBBBB'
  47. typeset EVEN_BGCOLOR='#DCDCDC'
  48. typeset PASS_COLOR='#00ff00'
  49. typeset FAIL_COLOR='#ff4040'
  50. typeset ENVFILE=""
  51. # The following variables should be set in the env file
  52. typeset MASTERLIST=""
  53. typeset TESTCASEDIR=""
  54. typeset RESULTSBASE=""
  55. typeset XMERGE_JAR=""
  56. typeset APORTIS_JAR=""
  57. typeset WORDSMITH_JAR=""
  58. typeset MINICALC_JAR=""
  59. typeset PERL5LIB=""
  60. typeset POSE_EXE=""
  61. typeset POSE_PRC=""
  62. typeset TEST_DRIVER_PL=""
  63. typeset COMPARATOR_PL=""
  64. typeset COMPLIST=""
  65. typeset XML_INFILE_DIR=""
  66. typeset PDB_BASELINE_DIR=""
  67. typeset XML_BASELINE_DIR=""
  68. typeset EM_SCRIPT_HOME=""
  69. typeset QAWRAPPER_SCRIPT_HOME=""
  70. typeset EM_ROM_FILE=""
  71. typeset EM_SESSION_FILE=""
  72. typeset QA_LIB_HOME=""
  73. typeset QA_COMPARATOR_HOME=""
  74. typeset CLASSES_DIR=""
  75. ################################################################################
  76. Usage() {
  77. echo "Usage: run-convtest -env <ENVFILE> [-name RUNNAME]"
  78. exit 1
  79. }
  80. ################################################################################
  81. StartReportFile() {
  82. typeset line=`date`
  83. ReportLine "<HTML>"
  84. ReportLine "<HEAD>"
  85. ReportLine "<TITLE>XMerge Converters Test Results - ${RUNNAME}</TITLE>"
  86. ReportLine "</HEAD>"
  87. ReportLine "<BODY BGCOLOR=#ffffff>"
  88. ReportLine "<H1 align=center>XMerge Converters Test Results - ${RUNNAME}</H1>"
  89. ReportLine "<P>"
  90. ReportLine "Test run on: ${PRINTDATE}"
  91. ReportLine "<P>"
  92. ReportLine "<CENTER>"
  93. ReportLine "<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=2>"
  94. ReportLine "<TR BGCOLOR='#9999CC'>"
  95. ReportLine "<TH>Test Name</TH>"
  96. ReportLine "<TH>Test File</TH>"
  97. ReportLine "<TH>.ext</TH>"
  98. ReportLine "<TH>Result</TH>"
  99. ReportLine "<TH>Comments</TH>"
  100. ReportLine "</TR>"
  101. }
  102. ################################################################################
  103. EndReportFile() {
  104. # remove full path from LOGFILE (link will be to current dir)
  105. typeset loglink=${LOGFILE##*/}
  106. ReportLine "<P>"
  107. ReportLine "<CENTER>"
  108. ReportLine "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2>"
  109. ReportLine "<TR>"
  110. ReportLine "<TH>Total Tests PASSED</TH>"
  111. ReportLine "<TH>${TOTAL_PASS}</TH>"
  112. ReportLine "</TR>"
  113. ReportLine "<TR>"
  114. ReportLine "<TH>Total Tests FAILED</TH>"
  115. ReportLine "<TH>${TOTAL_FAIL}</TH>"
  116. ReportLine "</TR>"
  117. ReportLine "<TR>"
  118. ReportLine "<TH>Total Tests Run</TH>"
  119. ReportLine "<TH>${TOTAL_RUN}</TH>"
  120. ReportLine "</TR>"
  121. ReportLine "</TABLE>"
  122. ReportLine "</CENTER>"
  123. ReportLine "<P>"
  124. ReportLine "<A HREF=${loglink}>Full logfile for test run</A>"
  125. ReportLine "<P>"
  126. ReportLine "<CENTER>"
  127. ReportLine "</BODY>"
  128. ReportLine "</HTML>"
  129. }
  130. ################################################################################
  131. ReportLine() {
  132. echo $1 >> $REPORT
  133. }
  134. ################################################################################
  135. LogLine() {
  136. echo $1 >> $LOGFILE
  137. }
  138. ################################################################################
  139. ReportTestComments() {
  140. if [[ $TEST_COMMENTS == "" ]] ; then
  141. TEST_COMMENTS="&nbsp;"
  142. fi
  143. ReportLine "<TD>${TEST_COMMENTS}</TD>"
  144. }
  145. ################################################################################
  146. GetParams() {
  147. integer argc=$#
  148. integer i=0
  149. if [[ $argc -lt 1 ]] ; then
  150. Usage
  151. fi
  152. while (($i < $argc)) ; do
  153. arg=$1
  154. shift
  155. i=i+1
  156. if [[ $arg == '-name' ]] ; then
  157. if (( $i < $argc )) ; then
  158. RUNNAME=$1
  159. echo "RUNNAME=[$RUNNAME]"
  160. shift
  161. i=i+1
  162. else
  163. Usage
  164. fi
  165. elif [[ $arg == '-env' ]] ; then
  166. if (( $i < $argc )) ; then
  167. ENVFILE=$1
  168. shift
  169. i=i+1
  170. else
  171. Usage
  172. fi
  173. else
  174. Usage
  175. fi
  176. done
  177. if [[ $ENVFILE == "" ]] ; then
  178. Usage
  179. fi
  180. }
  181. ################################################################################
  182. ReadEnvFile() {
  183. . $ENVFILE
  184. echo ""
  185. echo "The following values have been set from $ENVFILE:"
  186. echo "MASTERLIST=$MASTERLIST"
  187. echo "TESTCASEDIR=$TESTCASEDIR"
  188. echo "XMERGE_JAR=$XMERGE_JAR"
  189. echo "APORTIS_JAR=$APORTIS_JAR"
  190. echo "WORDSMITH_JAR=$WORDSMITH_JAR"
  191. echo "MINICALC_JAR=$MINICALC_JAR"
  192. echo "RESULTSBASE=$RESULTSBASE"
  193. echo "PERL5LIB=$PERL5LIB"
  194. echo "POSE_EXE=$POSE_EXE"
  195. echo "POSE_PRC=$POSE_PRC"
  196. echo "TEST_DRIVER_PL=$TEST_DRIVER_PL"
  197. echo "COMPARATOR_PL=$COMPARATOR_PL"
  198. echo "XML_INFILE_DIR=$XML_INFILE_DIR"
  199. echo "PDB_BASELINE_DIR=$PDB_BASELINE_DIR"
  200. echo "XML_BASELINE_DIR=$XML_BASELINE_DIR"
  201. echo "EM_SCRIPT_HOME=$EM_SCRIPT_HOME"
  202. echo "QAWRAPPER_SCRIPT_HOME=$QAWRAPPER_SCRIPT_HOME"
  203. echo "EM_ROM_FILE=$EM_ROM_FILE"
  204. echo "EM_SESSION_FILE=$EM_SESSION_FILE"
  205. echo "QA_LIB_HOME=$QA_LIB_HOME"
  206. echo "QA_COMPARATOR_HOME=$QA_COMPARATOR_HOME"
  207. echo "CLASSES_DIR=$CLASSES_DIR"
  208. echo "COMPLIST=$COMPLIST"
  209. }
  210. ################################################################################
  211. POSESetup() {
  212. export PERL5LIB
  213. export EM_SCRIPT_HOME
  214. export QAWRAPPER_SCRIPT_HOME
  215. export EM_ROM_FILE
  216. export EM_SESSION_FILE
  217. export QA_LIB_HOME
  218. export QA_COMPARATOR_HOME
  219. export CLASSES_DIR
  220. }
  221. ################################################################################
  222. TestSetup() {
  223. POSESetup
  224. export ZENDEBUG=1
  225. COMPLIST="${COMPLIST}/tempcomp.${RUNNAME}.list"
  226. # create the directories for the results of this test run
  227. RESDIR="${RESULTSBASE}/${RUNNAME}"
  228. \rm -Rf $RESDIR
  229. mkdir $RESDIR
  230. # Define the directories for the test input files,
  231. # test output files, working directories and baseline files
  232. PDB_INFILE_DIR="${RESDIR}/pdb-orig"
  233. mkdir "${PDB_INFILE_DIR}"
  234. PDB_OUTFILE_DIR="${RESDIR}/pdb-new"
  235. mkdir "${PDB_OUTFILE_DIR}"
  236. XML_OUTFILE_DIR="${RESDIR}/xml-new"
  237. mkdir "${XML_OUTFILE_DIR}"
  238. LOGFILE="${RESDIR}/logfile"
  239. COMPLOG="${RESDIR}/complog"
  240. REPORT="${RESDIR}/report.html"
  241. StartReportFile
  242. echo "Results in: $RESDIR"
  243. echo "Report file: $REPORT"
  244. }
  245. ################################################################################
  246. TestCleanup() {
  247. EndReportFile
  248. }
  249. ################################################################################
  250. TestCaseSetup() {
  251. # where to pick up converter classes
  252. export CLASSPATH=""
  253. export CLASSPATH=$CLASSPATH:$XMERGE_JAR
  254. export CLASSPATH=$CLASSPATH:$APORTIS_JAR
  255. export CLASSPATH=$CLASSPATH:$WORDSMITH_JAR
  256. export CLASSPATH=$CLASSPATH:$MINICALC_JAR
  257. }
  258. ################################################################################
  259. TestCaseCleanup() {
  260. # empty function
  261. a=42
  262. }
  263. ################################################################################
  264. RunTestCase() {
  265. testcase=$1
  266. LogLine ""
  267. LogLine "test_driver output:"
  268. # run test_driver in foreground
  269. $TEST_DRIVER_PL\
  270. -pose-prc=${POSE_PRC}\
  271. -pose-exe=${POSE_EXE}\
  272. -xml-orig=${XML_INFILE_DIR}\
  273. -pdb-orig=${PDB_INFILE_DIR}\
  274. -pdb-new=${PDB_OUTFILE_DIR}\
  275. -xml-new=${XML_OUTFILE_DIR}\
  276. -test=$testcase -merge >> $LOGFILE 2>&1
  277. # cleanup in case zombie POSE processes are hanging around
  278. pkill pose
  279. pkill -9 pose
  280. }
  281. ################################################################################
  282. ComparisonSetup() {
  283. typeset file=$1
  284. export CLASSPATH="$CLASSES_DIR/xerces.jar"
  285. # create temporary comparator list file for this test case
  286. echo $file > $COMPLIST
  287. }
  288. ################################################################################
  289. ComparisonCleanup() {
  290. # remove temporary comparator list file used for this test case
  291. \rm -f $COMPLIST
  292. }
  293. ################################################################################
  294. RunComparison() {
  295. typeset type=$1
  296. LogLine ""
  297. LogLine "Comparator output:"
  298. $COMPARATOR_PL\
  299. -xml-orig=${XML_BASELINE_DIR}\
  300. -pdb-orig=${PDB_BASELINE_DIR}\
  301. -pdb-new=${PDB_INFILE_DIR}\
  302. -xml-new=${XML_OUTFILE_DIR}\
  303. -list=$COMPLIST -log=$COMPLOG -type=$type >> $LOGFILE 2>&1
  304. # -list=$COMPLIST -log=$COMPLOG -type=$type | tee -a $LOGFILE 2>&1
  305. pass=`grep TRUE $COMPLOG | wc -l`
  306. LogLine ""
  307. LogLine "COMPLIST file:"
  308. cat $COMPLIST >> $LOGFILE
  309. LogLine ""
  310. LogLine "Comparator logfile:"
  311. cat $COMPLOG >> $LOGFILE
  312. if [ $pass -eq 0 ]
  313. then
  314. TEST_COMMENTS="${TEST_COMMENTS}$type comparison ERROR<BR>"
  315. echo "$type comparison ERROR"
  316. return 0
  317. fi
  318. echo "$type comparison OK"
  319. return 1
  320. }
  321. ################################################################################
  322. CheckOutput() {
  323. typeset xmlfile="${XML_OUTFILE_DIR}/$1"
  324. typeset pdbfile="${PDB_INFILE_DIR}/$2"
  325. if [ ! -f $pdbfile ] ; then
  326. TEST_COMMENTS="${TEST_COMMENTS}[$pdbfile] does not exist<BR>"
  327. LogLine "ERROR: $pdbfile does not exist"
  328. echo "ERROR: $pdbfile does not exist"
  329. return 0
  330. fi
  331. if [ ! -f $xmlfile ] ; then
  332. TEST_COMMENTS="${TEST_COMMENTS}[$xmlfile] does not exist<BR>"
  333. LogLine "ERROR: $xmlfile does not exist"
  334. echo "ERROR: $xmlfile does not exist"
  335. return 0
  336. fi
  337. return 1
  338. }
  339. ################################################################################
  340. RunTest() {
  341. typeset testcasename
  342. typeset testcase
  343. typeset testfile
  344. typeset pdbfile
  345. typeset xmlfile
  346. typeset ext
  347. integer try
  348. integer finished_with_test
  349. integer test_pass
  350. TestSetup
  351. BGCOLOR=$ODD_BGCOLOR
  352. while read line ; do
  353. # get chars up to 1st space
  354. testcasename=${line%% *}
  355. testcase="${TESTCASEDIR}/$testcasename"
  356. # get 2nd word
  357. testfile=${line#* }
  358. testfile=${testfile%% *}
  359. # get last word
  360. ext=${line##* }
  361. LogLine "############################################"
  362. LogLine "Starting the following testcase"
  363. LogLine "testcase = $testcase"
  364. LogLine "testfile = $testfile"
  365. LogLine "ext = $ext"
  366. ReportLine "<TR BGCOLOR='${BGCOLOR}'>"
  367. ReportLine "<TD valign=top>$testcasename</TD>"
  368. ReportLine "<TD valign=top>$testfile</TD>"
  369. ReportLine "<TD valign=top>$ext</TD>"
  370. echo ""
  371. echo "testcase = $testcase"
  372. echo "testfile = $testfile"
  373. echo "ext = $ext"
  374. try=1
  375. finished_with_test=0
  376. TEST_COMMENTS=""
  377. while (($finished_with_test == 0)) ; do
  378. TestCaseSetup
  379. RunTestCase $testcase
  380. TestCaseCleanup
  381. xmlfile="${testfile}.${ext}"
  382. if [[ $ext == "sxc" ]] ; then
  383. pdbfile="${testfile}-Sheet1.pdb"
  384. else
  385. pdbfile="${testfile}.pdb"
  386. fi
  387. CheckOutput $xmlfile $pdbfile
  388. res=$?
  389. if [[ $res -eq 1 ]] ; then
  390. ComparisonSetup $pdbfile
  391. RunComparison pdb
  392. res=$?
  393. # ignore result until pdb comparator is fixed...
  394. res=1
  395. ComparisonCleanup
  396. fi
  397. if [[ $res -eq 1 ]] ; then
  398. ComparisonSetup $xmlfile
  399. RunComparison xml
  400. res=$?
  401. ComparisonCleanup
  402. fi
  403. if [[ $res -eq 1 ]] ; then
  404. TOTAL_PASS=TOTAL_PASS+1
  405. ReportLine "<TD valign=top BGCOLOR='${PASS_COLOR}'>PASS</TD>"
  406. ReportTestComments
  407. ReportLine "</TR>"
  408. LogLine "Test PASSED (on try $try)"
  409. echo "Test PASSED (on try $try)"
  410. finished_with_test=1
  411. else
  412. TEST_COMMENTS="${TEST_COMMENTS}error on try ${try}<BR>"
  413. LogLine "TEST FAILED (on try $try)"
  414. echo "TEST FAILED (on try $try)"
  415. if [[ $try -eq $MAX_RETRIES ]] ; then
  416. TOTAL_FAIL=TOTAL_FAIL+1
  417. ReportLine "<TD valign=top BGCOLOR='${FAIL_COLOR}'>FAIL</TD>"
  418. ReportTestComments
  419. ReportLine "</TR>"
  420. finished_with_test=1
  421. fi
  422. fi
  423. try=try+1
  424. done
  425. TOTAL_RUN=TOTAL_RUN+1
  426. # toggle BGCOLOR for next report line
  427. if [[ $BGCOLOR == $ODD_BGCOLOR ]] ; then
  428. BGCOLOR=$EVEN_BGCOLOR
  429. else
  430. BGCOLOR=$ODD_BGCOLOR
  431. fi
  432. done < $MASTERLIST
  433. ReportLine "</TABLE>"
  434. ReportLine "</CENTER>"
  435. TestCleanup
  436. echo "Total Tests PASSED: "${TOTAL_PASS}
  437. echo "Total Tests FAILED: "${TOTAL_FAIL}
  438. echo "Total Tests RUN: "${TOTAL_RUN}
  439. echo "Results in: $RESDIR"
  440. echo "Report file: $REPORT"
  441. }
  442. ################################################################################
  443. ################################################################################
  444. # main
  445. ################################################################################
  446. ################################################################################
  447. GetParams $@
  448. ReadEnvFile
  449. RunTest
  450. exit 0