diff options
Diffstat (limited to 'xmerge/source/palmtests/qa-wrapper/bin')
-rwxr-xr-x | xmerge/source/palmtests/qa-wrapper/bin/qa_comparator.pl | 257 | ||||
-rwxr-xr-x | xmerge/source/palmtests/qa-wrapper/bin/qa_test_driver.pl | 846 | ||||
-rwxr-xr-x | xmerge/source/palmtests/qa-wrapper/bin/run-convtest | 538 |
3 files changed, 1641 insertions, 0 deletions
diff --git a/xmerge/source/palmtests/qa-wrapper/bin/qa_comparator.pl b/xmerge/source/palmtests/qa-wrapper/bin/qa_comparator.pl new file mode 100755 index 000000000000..6cc49da3570b --- /dev/null +++ b/xmerge/source/palmtests/qa-wrapper/bin/qa_comparator.pl @@ -0,0 +1,257 @@ +#!/usr/bin/perl +######################################################################### + + #************************************************************************* + # +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# + #************************************************************************* + +$compare_home = $ENV{'QA_COMPARATOR_HOME'}; + +if ($ENV{'CLASSPATH'}) +{ + $classpath_val = "$compare_home:$ENV{'CLASSPATH'}"; +} +else +{ + $classpath_val = "$compare_home"; +} + +print "classpath is $classpath_val\n"; + +$list_file=""; +$orig_dir=""; +$new_dir=""; +$diff_type=""; + +####### BEGIN MAIN ############## +$cmdline_len = @ARGV; +if ($cmdline_len <= 0) +{ + print_usage(); + exit (0); +} + +process_cmdline(@ARGV); +print_env(); +open (LOGFILE, ">$logfile") || die "Cannot open log file $logfile"; +if ($test_list ne "") +{ + open (TESTLIST, $test_list) || die "Couldn't open diff list file $test_list"; + + while (<TESTLIST>) + { + chomp $_; + process_diff(get_file_title($_)); + } +} +close TESTLIST; +close LOGFILE; + +####### END MAIN ############## + +sub process_diff +{ +# $_[0] =~ tr/A-Z/a-z/; + + # chdir to the output directory so the temporary files created by + # the java programs are put in the right place. + # + chdir ($xml_new); + + if ($diff_type eq "xml") + { + # Ugly hack, probably a way to tell xerces directly that the dtd's + # are in $compare_home/dtd. + # + `cp $compare_home/dtd/* $xml_new`; + +# $cmd = "java -classpath $classpath_val XmlWrapper $xml_orig/$_[0].sxw $xml_new/$_[0].sxw"; + $cmd = "java -classpath $classpath_val XmlWrapper $xml_orig/$_[0] $xml_new/$_[0]"; + print "Executing: $cmd\n"; + $val = system($cmd)/256; + if ($val == 2) + { +# print LOGFILE "$_[0]|TRUE|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n"; + print LOGFILE "$_[0]|TRUE|$xml_orig/$_[0]|$xml_new/$_[0]\n"; + } + elsif($val == 3) + { +# print LOGFILE "$_[0]|FALSE|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n"; + print LOGFILE "$_[0]|FALSE|$xml_orig/$_[0]|$xml_new/$_[0]\n"; + } + else + { +# print LOGFILE "$_[0]|ERROR|$xml_orig/$_[0].sxw|$xml_new/$_[0].sxw\n"; + print LOGFILE "$_[0]|ERROR|$xml_orig/$_[0]|$xml_new/$_[0]\n"; + } + } + elsif ($diff_type eq "pdb") + { +# $cmd = "java -classpath $classpath_val SimplePdbCompare $pdb_orig/$_[0].pdb $pdb_new/$_[0].pdb\n"; + $cmd = "java -classpath $classpath_val SimplePdbCompare $pdb_orig/$_[0] $pdb_new/$_[0]\n"; + print "Executing: $cmd\n"; + $val = system($cmd)/256; + if ($val == 2) + { +# print LOGFILE "$_[0]|TRUE|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n"; + print LOGFILE "$_[0]|TRUE|$pdb_orig/$_[0]|$pdb_new/$_[0]\n"; + } + elsif($val == 3) + { +# print LOGFILE "$_[0]|FALSE|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n"; + print LOGFILE "$_[0]|FALSE|$pdb_orig/$_[0]|$pdb_new/$_[0]\n"; + } + else + { +# print LOGFILE "$_[0]|ERROR|$pdb_orig/$_[0].pdb|$pdb_new/$_[0].pdb\n"; + print LOGFILE "$_[0]|ERROR|$pdb_orig/$_[0]|$pdb_new/$_[0]\n"; + } + } + else + { + die "Don't understand test type of $diff_type."; + } +} + +sub process_cmdline +{ + foreach $i (@_) + { + @arg= split('=', $i); + @arg[0] =~ tr/A-Z/a-z/; + + if (@arg[0] eq "-pdb-orig") + { + $pdb_orig=$arg[1]; + } + elsif (@arg[0] eq "-pdb-new") + { + $pdb_new=$arg[1]; + } + elsif (@arg[0] eq "-xml-orig") + { + $xml_orig=$arg[1]; + } + elsif (@arg[0] eq "-xml-new") + { + $xml_new=$arg[1]; + } + elsif (@arg[0] eq "-env") + { + set_env_from_props($arg[1]); + } + elsif (@arg[0] eq "-list") + { + $test_list = $arg[1]; + } + elsif (@arg[0] eq "-one") + { + $infile = $arg[1]; + } + elsif (@arg[0] eq "-type") + { + $diff_type = $arg[1]; + chomp $diff_type; + } + elsif (@arg[0] eq "-log") + { + $logfile = $arg[1]; + } + else + { + print_usage(); + die "Incorrect command line. Don't understand $i"; + } + } +} + +sub set_env_from_props +{ + open(PROPSFILE, $_[0]) || die "Could not open properties file"; + + while (<PROPSFILE>) + { + chomp $_; + @arg = split('=', $_); + @arg[0] =~ tr/a-z/A-Z/; + $len = @arg; + if ($len != 2) + { + die "Malformed property in $ARGV[0]"; + } + + if (@arg[0] eq "PDB_ORIG") + { + $pdb_orig=$arg[1]; + } + elsif (@arg[0] eq "PDB_NEW") + { + $pdb_new=$arg[1]; + } + elsif (@arg[0] eq "XML_ORIG") + { + $xml_orig=$arg[1]; + } + elsif (@arg[0] eq "XML_NEW") + { + $xml_new=$arg[1]; + } + + } + close PROPSFILE; +} + +sub print_usage +{ + print "Usage : compartor.pl - compare Office or pdb files\n"; + print "\t-one=<file> :\t\t individual test case file to run\n"; + print "\t-list=<file> :\t\t list of test case files\n"; + print "\t-env=<file> :\t\t Properites like file defining env\n"; + print "\t-pdb-orig=<path> :\t directory to hold original pdb files\n"; + print "\t-pdb-new=<path> :\t directory to hold new pdb files\n"; + print "\t-xml-orig=<path> :\t directory to hold original office documents\n"; + print "\t-xml-new=<path> :\t directory to hold new office documents\n"; + print "\t-type=<xml|pdb> :\t Invokes the merge option when converting\n"; + print "\t-log=<logfile> :\t Save results to logfile.\n"; +} + +sub print_env +{ + print "Using the following environment:\n"; + print "\tPDB_ORIG = $pdb_orig\n"; + print "\tPDB_NEW = $pdb_new\n"; + print "\tXML_ORIG = $xml_orig\n"; + print "\tXML_NEW = $xml_new\n\n"; +} + +sub get_file_title +{ + @paths = split('\/', $_[0]); + $len = @paths; + return @paths[$len-1]; +# @names = split('\.', @paths[$len-1]); +# return $names[0]; +} diff --git a/xmerge/source/palmtests/qa-wrapper/bin/qa_test_driver.pl b/xmerge/source/palmtests/qa-wrapper/bin/qa_test_driver.pl new file mode 100755 index 000000000000..fd57512fd171 --- /dev/null +++ b/xmerge/source/palmtests/qa-wrapper/bin/qa_test_driver.pl @@ -0,0 +1,846 @@ +#!/usr/bin/perl +######################################################################### + + #************************************************************************* + # +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# + #************************************************************************* + +#################################################################### +# File Name: test_driver.pl +# Version : 1.0 +# Project : Xmerge +# Author : Brian Cameron +# Date : 5th Sept. 2001 +# +# +# This script does the following: +# +# Processes the input file, and runs the tests specified in that +# file. This will do the following for each test: +# +# 1. Convert a file from XML to PDB format +# 2. Starts up the Palm OS emulator with the appropriate program +# running and the converted file loaded the program. +# 3. Makes automated changes as specified in the inputfile to +# this script.. +# 4. Returns to the main applications window. +# +# Parameter +# Filename to convert and change +# +########################################################################## + +# Turn on auto-flushing +# +$|=1; + +use EmRPC; + +# Directory where converterlib is located... +# +#use lib "/export/home/test/qadir/qa/lib"; +use lib $ENV{'QA_LIB_HOME'}; +use converterlib; + +#-------------------- Start of main script ------------------------------------ + +# Environmental Settings + +$pose_exe = ""; +$pose_prc = ""; +$test_list = ""; +$infile = ""; +$merge_opt = 0; +# if testcase hasn't completed in 10 mins, then kill it off +$testcase_timeout=600; + +# You may need to change this from the default if your pose emulator +# starts faster or slower than mine. +# +if ($ENV{'POSE_TIMEOUT'}) +{ + $pose_timeout = "$ENV{'POSE_TIMEOUT'}"; +} +else +{ + $pose_timeout = 15; +} + +$cmdline_len = @ARGV; +if ($cmdline_len <= 0) +{ + print_usage(); + exit (0); +} + +&process_cmdline(@ARGV); +&print_env(); +&verify_env_options(); + +# Make the output directories with timestamps included in the +# directory names. +# +mkdir $pdb_orig, 0777 || die "can not create directory <$pdb_orig>."; +`chmod 777 $pdb_orig`; +mkdir $pdb_new, 0777 || die "can not create directory <$pdb_new>."; +`chmod 777 $pdb_new`; +mkdir $xml_new, 0777 || die "can not create directory <$xml_new>."; +`chmod 777 $xml_new`; + +&verify_prcs_exist("DBExporter.prc"); + +if ($test_list ne "") +{ + open (TESTLIST, $test_list) || die "Couldn't open testcase list file $test_list"; + + while (<TESTLIST>) + { + &process_testcase($_); + } +} +elsif ($infile ne "") +{ + if (!defined($child_pid = fork())) + { + # there was an error forking a process + print "ERROR: Unable to fork process\n"; + die "ERROR: Unable to fork process\n"; + } + elsif ($child_pid) + { + # this is the parent process + # run the actual test here +print "********\tPARENT (pid = $$): process_testcase...\n"; + &process_testcase($infile); +print "********\tPARENT (pid = $$): ...process_testcase finished normally\n"; + + # test finished normally, so kill the monitor + # that is running in the child process +print "********\tPARENT (pid = $$): kill child process ($child_pid)\n"; +print "********\tPARENT Before:\n"; +system( "/usr/bin/ptree" ); + kill( $child_pid ); + kill( 9, $child_pid ); +print "********\tPARENT After:\n"; +system( "/usr/bin/ptree" ); + } + else + { +print "********\tCHILD (pid = $$): sleep for $testcase_timeout seconds\n"; + # this is the child process + # wait on the test running in the parent, and + # kill it if it hasn't finished on time + sleep( $testcase_timeout ); + + # if the parent hasn't killed this process before it + # gets here, then it's probably hung, so we need to + # kill it. + print "********\tCHILD (pid = $$): TEST HUNG? still " + ."running after [$testcase_timeout] seconds - " + ."need to kill test process\n"; + $parent = getppid; + + if ( $parent != 1 ) { + print "********\nCHILD (pid = $$): Killing process ($parent)\n"; + kill( $parent ); + kill( 9, $parent ); + } else { + # If we cannot get the ppid, then the parent might + # have died abnormally, before it got a chance to + # kill this (child) process. + print "********\nCHILD (pid = $$): cannot determine ppid - " + ."terminating\n"; +system( "/usr/bin/ptree" ); + exit(2); + } + + exit(1); + } +} +else +{ + die ("You didn't supply any test cases to process"); +} + +print "Finished.\n"; +exit(0); + +#-------------------- End of main script ---------------------------------------- + +#-------------------------------------------------------------------------------- +# Various sub routines +#-------------------------------------------------------------------------------- + +# process_testcase +# infile - test case file name +# +# This is the main driver function +# Opens the infile, reads it in parses it, runs the appropriate conversion +# starts pose and load the file into the emulator. It launches the +# appropriate editor and then runs the commands specified in the test case. +# It then exports the file and saves it locally. Finally it is converted +# back to the original office format. +# +sub process_testcase +{ + my $infile = $_[0]; + my $convert_file = ""; + my $rc; + + # Process the inputfile + # + open (INFILE, $infile) || die "Failed to open test case <$infile>"; + + $running_testtype = ""; + + # Process the input file. + # + while ($c_inline = <INFILE>) + { + chomp $c_inline; + @entry = split('\|', $c_inline); + + # Process TEST + # + if ($c_inline =~ /^ *#/ || $c_inline =~ /^[ \t]*$/) + { + # skip comments and blank lines. + # + next; + } + elsif ("$entry[0]" eq "TEST") + { + # Close the test if one is running. + # + &close_program($convert_file); + $running_testtype = ""; + + $valid_test = 0; + + if ($#entry != 3) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + else + { + # Start the test. + # + print "\nStarting test: $entry[1]\n"; + $convert_file = $entry[3]; + + if ("$entry[2]" =~ /[Qq][Uu][Ii][Cc][Kk][Ww][Oo][Rr][Dd]/) + { + $xml_extension = "sxw"; + $convert_to = "application/x-aportisdoc"; + + # Convert XML file to pdb format. + # + $rc = &convert_to_pdb("$xml_orig", $convert_file, $xml_extension , + $convert_to,"$pdb_orig"); + if ($rc != 0) + { + print "\nERROR, problem converting file $convert_file\n\n"; + } + else + { + # Start pose + # + $rc = &start_pose("$pose_exe", + "$pose_prc/Quickword.PRC,$pose_prc/DBExporter.prc,$pdb_orig/$convert_file.pdb", + "Quickword", $pose_timeout); + + if ($rc == 0) + { + &start_quickword(); + $valid_test = 1; + $running_testtype = "QUICKWORD"; + print "\npose launched, begin automated test sequence for QuickWord\n"; + } + else + { + &kill_pose(); + $running_testtype = ""; + } + } + } + elsif ("$entry[2]" =~ /[Mm][Ii][Nn][Ii][Cc][Aa][Ll][Cc]/) + { + $xml_extension = "sxc"; + $convert_to = "application/x-minicalc"; + + # Convert XML file to pdb format. + # + $rc = &convert_to_pdb("$xml_orig", $convert_file, + $xml_extension, $convert_to,"$pdb_orig"); + if ($rc != 0) + { + print "\nERROR, problem converting file $convert_file\n\n"; + } + else + { + # Get minicalc PDB file names, since an SXC file can + # be converted to more than one. + # + $pdb_files=""; + $i = 1; + while (-f "$pdb_orig/$convert_file-Sheet$i.pdb") + { + if ($i > 1) + { + $pdb_files .= ","; + } + $pdb_files .= "$pdb_orig/$convert_file-Sheet$i.pdb"; + $i++; + } + $number = $i-1; + + # Start pose + # + $rc = &start_pose("$pose_exe", + "$pose_prc/MiniCalc.prc,$pose_prc/DBExporter.prc,$pdb_files", + "MiniCalc", $pose_timeout); + + if ($rc == 0) + { + &start_minicalc(); + $valid_test = 1; + $running_testtype = "MINICALC"; + print "pose launched, begin automated test sequence for MiniCalc\n"; + } + else + { + &kill_pose(); + $running_testtype = ""; + } + } + } + else + { + print "\nERROR, invalid extension <$entry[2]>\n\n"; + } + } + } + + # Process DB_EXPORT + # + elsif ("$entry[0]" eq "DB_EXPORT") + { + if ($#entry != 1) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + else + { + &db_export($entry[1]); + } + } + + # Process TAP_APPLICATIONS + # + elsif ("$entry[0]" eq "TAP_APPLICATIONS") + { + if ($#entry != 0) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + else + { + &tap_applications(0); + } + } + + # Process ENTER_STRING_AT_LOCATION + # + elsif ("$entry[0]" eq "ENTER_STRING_AT_LOCATION") + { + if ($#entry != 3) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + elsif ($valid_test == 0) + { + print "\nERROR, can not process $entry[0] for invalid test\n\n"; + } + else + { + &enter_string_at_location($entry[1], $entry[2], + $entry[3], $running_testtype); + } + } + + # Process TAP_PEN + # + elsif ("$entry[0]" eq "TAP_PEN") + { + if ($#entry != 2) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + elsif ($valid_test == 0) + { + print "\nERROR, can not process $entry[0] for invalid test\n\n"; + } + else + { + &pose_tap_pen($entry[1], $entry[2], 0); + } + } + + # Process TAP_BUTTON + # + elsif ("$entry[0]" eq "TAP_BUTTON") + { + if ($#entry != 1) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + elsif ($valid_test == 0) + { + print "\nERROR, can not process $entry[0] for invalid test\n\n"; + } + else + { + &pose_tap_button($entry[1], 0); + } + } + + # Process TAP_PEN_HARD + # + elsif ("$entry[0]" eq "TAP_PEN_HARD") + { + if ($#entry != 2) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + elsif ($valid_test == 0) + { + print "\nERROR, can not process $entry[0] for invalid test\n\n"; + } + else + { + &pose_tap_pen_hard($entry[1],$entry[2], 0); + } + } + + + # Process SLEEP + # + elsif ("$entry[0]" eq "SLEEP") + { + if ($#entry != 1) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + else + { + &pose_sleep($entry[1]); + } + } + + # Process MINICALC_ENTER_CELL + # + elsif ("$entry[0]" eq "MINICALC_ENTER_CELL") + { + if ($#entry != 3) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + elsif ($valid_test == 0) + { + print "\nERROR, can not process $entry[0] for invalid test\n\n"; + } + else + { + &minicalc_enter_cell($entry[1], $entry[2], $entry[3]); + } + } + + # Process QUICKWORD_FIND_REPLACE + # + elsif ("$entry[0]" eq "QUICKWORD_FIND_REPLACE") + { + if ($#entry != 2) + { + print "\nERROR, $entry[0] invalid number of arguments\n\n"; + } + elsif ($valid_test == 0) + { + print "\nERROR, can not process $entry[0] for invalid test\n\n"; + } + else + { + &quickword_find_replace($entry[1], $entry[2]); + } + } + else + { + print "\nERROR, invalid line <$c_inline>\n"; + } + } + + &close_program($convert_file); +} + +# close_program +# convert_file - file to export +# +# closes the program running in pose and kills pose +# +sub close_program +{ + my $convert_file = $_[0]; + + if ($running_testtype eq "QUICKWORD") + { + print "QuickWord test completed.\n"; + &close_program_quickword($convert_file); + } + elsif ($running_testtype eq "MINICALC") + { + print "MiniCalc test completed.\n"; + &close_program_minicalc($convert_file, $number); + } +} + +# close_program_quickword +# convert_file - file to export +# +# Closes quickword and kills pose +# +sub close_program_quickword +{ + my $convert_file = $_[0]; + my $error_file = "./error.txt"; + my $rc; + + &close_quickword(); + + &db_export($convert_file); + print "Moving /tmp/$convert_file.pdb to $pdb_new\n"; + `mv /tmp/$convert_file.pdb $pdb_new`; + `chmod 666 $pdb_new/$convert_file.pdb`; + + &close_connection(1); + &kill_pose(); + print "\nFinishing test...\n"; + + # The path of where to put the error file should be specified + # in the properties file. Not sure if it is really necessary + # to put this out to a separate file. STDOUT should be fine. + # + $rc = &convert_to_xml($xml_new, $xml_orig, + "$pdb_new/$convert_file.pdb", "application/x-aportisdoc" , + "sxw", $convert_file, $merge_opt); + if ($rc != 0) + { + print "\nERROR, problem converting file $pdb_new/$convert_file.pdb\n\n"; + } +} + +# close_program_minicalc +# convert_file - file to export +# +# Closes minicalc and kills pose +# +sub close_program_minicalc +{ + my $convert_file = $_[0]; + my $num_files = $_[1]; + my $list=""; + my $rc; + + &close_minicalc(); + + for ($a=1; $a <= $num_files; $a++) + { + &db_export("$convert_file-Sheet$a"); + print "Moving /tmp/$convert_file-Sheet$a.pdb to $pdb_new/\n"; + `mv /tmp/$convert_file-Sheet$a.pdb $pdb_new/`; + `chmod 666 $pdb_new/$convert_file-Sheet$a.pdb`; + } + + &close_connection(1); + &kill_pose(); + print "\nFinishing test...\n"; + + for ($a=1; $a <= $num_files; $a++) + { + $list .="$pdb_new/$convert_file-Sheet$a.pdb " + } + + $rc = &convert_to_xml($xml_new, $xml_orig, "$list", + "application/x-minicalc", "sxc", $convert_file, $merge_opt); + if ($rc != 0) + { + print "\nERROR, problem converting file(s) $list\n\n"; + } + + &pose_sleep(5); +} + +# print_usage +# +# prints the usage for this program. +# +sub print_usage +{ + print "Usage : test_driver.pl\n"; + print "\t-test=<file> \t\t: individual test case file to run\n"; + print "\t-list=<file> \t\t: list of test case files\n"; + print "\t-env=<file> \t\t: Properites like file defining env\n"; + print "\t-pose-exe=<fullpath> \t: path to pose executable\n"; + print "\t-pose-prc=<path> \t: path to directory holding prc files\n"; + print "\t-pdb-orig=<path> \t: directory to hold original pdb files\n"; + print "\t-pdb-new=<path> \t: directory to hold new pdb files\n"; + print "\t-xml-orig=<path> \t: directory to hold original office documents\n"; + print "\t-xml-new=<path> \t: directory to hold new office documents\n"; + print "\t-merge \t: Invokes the merge option when converting\n"; + print "\t \t from PDB back to XML.\n"; +} + +# print_env +# +# Prints the current environment. +# +sub print_env +{ + print "\nUsing the following environment:\n"; + print "\tPOSE_EXE = $pose_exe\n"; + print "\tPOSE_PRC = $pose_prc\n"; + print "\tPDB_ORIG = $pdb_orig\n"; + print "\tPDB_NEW = $pdb_new\n"; + print "\tXML_ORIG = $xml_orig\n"; + print "\tXML_NEW = $xml_new\n"; +} + +# process_cmdline +# +# command line options come in as key/value pairs. +# read them and set the appropriate global variable +# +# Sets these globals: pose_exe, pose_prc, xml_orig, xml_new_dir, +# xml_new, pdb_orig_dir, pdb_orig, pdb_new_dir, pdb_new. +# +sub process_cmdline +{ + foreach $i (@_) + { + my @arg= split('=', $i); + @arg[0] =~ tr/A-Z/a-z/; + + if (@arg[0] eq "-pose-exe") + { + $pose_exe=$arg[1]; + } + elsif (@arg[0] eq "-pose-prc") + { + $pose_prc=$arg[1]; + } + elsif (@arg[0] eq "-pdb-orig") + { + $pdb_orig_dir=$arg[1]; + $pdb_orig=$arg[1]; + } + elsif (@arg[0] eq "-pdb-new") + { + $pdb_new_dir=$arg[1]; + $pdb_new=$arg[1]; + } + elsif (@arg[0] eq "-xml-orig") + { + $xml_orig=$arg[1]; + } + elsif (@arg[0] eq "-xml-new") + { + $xml_new_dir=$arg[1]; + $xml_new=$arg[1]; + } + elsif (@arg[0] eq "-env") + { + &set_env_from_props($arg[1]); + } + elsif (@arg[0] eq "-list") + { + $test_list = $arg[1]; + } + elsif (@arg[0] eq "-test") + { + $infile = $arg[1]; + } + elsif (@arg[0] eq "-merge") + { + $merge_opt = 1; + } + else + { + print_usage(); + die "Incorrect command line"; + } + } +} + +# set_env_from_props +# infile - property file +# +# Read the properties file, of the form key=value +# Valid key values are : +# POSE_EXE +# POSE_PRC +# PDB_ORIG +# PDB_NEW +# XML_ORIG +# XML_NEW +# If a value is found the appropriate global variable is set. +# +# Sets these globals: pose_exe, pose_prc, xml_orig, xml_new_dir, +# xml_new, pdb_orig_dir, pdb_orig, pdb_new_dir, pdb_new. +# +sub set_env_from_props +{ + my $infile = $_[0]; + + open(PROPSFILE, $infile) || die "Could not open properties file <$infile>"; + + while (<PROPSFILE>) + { + chomp $_; + my @arg = split('=', $_); + @arg[0] =~ tr/a-z/A-Z/; + my $len = @arg; + if ($len != 2) + { + die "Malformed property in $arg[0]"; + } + if (@arg[0] eq "POSE_EXE") + { + $pose_exe=$arg[1]; + } + elsif (@arg[0] eq "POSE_PRC") + { + $pose_prc=$arg[1]; + } + elsif (@arg[0] eq "PDB_ORIG") + { + $pdb_orig_dir=$arg[1]; + $pdb_orig=$arg[1]; + } + elsif (@arg[0] eq "PDB_NEW") + { + $pdb_new_dir=$arg[1]; + $pdb_new=$arg[1]; + } + elsif (@arg[0] eq "XML_ORIG") + { + $xml_orig=$arg[1]; + } + elsif (@arg[0] eq "XML_NEW") + { + $xml_new_dir=$arg[1]; + $xml_new=$arg[1]; + } + + } + close PROPSFILE; +} + +# verify_env_options +# +# Verify that input options are correctly set. +# Assumes pose_exe, pose_prc, xml_orig, xml_new_dir, +# pdb_orig_dir, and pdb_new_dir are already set. +# +sub verify_env_options +{ + if (!-e "$pose_exe") + { + die "The pose executable cannot be found at $pose_exe."; + } + if (!-x $pose_exe) + { + die "$pose_exe exists but is not executable."; + } + + if (!-e "$pose_prc") + { + die "The PRC directory specified as $pose_prc does not exist."; + } + if (!-d "$pose_prc") + { + die "The PRC location specified as $pose_prc exists, but is not a directory."; + } + + if (!-e "$pdb_orig_dir") + { + die "The original PDB directory specified as $pdb_orig_dir does not exist."; + } + if (!-d "$pdb_orig_dir") + { + die "The original PDB directory specified as $pdb_orig_dir exists but is not a directory."; + } + + if (!-e "$pdb_new_dir") + { + die "The new PDB directory specified as $pdb_new_dir does not exist."; + } + if (!-d "$pdb_new_dir") + { + die "The new PDB directory specified as $pdb_new_dir exists but is not a directory."; + } + + if (!-e "$xml_orig") + { + die "The original Office document directory specified as $xml_orig does not exist."; + } + if (!-d "$xml_orig") + { + die "The original Office document location specified as $xml_orig exists but is not a directory."; + } + + if (!-e "$xml_new_dir") + { + die "The new Office document directory specified as $xml_new_dir does not exist."; + } + if (!-d "$xml_new_dir") + { + die "The new Office document location specified as $xml_new_dir exists but is not a directory."; + } +} + +# verify_prcs_exist +# prcfile - the PRC file to check +# +# Verifies that the specified PRC file exists. +# +sub verify_prcs_exist +{ + my $prcfile = $_[0]; + + if (!-e "$pose_prc/$prcfile") + { + die "The pose PRC directory ($pose_prc) is correct, but I can't find $prcfile there."; + } +} + diff --git a/xmerge/source/palmtests/qa-wrapper/bin/run-convtest b/xmerge/source/palmtests/qa-wrapper/bin/run-convtest new file mode 100755 index 000000000000..56c12509e215 --- /dev/null +++ b/xmerge/source/palmtests/qa-wrapper/bin/run-convtest @@ -0,0 +1,538 @@ +#!/bin/ksh +######################################################################### + + #************************************************************************* + # +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# + #************************************************************************* + +#set -x +umask 0 + +integer TOTAL_PASS=0 +integer TOTAL_FAIL=0 +integer TOTAL_RUN=0 +integer MAX_RETRIES=5 +typeset RUNNAME=`date +%Y%m%d%H%M%S` +typeset PRINTDATE=`date` +typeset PDB_INFILE_DIR +typeset PDB_OUTFILE_DIR +typeset XML_OUTFILE_DIR +typeset REPORT +typeset RESDIR +typeset LOGFILE +typeset COMPLOG +typeset TEST_COMMENTS +typeset BGCOLOR +typeset ODD_BGCOLOR='#BBBBBB' +typeset EVEN_BGCOLOR='#DCDCDC' +typeset PASS_COLOR='#00ff00' +typeset FAIL_COLOR='#ff4040' + +typeset ENVFILE="" +# The following variables should be set in the env file +typeset MASTERLIST="" +typeset TESTCASEDIR="" +typeset RESULTSBASE="" +typeset XMERGE_JAR="" +typeset APORTIS_JAR="" +typeset WORDSMITH_JAR="" +typeset MINICALC_JAR="" +typeset PERL5LIB="" +typeset POSE_EXE="" +typeset POSE_PRC="" +typeset TEST_DRIVER_PL="" +typeset COMPARATOR_PL="" +typeset COMPLIST="" +typeset XML_INFILE_DIR="" +typeset PDB_BASELINE_DIR="" +typeset XML_BASELINE_DIR="" +typeset EM_SCRIPT_HOME="" +typeset QAWRAPPER_SCRIPT_HOME="" +typeset EM_ROM_FILE="" +typeset EM_SESSION_FILE="" +typeset QA_LIB_HOME="" +typeset QA_COMPARATOR_HOME="" +typeset CLASSES_DIR="" + + + +################################################################################ +Usage() { + echo "Usage: run-convtest -env <ENVFILE> [-name RUNNAME]" + exit 1 +} + + +################################################################################ +StartReportFile() { + typeset line=`date` + + ReportLine "<HTML>" + ReportLine "<HEAD>" + ReportLine "<TITLE>XMerge Converters Test Results - ${RUNNAME}</TITLE>" + ReportLine "</HEAD>" + ReportLine "<BODY BGCOLOR=#ffffff>" + ReportLine "<H1 align=center>XMerge Converters Test Results - ${RUNNAME}</H1>" + ReportLine "<P>" + ReportLine "Test run on: ${PRINTDATE}" + ReportLine "<P>" + ReportLine "<CENTER>" + ReportLine "<TABLE WIDTH='100%' BORDER=1 CELLSPACING=0 CELLPADDING=2>" + ReportLine "<TR BGCOLOR='#9999CC'>" + ReportLine "<TH>Test Name</TH>" + ReportLine "<TH>Test File</TH>" + ReportLine "<TH>.ext</TH>" + ReportLine "<TH>Result</TH>" + ReportLine "<TH>Comments</TH>" + ReportLine "</TR>" +} + + +################################################################################ +EndReportFile() { + # remove full path from LOGFILE (link will be to current dir) + typeset loglink=${LOGFILE##*/} + + ReportLine "<P>" + ReportLine "<CENTER>" + ReportLine "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2>" + ReportLine "<TR>" + ReportLine "<TH>Total Tests PASSED</TH>" + ReportLine "<TH>${TOTAL_PASS}</TH>" + ReportLine "</TR>" + ReportLine "<TR>" + ReportLine "<TH>Total Tests FAILED</TH>" + ReportLine "<TH>${TOTAL_FAIL}</TH>" + ReportLine "</TR>" + ReportLine "<TR>" + ReportLine "<TH>Total Tests Run</TH>" + ReportLine "<TH>${TOTAL_RUN}</TH>" + ReportLine "</TR>" + ReportLine "</TABLE>" + ReportLine "</CENTER>" + ReportLine "<P>" + ReportLine "<A HREF=${loglink}>Full logfile for test run</A>" + ReportLine "<P>" + ReportLine "<CENTER>" + ReportLine "</BODY>" + ReportLine "</HTML>" +} + +################################################################################ +ReportLine() { + echo $1 >> $REPORT +} + +################################################################################ +LogLine() { + echo $1 >> $LOGFILE +} + +################################################################################ +ReportTestComments() { + if [[ $TEST_COMMENTS == "" ]] ; then + TEST_COMMENTS=" " + fi + + ReportLine "<TD>${TEST_COMMENTS}</TD>" +} + +################################################################################ +GetParams() { + integer argc=$# + integer i=0 + + if [[ $argc -lt 1 ]] ; then + Usage + fi + + while (($i < $argc)) ; do + arg=$1 + shift + i=i+1 + + if [[ $arg == '-name' ]] ; then + if (( $i < $argc )) ; then + RUNNAME=$1 + echo "RUNNAME=[$RUNNAME]" + shift + i=i+1 + else + Usage + fi + elif [[ $arg == '-env' ]] ; then + if (( $i < $argc )) ; then + ENVFILE=$1 + shift + i=i+1 + else + Usage + fi + else + Usage + fi + done + + if [[ $ENVFILE == "" ]] ; then + Usage + fi +} + + +################################################################################ +ReadEnvFile() { + . $ENVFILE + + + echo "" + echo "The following values have been set from $ENVFILE:" + echo "MASTERLIST=$MASTERLIST" + echo "TESTCASEDIR=$TESTCASEDIR" + echo "XMERGE_JAR=$XMERGE_JAR" + echo "APORTIS_JAR=$APORTIS_JAR" + echo "WORDSMITH_JAR=$WORDSMITH_JAR" + echo "MINICALC_JAR=$MINICALC_JAR" + echo "RESULTSBASE=$RESULTSBASE" + echo "PERL5LIB=$PERL5LIB" + echo "POSE_EXE=$POSE_EXE" + echo "POSE_PRC=$POSE_PRC" + echo "TEST_DRIVER_PL=$TEST_DRIVER_PL" + echo "COMPARATOR_PL=$COMPARATOR_PL" + echo "XML_INFILE_DIR=$XML_INFILE_DIR" + echo "PDB_BASELINE_DIR=$PDB_BASELINE_DIR" + echo "XML_BASELINE_DIR=$XML_BASELINE_DIR" + echo "EM_SCRIPT_HOME=$EM_SCRIPT_HOME" + echo "QAWRAPPER_SCRIPT_HOME=$QAWRAPPER_SCRIPT_HOME" + echo "EM_ROM_FILE=$EM_ROM_FILE" + echo "EM_SESSION_FILE=$EM_SESSION_FILE" + echo "QA_LIB_HOME=$QA_LIB_HOME" + echo "QA_COMPARATOR_HOME=$QA_COMPARATOR_HOME" + echo "CLASSES_DIR=$CLASSES_DIR" + echo "COMPLIST=$COMPLIST" +} + +################################################################################ +POSESetup() { + export PERL5LIB + export EM_SCRIPT_HOME + export QAWRAPPER_SCRIPT_HOME + export EM_ROM_FILE + export EM_SESSION_FILE + export QA_LIB_HOME + export QA_COMPARATOR_HOME + export CLASSES_DIR + +} + +################################################################################ +TestSetup() { + + + POSESetup + + export ZENDEBUG=1 + + COMPLIST="${COMPLIST}/tempcomp.${RUNNAME}.list" + # create the directories for the results of this test run + RESDIR="${RESULTSBASE}/${RUNNAME}" + \rm -Rf $RESDIR + mkdir $RESDIR + + # Define the directories for the test input files, + # test output files, working directories and baseline files + PDB_INFILE_DIR="${RESDIR}/pdb-orig" + mkdir "${PDB_INFILE_DIR}" + PDB_OUTFILE_DIR="${RESDIR}/pdb-new" + mkdir "${PDB_OUTFILE_DIR}" + XML_OUTFILE_DIR="${RESDIR}/xml-new" + mkdir "${XML_OUTFILE_DIR}" + + LOGFILE="${RESDIR}/logfile" + COMPLOG="${RESDIR}/complog" + REPORT="${RESDIR}/report.html" + StartReportFile + + echo "Results in: $RESDIR" + echo "Report file: $REPORT" +} + +################################################################################ +TestCleanup() { + EndReportFile +} + +################################################################################ +TestCaseSetup() { + # where to pick up converter classes + export CLASSPATH="" + export CLASSPATH=$CLASSPATH:$XMERGE_JAR + export CLASSPATH=$CLASSPATH:$APORTIS_JAR + export CLASSPATH=$CLASSPATH:$WORDSMITH_JAR + export CLASSPATH=$CLASSPATH:$MINICALC_JAR +} + +################################################################################ +TestCaseCleanup() { + # empty function + a=42 +} + +################################################################################ +RunTestCase() { + testcase=$1 + + LogLine "" + LogLine "test_driver output:" + + # run test_driver in foreground + $TEST_DRIVER_PL\ + -pose-prc=${POSE_PRC}\ + -pose-exe=${POSE_EXE}\ + -xml-orig=${XML_INFILE_DIR}\ + -pdb-orig=${PDB_INFILE_DIR}\ + -pdb-new=${PDB_OUTFILE_DIR}\ + -xml-new=${XML_OUTFILE_DIR}\ + -test=$testcase -merge >> $LOGFILE 2>&1 + + # cleanup in case zombie POSE processes are hanging around + pkill pose + pkill -9 pose +} + + +################################################################################ +ComparisonSetup() { + typeset file=$1 + + + export CLASSPATH="$CLASSES_DIR/xerces.jar" + + # create temporary comparator list file for this test case + echo $file > $COMPLIST +} + +################################################################################ +ComparisonCleanup() { + # remove temporary comparator list file used for this test case + \rm -f $COMPLIST +} + +################################################################################ +RunComparison() { + typeset type=$1 + + LogLine "" + LogLine "Comparator output:" + $COMPARATOR_PL\ + -xml-orig=${XML_BASELINE_DIR}\ + -pdb-orig=${PDB_BASELINE_DIR}\ + -pdb-new=${PDB_INFILE_DIR}\ + -xml-new=${XML_OUTFILE_DIR}\ + -list=$COMPLIST -log=$COMPLOG -type=$type >> $LOGFILE 2>&1 +# -list=$COMPLIST -log=$COMPLOG -type=$type | tee -a $LOGFILE 2>&1 + + pass=`grep TRUE $COMPLOG | wc -l` + + LogLine "" + LogLine "COMPLIST file:" + cat $COMPLIST >> $LOGFILE + LogLine "" + LogLine "Comparator logfile:" + cat $COMPLOG >> $LOGFILE + + if [ $pass -eq 0 ] + then + TEST_COMMENTS="${TEST_COMMENTS}$type comparison ERROR<BR>" + echo "$type comparison ERROR" + return 0 + fi + + echo "$type comparison OK" + return 1 +} + +################################################################################ +CheckOutput() { + typeset xmlfile="${XML_OUTFILE_DIR}/$1" + typeset pdbfile="${PDB_INFILE_DIR}/$2" + + if [ ! -f $pdbfile ] ; then + TEST_COMMENTS="${TEST_COMMENTS}[$pdbfile] does not exist<BR>" + LogLine "ERROR: $pdbfile does not exist" + echo "ERROR: $pdbfile does not exist" + return 0 + fi + + if [ ! -f $xmlfile ] ; then + TEST_COMMENTS="${TEST_COMMENTS}[$xmlfile] does not exist<BR>" + LogLine "ERROR: $xmlfile does not exist" + echo "ERROR: $xmlfile does not exist" + return 0 + fi + + return 1 +} + +################################################################################ +RunTest() { + typeset testcasename + typeset testcase + typeset testfile + typeset pdbfile + typeset xmlfile + typeset ext + integer try + integer finished_with_test + integer test_pass + + TestSetup + + BGCOLOR=$ODD_BGCOLOR + + while read line ; do + # get chars up to 1st space + testcasename=${line%% *} + testcase="${TESTCASEDIR}/$testcasename" + + # get 2nd word + testfile=${line#* } + testfile=${testfile%% *} + + # get last word + ext=${line##* } + + LogLine "############################################" + LogLine "Starting the following testcase" + LogLine "testcase = $testcase" + LogLine "testfile = $testfile" + LogLine "ext = $ext" + + ReportLine "<TR BGCOLOR='${BGCOLOR}'>" + ReportLine "<TD valign=top>$testcasename</TD>" + ReportLine "<TD valign=top>$testfile</TD>" + ReportLine "<TD valign=top>$ext</TD>" + + echo "" + echo "testcase = $testcase" + echo "testfile = $testfile" + echo "ext = $ext" + + try=1 + finished_with_test=0 + TEST_COMMENTS="" + + while (($finished_with_test == 0)) ; do + + TestCaseSetup + RunTestCase $testcase + TestCaseCleanup + + xmlfile="${testfile}.${ext}" + + if [[ $ext == "sxc" ]] ; then + pdbfile="${testfile}-Sheet1.pdb" + else + pdbfile="${testfile}.pdb" + fi + + CheckOutput $xmlfile $pdbfile + res=$? + + if [[ $res -eq 1 ]] ; then + ComparisonSetup $pdbfile + RunComparison pdb + res=$? +# ignore result until pdb comparator is fixed... +res=1 + ComparisonCleanup + fi + + if [[ $res -eq 1 ]] ; then + ComparisonSetup $xmlfile + RunComparison xml + res=$? + ComparisonCleanup + fi + + if [[ $res -eq 1 ]] ; then + TOTAL_PASS=TOTAL_PASS+1 + ReportLine "<TD valign=top BGCOLOR='${PASS_COLOR}'>PASS</TD>" + ReportTestComments + ReportLine "</TR>" + LogLine "Test PASSED (on try $try)" + echo "Test PASSED (on try $try)" + finished_with_test=1 + else + TEST_COMMENTS="${TEST_COMMENTS}error on try ${try}<BR>" + LogLine "TEST FAILED (on try $try)" + echo "TEST FAILED (on try $try)" + + if [[ $try -eq $MAX_RETRIES ]] ; then + TOTAL_FAIL=TOTAL_FAIL+1 + ReportLine "<TD valign=top BGCOLOR='${FAIL_COLOR}'>FAIL</TD>" + ReportTestComments + ReportLine "</TR>" + finished_with_test=1 + fi + fi + + try=try+1 + done + + TOTAL_RUN=TOTAL_RUN+1 + + # toggle BGCOLOR for next report line + if [[ $BGCOLOR == $ODD_BGCOLOR ]] ; then + BGCOLOR=$EVEN_BGCOLOR + else + BGCOLOR=$ODD_BGCOLOR + fi + + done < $MASTERLIST + + ReportLine "</TABLE>" + ReportLine "</CENTER>" + + TestCleanup + + echo "Total Tests PASSED: "${TOTAL_PASS} + echo "Total Tests FAILED: "${TOTAL_FAIL} + echo "Total Tests RUN: "${TOTAL_RUN} + echo "Results in: $RESDIR" + echo "Report file: $REPORT" +} + +################################################################################ +################################################################################ +# main +################################################################################ +################################################################################ + +GetParams $@ +ReadEnvFile +RunTest + +exit 0 |