1*cdf0e10cSrcweir#!/usr/bin/perl 2*cdf0e10cSrcweir######################################################################### 3*cdf0e10cSrcweir 4*cdf0e10cSrcweir #************************************************************************* 5*cdf0e10cSrcweir # 6*cdf0e10cSrcweir# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7*cdf0e10cSrcweir# 8*cdf0e10cSrcweir# Copyright 2000, 2010 Oracle and/or its affiliates. 9*cdf0e10cSrcweir# 10*cdf0e10cSrcweir# OpenOffice.org - a multi-platform office productivity suite 11*cdf0e10cSrcweir# 12*cdf0e10cSrcweir# This file is part of OpenOffice.org. 13*cdf0e10cSrcweir# 14*cdf0e10cSrcweir# OpenOffice.org is free software: you can redistribute it and/or modify 15*cdf0e10cSrcweir# it under the terms of the GNU Lesser General Public License version 3 16*cdf0e10cSrcweir# only, as published by the Free Software Foundation. 17*cdf0e10cSrcweir# 18*cdf0e10cSrcweir# OpenOffice.org is distributed in the hope that it will be useful, 19*cdf0e10cSrcweir# but WITHOUT ANY WARRANTY; without even the implied warranty of 20*cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21*cdf0e10cSrcweir# GNU Lesser General Public License version 3 for more details 22*cdf0e10cSrcweir# (a copy is included in the LICENSE file that accompanied this code). 23*cdf0e10cSrcweir# 24*cdf0e10cSrcweir# You should have received a copy of the GNU Lesser General Public License 25*cdf0e10cSrcweir# version 3 along with OpenOffice.org. If not, see 26*cdf0e10cSrcweir# <http://www.openoffice.org/license.html> 27*cdf0e10cSrcweir# for a copy of the LGPLv3 License. 28*cdf0e10cSrcweir# 29*cdf0e10cSrcweir #************************************************************************* 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir#################################################################### 32*cdf0e10cSrcweir# File Name: test_driver.pl 33*cdf0e10cSrcweir# Version : 1.0 34*cdf0e10cSrcweir# Project : Xmerge 35*cdf0e10cSrcweir# Author : Brian Cameron 36*cdf0e10cSrcweir# Date : 5th Sept. 2001 37*cdf0e10cSrcweir# 38*cdf0e10cSrcweir# This script does the following: 39*cdf0e10cSrcweir# 40*cdf0e10cSrcweir# Processes the input file, and runs the tests specified in that 41*cdf0e10cSrcweir# file. This will do the following for each test: 42*cdf0e10cSrcweir# 43*cdf0e10cSrcweir# 1. Convert a file from XML to PDB format 44*cdf0e10cSrcweir# 2. Starts up the Palm OS emulator with the appropriate program 45*cdf0e10cSrcweir# running and the converted file loaded the program. 46*cdf0e10cSrcweir# 3. Makes automated changes as specified in the inputfile to 47*cdf0e10cSrcweir# this script.. 48*cdf0e10cSrcweir# 4. Returns to the main applications window. 49*cdf0e10cSrcweir# 50*cdf0e10cSrcweir# Parameter 51*cdf0e10cSrcweir# Filename to convert and change 52*cdf0e10cSrcweir# 53*cdf0e10cSrcweir########################################################################## 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir# Turn on auto-flushing 56*cdf0e10cSrcweir# 57*cdf0e10cSrcweir$|=1; 58*cdf0e10cSrcweir 59*cdf0e10cSrcweiruse EmRPC; 60*cdf0e10cSrcweir 61*cdf0e10cSrcweir# Directory where converterlib is located... 62*cdf0e10cSrcweir# 63*cdf0e10cSrcweiruse lib "$ENV{qa-dir}/lib"; 64*cdf0e10cSrcweiruse converterlib; 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir#-------------------- Start of main script ------------------------------------ 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir# Environmental Settings 69*cdf0e10cSrcweir 70*cdf0e10cSrcweir$pose_exe = "$ENV{pose-dir}/pose/posedist/pose"; 71*cdf0e10cSrcweir$pose_prc = "$ENV{thirdpartyapps-dir}"; 72*cdf0e10cSrcweir$test_list = ""; 73*cdf0e10cSrcweir$infile = ""; 74*cdf0e10cSrcweir$merge_opt = 0; 75*cdf0e10cSrcweir 76*cdf0e10cSrcweir# You may need to change this from the default if your pose emulator 77*cdf0e10cSrcweir# starts faster or slower than mine. 78*cdf0e10cSrcweir# 79*cdf0e10cSrcweirif ($ENV{'POSE_TIMEOUT'}) 80*cdf0e10cSrcweir{ 81*cdf0e10cSrcweir $pose_timeout = "$ENV{'POSE_TIMEOUT'}"; 82*cdf0e10cSrcweir} 83*cdf0e10cSrcweirelse 84*cdf0e10cSrcweir{ 85*cdf0e10cSrcweir $pose_timeout = 15; 86*cdf0e10cSrcweir} 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir$cmdline_len = @ARGV; 89*cdf0e10cSrcweirif ($cmdline_len <= 0) 90*cdf0e10cSrcweir{ 91*cdf0e10cSrcweir print_usage(); 92*cdf0e10cSrcweir exit (0); 93*cdf0e10cSrcweir} 94*cdf0e10cSrcweir 95*cdf0e10cSrcweir&process_cmdline(@ARGV); 96*cdf0e10cSrcweir&print_env(); 97*cdf0e10cSrcweir&verify_env_options(); 98*cdf0e10cSrcweir 99*cdf0e10cSrcweir# Make the output directories with timestamps included in the 100*cdf0e10cSrcweir# directory names. 101*cdf0e10cSrcweir# 102*cdf0e10cSrcweirmkdir $pdb_orig, 0777 || die "can not create directory <$pdb_new>."; 103*cdf0e10cSrcweir`chmod 777 $pdb_orig`; 104*cdf0e10cSrcweirmkdir $pdb_new, 0777 || die "can not create directory <$pdb_new>."; 105*cdf0e10cSrcweir`chmod 777 $pdb_new`; 106*cdf0e10cSrcweirmkdir $xml_new, 0777 || die "can not create directory <$pdb_new>."; 107*cdf0e10cSrcweir`chmod 777 $xml_new`; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir&verify_prcs_exist("DBExporter.prc"); 110*cdf0e10cSrcweir 111*cdf0e10cSrcweirif ($test_list ne "") 112*cdf0e10cSrcweir{ 113*cdf0e10cSrcweir open (TESTLIST, $test_list) || die "Couldn't open testcase list file $test_list"; 114*cdf0e10cSrcweir 115*cdf0e10cSrcweir while (<TESTLIST>) 116*cdf0e10cSrcweir { 117*cdf0e10cSrcweir &process_testcase($_); 118*cdf0e10cSrcweir } 119*cdf0e10cSrcweir} 120*cdf0e10cSrcweirelsif ($infile ne "") 121*cdf0e10cSrcweir{ 122*cdf0e10cSrcweir &process_testcase($infile); 123*cdf0e10cSrcweir} 124*cdf0e10cSrcweirelse 125*cdf0e10cSrcweir{ 126*cdf0e10cSrcweir die ("You didn't supply any test cases to process"); 127*cdf0e10cSrcweir} 128*cdf0e10cSrcweir 129*cdf0e10cSrcweirprint "Finished.\n"; 130*cdf0e10cSrcweirexit(0); 131*cdf0e10cSrcweir 132*cdf0e10cSrcweir#-------------------- End of main script ---------------------------------------- 133*cdf0e10cSrcweir 134*cdf0e10cSrcweir#-------------------------------------------------------------------------------- 135*cdf0e10cSrcweir# Various sub routines 136*cdf0e10cSrcweir#-------------------------------------------------------------------------------- 137*cdf0e10cSrcweir 138*cdf0e10cSrcweir# process_testcase 139*cdf0e10cSrcweir# infile - test case file name 140*cdf0e10cSrcweir# 141*cdf0e10cSrcweir# This is the main driver function 142*cdf0e10cSrcweir# Opens the infile, reads it in parses it, runs the appropriate conversion 143*cdf0e10cSrcweir# starts pose and load the file into the emulator. It launches the 144*cdf0e10cSrcweir# appropriate editor and then runs the commands specified in the test case. 145*cdf0e10cSrcweir# It then exports the file and saves it locally. Finally it is converted 146*cdf0e10cSrcweir# back to the original office format. 147*cdf0e10cSrcweir# 148*cdf0e10cSrcweirsub process_testcase 149*cdf0e10cSrcweir{ 150*cdf0e10cSrcweir my $infile = $_[0]; 151*cdf0e10cSrcweir my $convert_file = ""; 152*cdf0e10cSrcweir my $rc; 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir # Process the inputfile 155*cdf0e10cSrcweir # 156*cdf0e10cSrcweir open (INFILE, $infile) || die "Failed to open test case <$infile>"; 157*cdf0e10cSrcweir 158*cdf0e10cSrcweir $running_testtype = ""; 159*cdf0e10cSrcweir 160*cdf0e10cSrcweir # Process the input file. 161*cdf0e10cSrcweir # 162*cdf0e10cSrcweir while ($c_inline = <INFILE>) 163*cdf0e10cSrcweir { 164*cdf0e10cSrcweir chomp $c_inline; 165*cdf0e10cSrcweir @entry = split('\|', $c_inline); 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir # Process TEST 168*cdf0e10cSrcweir # 169*cdf0e10cSrcweir if ($c_inline =~ /^ *#/ || $c_inline =~ /^[ \t]*$/) 170*cdf0e10cSrcweir { 171*cdf0e10cSrcweir # skip comments and blank lines. 172*cdf0e10cSrcweir # 173*cdf0e10cSrcweir next; 174*cdf0e10cSrcweir } 175*cdf0e10cSrcweir elsif ("$entry[0]" eq "TEST") 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir # Close the test if one is running. 178*cdf0e10cSrcweir # 179*cdf0e10cSrcweir &close_program($convert_file); 180*cdf0e10cSrcweir $running_testtype = ""; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir $valid_test = 0; 183*cdf0e10cSrcweir 184*cdf0e10cSrcweir if ($#entry != 3) 185*cdf0e10cSrcweir { 186*cdf0e10cSrcweir print "\nERROR, $entry[0] invalid number of arguments\n\n"; 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir else 189*cdf0e10cSrcweir { 190*cdf0e10cSrcweir # Start the test. 191*cdf0e10cSrcweir # 192*cdf0e10cSrcweir print "\nStarting test: $entry[1]\n"; 193*cdf0e10cSrcweir $convert_file = $entry[3]; 194*cdf0e10cSrcweir 195*cdf0e10cSrcweir if ("$entry[2]" =~ /[Qq][Uu][Ii][Cc][Kk][Ww][Oo][Rr][Dd]/) 196*cdf0e10cSrcweir { 197*cdf0e10cSrcweir $xml_extension = "sxw"; 198*cdf0e10cSrcweir $convert_to = "doc"; 199*cdf0e10cSrcweir 200*cdf0e10cSrcweir # Convert XML file to pdb format. 201*cdf0e10cSrcweir # 202*cdf0e10cSrcweir $rc = &convert_to_pdb("$xml_orig", $convert_file, $xml_extension , 203*cdf0e10cSrcweir $convert_to,"$pdb_orig"); 204*cdf0e10cSrcweir if ($rc != 0) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir print "\nERROR, problem converting file $convert_file\n\n"; 207*cdf0e10cSrcweir } 208*cdf0e10cSrcweir else 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir # Start pose 211*cdf0e10cSrcweir # 212*cdf0e10cSrcweir $rc = &start_pose("$pose_exe", 213*cdf0e10cSrcweir "$pose_prc/Quickword.PRC,$pose_prc/DBExporter.prc,$pdb_orig/$convert_file.pdb", 214*cdf0e10cSrcweir "Quickword", $pose_timeout); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir if ($rc == 0) 217*cdf0e10cSrcweir { 218*cdf0e10cSrcweir &start_quickword(); 219*cdf0e10cSrcweir $valid_test = 1; 220*cdf0e10cSrcweir $running_testtype = "QUICKWORD"; 221*cdf0e10cSrcweir print "\npose launched, begin automated test sequence for QuickWord\n"; 222*cdf0e10cSrcweir } 223*cdf0e10cSrcweir else 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir &kill_pose(); 226*cdf0e10cSrcweir $running_testtype = ""; 227*cdf0e10cSrcweir } 228*cdf0e10cSrcweir } 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir elsif ("$entry[2]" =~ /[Mm][Ii][Nn][Ii][Cc][Aa][Ll][Cc]/) 231*cdf0e10cSrcweir { 232*cdf0e10cSrcweir $xml_extension = "sxc"; 233*cdf0e10cSrcweir $convert_to = "minicalc"; 234*cdf0e10cSrcweir 235*cdf0e10cSrcweir # Convert XML file to pdb format. 236*cdf0e10cSrcweir # 237*cdf0e10cSrcweir $rc = &convert_to_pdb("$xml_orig", $convert_file, 238*cdf0e10cSrcweir $xml_extension, $convert_to,"$pdb_orig"); 239*cdf0e10cSrcweir if ($rc != 0) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir print "\nERROR, problem converting file $convert_file\n\n"; 242*cdf0e10cSrcweir } 243*cdf0e10cSrcweir else 244*cdf0e10cSrcweir { 245*cdf0e10cSrcweir # Get minicalc PDB file names, since an SXC file can 246*cdf0e10cSrcweir # be converted to more than one. 247*cdf0e10cSrcweir # 248*cdf0e10cSrcweir $pdb_files=""; 249*cdf0e10cSrcweir $i = 1; 250*cdf0e10cSrcweir while (-f "$pdb_orig/$convert_file-Sheet$i.pdb") 251*cdf0e10cSrcweir { 252*cdf0e10cSrcweir if ($i > 1) 253*cdf0e10cSrcweir { 254*cdf0e10cSrcweir $pdb_files .= ","; 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir $pdb_files .= "$pdb_orig/$convert_file-Sheet$i.pdb"; 257*cdf0e10cSrcweir $i++; 258*cdf0e10cSrcweir } 259*cdf0e10cSrcweir $number = $i-1; 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir # Start pose 262*cdf0e10cSrcweir # 263*cdf0e10cSrcweir $rc = &start_pose("$pose_exe", 264*cdf0e10cSrcweir "$pose_prc/MiniCalc.prc,$pose_prc/DBExporter.prc,$pdb_files", 265*cdf0e10cSrcweir "MiniCalc", $pose_timeout); 266*cdf0e10cSrcweir 267*cdf0e10cSrcweir if ($rc == 0) 268*cdf0e10cSrcweir { 269*cdf0e10cSrcweir &start_minicalc(); 270*cdf0e10cSrcweir $valid_test = 1; 271*cdf0e10cSrcweir $running_testtype = "MINICALC"; 272*cdf0e10cSrcweir print "pose launched, begin automated test sequence for MiniCalc\n"; 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir else 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir &kill_pose(); 277*cdf0e10cSrcweir $running_testtype = ""; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir else 282*cdf0e10cSrcweir { 283*cdf0e10cSrcweir print "\nERROR, invalid extension <$entry[2]>\n\n"; 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir } 286*cdf0e10cSrcweir } 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir # Process DB_EXPORT 289*cdf0e10cSrcweir # 290*cdf0e10cSrcweir elsif ("$entry[0]" eq "DB_EXPORT") 291*cdf0e10cSrcweir { 292*cdf0e10cSrcweir if ($#entry != 1) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir print "\nERROR, $entry[0] invalid number of arguments\n\n"; 295*cdf0e10cSrcweir } 296*cdf0e10cSrcweir else 297*cdf0e10cSrcweir { 298*cdf0e10cSrcweir &db_export($entry[1]); 299*cdf0e10cSrcweir } 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir # Process TAP_APPLICATIONS 303*cdf0e10cSrcweir # 304*cdf0e10cSrcweir elsif ("$entry[0]" eq "TAP_APPLICATIONS") 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir if ($#entry != 0) 307*cdf0e10cSrcweir { 308*cdf0e10cSrcweir print "\nERROR, $entry[0] invalid number of arguments\n\n"; 309*cdf0e10cSrcweir } 310*cdf0e10cSrcweir else 311*cdf0e10cSrcweir { 312*cdf0e10cSrcweir &tap_applications(0); 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir 316*cdf0e10cSrcweir # Process ENTER_STRING_AT_LOCATION 317*cdf0e10cSrcweir # 318*cdf0e10cSrcweir elsif ("$entry[0]" eq "ENTER_STRING_AT_LOCATION") 319*cdf0e10cSrcweir { 320*cdf0e10cSrcweir if ($#entry != 3) 321*cdf0e10cSrcweir { 322*cdf0e10cSrcweir print "\nERROR, $entry[0] invalid number of arguments\n\n"; 323*cdf0e10cSrcweir } 324*cdf0e10cSrcweir elsif ($valid_test == 0) 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir print "\nERROR, can not process $entry[0] for invalid test\n\n"; 327*cdf0e10cSrcweir } 328*cdf0e10cSrcweir else 329*cdf0e10cSrcweir { 330*cdf0e10cSrcweir &enter_string_at_location($entry[1], $entry[2], 331*cdf0e10cSrcweir $entry[3], $running_testtype); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir # Process TAP_PEN 336*cdf0e10cSrcweir # 337*cdf0e10cSrcweir elsif ("$entry[0]" eq "TAP_PEN") 338*cdf0e10cSrcweir { 339*cdf0e10cSrcweir if ($#entry != 2) 340*cdf0e10cSrcweir { 341*cdf0e10cSrcweir print "\nERROR, $entry[0] invalid number of arguments\n\n"; 342*cdf0e10cSrcweir } 343*cdf0e10cSrcweir elsif ($valid_test == 0) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir print "\nERROR, can not process $entry[0] for invalid test\n\n"; 346*cdf0e10cSrcweir } 347*cdf0e10cSrcweir else 348*cdf0e10cSrcweir { 349*cdf0e10cSrcweir &pose_tap_pen($entry[1], $entry[2], 0); 350*cdf0e10cSrcweir } 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir # Process TAP_BUTTON 354*cdf0e10cSrcweir # 355*cdf0e10cSrcweir elsif ("$entry[0]" eq "TAP_BUTTON") 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir if ($#entry != 1) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir print "\nERROR, $entry[0] invalid number of arguments\n\n"; 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir elsif ($valid_test == 0) 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir print "\nERROR, can not process $entry[0] for invalid test\n\n"; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir else 366*cdf0e10cSrcweir { 367*cdf0e10cSrcweir &pose_tap_button($entry[1], 0); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir } 370*cdf0e10cSrcweir 371*cdf0e10cSrcweir # Process SLEEP 372*cdf0e10cSrcweir # 373*cdf0e10cSrcweir elsif ("$entry[0]" eq "SLEEP") 374*cdf0e10cSrcweir { 375*cdf0e10cSrcweir if ($#entry != 1) 376*cdf0e10cSrcweir { 377*cdf0e10cSrcweir print "\nERROR, $entry[0] invalid number of arguments\n\n"; 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir else 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir &pose_sleep($entry[1]); 382*cdf0e10cSrcweir } 383*cdf0e10cSrcweir } 384*cdf0e10cSrcweir 385*cdf0e10cSrcweir # Process MINICALC_ENTER_CELL 386*cdf0e10cSrcweir # 387*cdf0e10cSrcweir elsif ("$entry[0]" eq "MINICALC_ENTER_CELL") 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir if ($#entry != 3) 390*cdf0e10cSrcweir { 391*cdf0e10cSrcweir print "\nERROR, $entry[0] invalid number of arguments\n\n"; 392*cdf0e10cSrcweir } 393*cdf0e10cSrcweir elsif ($valid_test == 0) 394*cdf0e10cSrcweir { 395*cdf0e10cSrcweir print "\nERROR, can not process $entry[0] for invalid test\n\n"; 396*cdf0e10cSrcweir } 397*cdf0e10cSrcweir else 398*cdf0e10cSrcweir { 399*cdf0e10cSrcweir &minicalc_enter_cell($entry[1], $entry[2], $entry[3]); 400*cdf0e10cSrcweir } 401*cdf0e10cSrcweir } 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir # Process QUICKWORD_FIND_REPLACE 404*cdf0e10cSrcweir # 405*cdf0e10cSrcweir elsif ("$entry[0]" eq "QUICKWORD_FIND_REPLACE") 406*cdf0e10cSrcweir { 407*cdf0e10cSrcweir if ($#entry != 2) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir print "\nERROR, $entry[0] invalid number of arguments\n\n"; 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir elsif ($valid_test == 0) 412*cdf0e10cSrcweir { 413*cdf0e10cSrcweir print "\nERROR, can not process $entry[0] for invalid test\n\n"; 414*cdf0e10cSrcweir } 415*cdf0e10cSrcweir else 416*cdf0e10cSrcweir { 417*cdf0e10cSrcweir &quickword_find_replace($entry[1], $entry[2]); 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir } 420*cdf0e10cSrcweir else 421*cdf0e10cSrcweir { 422*cdf0e10cSrcweir print "\nERROR, invalid line <$c_inline>\n"; 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir &close_program($convert_file); 427*cdf0e10cSrcweir} 428*cdf0e10cSrcweir 429*cdf0e10cSrcweir# close_program 430*cdf0e10cSrcweir# convert_file - file to export 431*cdf0e10cSrcweir# 432*cdf0e10cSrcweir# closes the program running in pose and kills pose 433*cdf0e10cSrcweir# 434*cdf0e10cSrcweirsub close_program 435*cdf0e10cSrcweir{ 436*cdf0e10cSrcweir my $convert_file = $_[0]; 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir if ($running_testtype eq "QUICKWORD") 439*cdf0e10cSrcweir { 440*cdf0e10cSrcweir print "QuickWord test completed.\n"; 441*cdf0e10cSrcweir &close_program_quickword($convert_file); 442*cdf0e10cSrcweir } 443*cdf0e10cSrcweir elsif ($running_testtype eq "MINICALC") 444*cdf0e10cSrcweir { 445*cdf0e10cSrcweir print "MiniCalc test completed.\n"; 446*cdf0e10cSrcweir &close_program_minicalc($convert_file, $number); 447*cdf0e10cSrcweir } 448*cdf0e10cSrcweir} 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir# close_program_quickword 451*cdf0e10cSrcweir# convert_file - file to export 452*cdf0e10cSrcweir# 453*cdf0e10cSrcweir# Closes quickword and kills pose 454*cdf0e10cSrcweir# 455*cdf0e10cSrcweirsub close_program_quickword 456*cdf0e10cSrcweir{ 457*cdf0e10cSrcweir my $convert_file = $_[0]; 458*cdf0e10cSrcweir my $error_file = "./error.txt"; 459*cdf0e10cSrcweir my $rc; 460*cdf0e10cSrcweir 461*cdf0e10cSrcweir &close_quickword(); 462*cdf0e10cSrcweir 463*cdf0e10cSrcweir &db_export($convert_file); 464*cdf0e10cSrcweir print "Moving /tmp/$convert_file.pdb to $pdb_new\n"; 465*cdf0e10cSrcweir `mv /tmp/$convert_file.pdb $pdb_new`; 466*cdf0e10cSrcweir `chmod 666 $pdb_new/$convert_file.pdb`; 467*cdf0e10cSrcweir 468*cdf0e10cSrcweir &close_connection(1); 469*cdf0e10cSrcweir &kill_pose(); 470*cdf0e10cSrcweir print "\nFinishing test...\n"; 471*cdf0e10cSrcweir 472*cdf0e10cSrcweir # The path of where to put the error file should be specified 473*cdf0e10cSrcweir # in the properties file. Not sure if it is really necessary 474*cdf0e10cSrcweir # to put this out to a separate file. STDOUT should be fine. 475*cdf0e10cSrcweir # 476*cdf0e10cSrcweir $rc = &convert_to_xml($xml_new, $xml_orig, 477*cdf0e10cSrcweir "$pdb_new/$convert_file.pdb", "doc" , 478*cdf0e10cSrcweir "sxw", $convert_file, $merge_opt); 479*cdf0e10cSrcweir if ($rc != 0) 480*cdf0e10cSrcweir { 481*cdf0e10cSrcweir print "\nERROR, problem converting file $pdb_new/$convert_file.pdb\n\n"; 482*cdf0e10cSrcweir } 483*cdf0e10cSrcweir} 484*cdf0e10cSrcweir 485*cdf0e10cSrcweir# close_program_minicalc 486*cdf0e10cSrcweir# convert_file - file to export 487*cdf0e10cSrcweir# 488*cdf0e10cSrcweir# Closes minicalc and kills pose 489*cdf0e10cSrcweir# 490*cdf0e10cSrcweirsub close_program_minicalc 491*cdf0e10cSrcweir{ 492*cdf0e10cSrcweir my $convert_file = $_[0]; 493*cdf0e10cSrcweir my $num_files = $_[1]; 494*cdf0e10cSrcweir my $list=""; 495*cdf0e10cSrcweir my $rc; 496*cdf0e10cSrcweir 497*cdf0e10cSrcweir &close_minicalc(); 498*cdf0e10cSrcweir 499*cdf0e10cSrcweir for ($a=1; $a <= $num_files; $a++) 500*cdf0e10cSrcweir { 501*cdf0e10cSrcweir &db_export("$convert_file-Sheet$a"); 502*cdf0e10cSrcweir print "Moving /tmp/$convert_file-Sheet$a.pdb to $pdb_new/\n"; 503*cdf0e10cSrcweir `mv /tmp/$convert_file-Sheet$a.pdb $pdb_new/`; 504*cdf0e10cSrcweir `chmod 666 $pdb_new/$convert_file-Sheet$a.pdb`; 505*cdf0e10cSrcweir } 506*cdf0e10cSrcweir 507*cdf0e10cSrcweir &close_connection(1); 508*cdf0e10cSrcweir &kill_pose(); 509*cdf0e10cSrcweir print "\nFinishing test...\n"; 510*cdf0e10cSrcweir 511*cdf0e10cSrcweir for ($a=1; $a <= $num_files; $a++) 512*cdf0e10cSrcweir { 513*cdf0e10cSrcweir $list .="$pdb_new/$convert_file-Sheet$a.pdb " 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir $rc = &convert_to_xml($xml_new, $xml_orig, "$list", 517*cdf0e10cSrcweir "minicalc", "sxc", $convert_file, $merge_opt); 518*cdf0e10cSrcweir if ($rc != 0) 519*cdf0e10cSrcweir { 520*cdf0e10cSrcweir print "\nERROR, problem converting file(s) $list\n\n"; 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir &pose_sleep(5); 524*cdf0e10cSrcweir} 525*cdf0e10cSrcweir 526*cdf0e10cSrcweir# print_usage 527*cdf0e10cSrcweir# 528*cdf0e10cSrcweir# prints the usage for this program. 529*cdf0e10cSrcweir# 530*cdf0e10cSrcweirsub print_usage 531*cdf0e10cSrcweir{ 532*cdf0e10cSrcweir print "Usage : test_driver.pl\n"; 533*cdf0e10cSrcweir print "\t-test=<file> \t\t: individual test case file to run\n"; 534*cdf0e10cSrcweir print "\t-list=<file> \t\t: list of test case files\n"; 535*cdf0e10cSrcweir print "\t-env=<file> \t\t: Properites like file defining env\n"; 536*cdf0e10cSrcweir print "\t-pose-exe=<fullpath> \t: path to pose executable\n"; 537*cdf0e10cSrcweir print "\t-pose-prc=<path> \t: path to directory holding prc files\n"; 538*cdf0e10cSrcweir print "\t-pdb-orig=<path> \t: directory to hold original pdb files\n"; 539*cdf0e10cSrcweir print "\t-pdb-new=<path> \t: directory to hold new pdb files\n"; 540*cdf0e10cSrcweir print "\t-xml-orig=<path> \t: directory to hold original office documents\n"; 541*cdf0e10cSrcweir print "\t-xml-new=<path> \t: directory to hold new office documents\n"; 542*cdf0e10cSrcweir print "\t-merge \t: Invokes the merge option when converting\n"; 543*cdf0e10cSrcweir print "\t \t from PDB back to XML.\n"; 544*cdf0e10cSrcweir} 545*cdf0e10cSrcweir 546*cdf0e10cSrcweir# print_env 547*cdf0e10cSrcweir# 548*cdf0e10cSrcweir# Prints the current environment. 549*cdf0e10cSrcweir# 550*cdf0e10cSrcweirsub print_env 551*cdf0e10cSrcweir{ 552*cdf0e10cSrcweir print "\nUsing the following environment:\n"; 553*cdf0e10cSrcweir print "\tPOSE_EXE = $pose_exe\n"; 554*cdf0e10cSrcweir print "\tPOSE_PRC = $pose_prc\n"; 555*cdf0e10cSrcweir print "\tPDB_ORIG = $pdb_orig\n"; 556*cdf0e10cSrcweir print "\tPDB_NEW = $pdb_new\n"; 557*cdf0e10cSrcweir print "\tXML_ORIG = $xml_orig\n"; 558*cdf0e10cSrcweir print "\tXML_NEW = $xml_new\n"; 559*cdf0e10cSrcweir} 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir# process_cmdline 562*cdf0e10cSrcweir# 563*cdf0e10cSrcweir# command line options come in as key/value pairs. 564*cdf0e10cSrcweir# read them and set the appropriate global variable 565*cdf0e10cSrcweir# 566*cdf0e10cSrcweir# Sets these globals: pose_exe, pose_prc, xml_orig, xml_new_dir, 567*cdf0e10cSrcweir# xml_new, pdb_orig_dir, pdb_orig, pdb_new_dir, pdb_new. 568*cdf0e10cSrcweir# 569*cdf0e10cSrcweirsub process_cmdline 570*cdf0e10cSrcweir{ 571*cdf0e10cSrcweir my $lu_str = &get_date_string(); 572*cdf0e10cSrcweir 573*cdf0e10cSrcweir foreach $i (@_) 574*cdf0e10cSrcweir { 575*cdf0e10cSrcweir my @arg= split('=', $i); 576*cdf0e10cSrcweir @arg[0] =~ tr/A-Z/a-z/; 577*cdf0e10cSrcweir 578*cdf0e10cSrcweir if (@arg[0] eq "-pose-exe") 579*cdf0e10cSrcweir { 580*cdf0e10cSrcweir $pose_exe=$arg[1]; 581*cdf0e10cSrcweir } 582*cdf0e10cSrcweir elsif (@arg[0] eq "-pose-prc") 583*cdf0e10cSrcweir { 584*cdf0e10cSrcweir $pose_prc=$arg[1]; 585*cdf0e10cSrcweir } 586*cdf0e10cSrcweir elsif (@arg[0] eq "-pdb-orig") 587*cdf0e10cSrcweir { 588*cdf0e10cSrcweir $pdb_orig_dir=$arg[1]; 589*cdf0e10cSrcweir $pdb_orig=$arg[1]; 590*cdf0e10cSrcweir $pdb_orig .= "/"; 591*cdf0e10cSrcweir $pdb_orig .= "$lu_str"; 592*cdf0e10cSrcweir } 593*cdf0e10cSrcweir elsif (@arg[0] eq "-pdb-new") 594*cdf0e10cSrcweir { 595*cdf0e10cSrcweir $pdb_new_dir=$arg[1]; 596*cdf0e10cSrcweir $pdb_new=$arg[1]; 597*cdf0e10cSrcweir $pdb_new .= "/"; 598*cdf0e10cSrcweir $pdb_new .= "$lu_str"; 599*cdf0e10cSrcweir } 600*cdf0e10cSrcweir elsif (@arg[0] eq "-xml-orig") 601*cdf0e10cSrcweir { 602*cdf0e10cSrcweir $xml_orig=$arg[1]; 603*cdf0e10cSrcweir } 604*cdf0e10cSrcweir elsif (@arg[0] eq "-xml-new") 605*cdf0e10cSrcweir { 606*cdf0e10cSrcweir $xml_new_dir=$arg[1]; 607*cdf0e10cSrcweir $xml_new=$arg[1]; 608*cdf0e10cSrcweir $xml_new .= "/"; 609*cdf0e10cSrcweir $xml_new .= "$lu_str"; 610*cdf0e10cSrcweir } 611*cdf0e10cSrcweir elsif (@arg[0] eq "-env") 612*cdf0e10cSrcweir { 613*cdf0e10cSrcweir &set_env_from_props($arg[1]); 614*cdf0e10cSrcweir } 615*cdf0e10cSrcweir elsif (@arg[0] eq "-list") 616*cdf0e10cSrcweir { 617*cdf0e10cSrcweir $test_list = $arg[1]; 618*cdf0e10cSrcweir } 619*cdf0e10cSrcweir elsif (@arg[0] eq "-test") 620*cdf0e10cSrcweir { 621*cdf0e10cSrcweir $infile = $arg[1]; 622*cdf0e10cSrcweir } 623*cdf0e10cSrcweir elsif (@arg[0] eq "-merge") 624*cdf0e10cSrcweir { 625*cdf0e10cSrcweir $merge_opt = 1; 626*cdf0e10cSrcweir } 627*cdf0e10cSrcweir else 628*cdf0e10cSrcweir { 629*cdf0e10cSrcweir print_usage(); 630*cdf0e10cSrcweir die "Incorrect command line"; 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir } 633*cdf0e10cSrcweir} 634*cdf0e10cSrcweir 635*cdf0e10cSrcweir# set_env_from_props 636*cdf0e10cSrcweir# infile - property file 637*cdf0e10cSrcweir# 638*cdf0e10cSrcweir# Read the properties file, of the form key=value 639*cdf0e10cSrcweir# Valid key values are : 640*cdf0e10cSrcweir# POSE_EXE 641*cdf0e10cSrcweir# POSE_PRC 642*cdf0e10cSrcweir# POSE_PERL 643*cdf0e10cSrcweir# TEST_HOME 644*cdf0e10cSrcweir# PDB_ORIG 645*cdf0e10cSrcweir# PDB_NEW 646*cdf0e10cSrcweir# XML_ORIG 647*cdf0e10cSrcweir# XML_NEW 648*cdf0e10cSrcweir# If a value is found the appropriate global variable is set. 649*cdf0e10cSrcweir# 650*cdf0e10cSrcweir# Sets these globals: pose_exe, pose_prc, xml_orig, xml_new_dir, 651*cdf0e10cSrcweir# xml_new, pdb_orig_dir, pdb_orig, pdb_new_dir, pdb_new. 652*cdf0e10cSrcweir# 653*cdf0e10cSrcweirsub set_env_from_props 654*cdf0e10cSrcweir{ 655*cdf0e10cSrcweir my $infile = $_[0]; 656*cdf0e10cSrcweir my $lu_str = &get_date_string(); 657*cdf0e10cSrcweir 658*cdf0e10cSrcweir open(PROPSFILE, $infile) || die "Could not open properties file <$infile>"; 659*cdf0e10cSrcweir 660*cdf0e10cSrcweir while (<PROPSFILE>) 661*cdf0e10cSrcweir { 662*cdf0e10cSrcweir chomp $_; 663*cdf0e10cSrcweir my @arg = split('=', $_); 664*cdf0e10cSrcweir @arg[0] =~ tr/a-z/A-Z/; 665*cdf0e10cSrcweir my $len = @arg; 666*cdf0e10cSrcweir if ($len != 2) 667*cdf0e10cSrcweir { 668*cdf0e10cSrcweir die "Malformed property in $arg[0]"; 669*cdf0e10cSrcweir } 670*cdf0e10cSrcweir if (@arg[0] eq "POSE_EXE") 671*cdf0e10cSrcweir { 672*cdf0e10cSrcweir $pose_exe=$arg[1]; 673*cdf0e10cSrcweir } 674*cdf0e10cSrcweir elsif (@arg[0] eq "POSE_PRC") 675*cdf0e10cSrcweir { 676*cdf0e10cSrcweir $pose_prc=$arg[1]; 677*cdf0e10cSrcweir } 678*cdf0e10cSrcweir elsif (@arg[0] eq "PDB_ORIG") 679*cdf0e10cSrcweir { 680*cdf0e10cSrcweir $pdb_orig_dir=$arg[1]; 681*cdf0e10cSrcweir $pdb_orig=$arg[1]; 682*cdf0e10cSrcweir $pdb_orig .= "/"; 683*cdf0e10cSrcweir $pdb_orig .= "$lu_str"; 684*cdf0e10cSrcweir } 685*cdf0e10cSrcweir elsif (@arg[0] eq "PDB_NEW") 686*cdf0e10cSrcweir { 687*cdf0e10cSrcweir $pdb_new_dir=$arg[1]; 688*cdf0e10cSrcweir $pdb_new=$arg[1]; 689*cdf0e10cSrcweir $pdb_new .= "/"; 690*cdf0e10cSrcweir $pdb_new .= "$lu_str"; 691*cdf0e10cSrcweir } 692*cdf0e10cSrcweir elsif (@arg[0] eq "XML_ORIG") 693*cdf0e10cSrcweir { 694*cdf0e10cSrcweir $xml_orig=$arg[1]; 695*cdf0e10cSrcweir } 696*cdf0e10cSrcweir elsif (@arg[0] eq "XML_NEW") 697*cdf0e10cSrcweir { 698*cdf0e10cSrcweir $xml_new_dir=$arg[1]; 699*cdf0e10cSrcweir $xml_new=$arg[1]; 700*cdf0e10cSrcweir $xml_new .= "/"; 701*cdf0e10cSrcweir $xml_new .= "$lu_str"; 702*cdf0e10cSrcweir } 703*cdf0e10cSrcweir 704*cdf0e10cSrcweir } 705*cdf0e10cSrcweir close PROPSFILE; 706*cdf0e10cSrcweir} 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir# verify_env_options 709*cdf0e10cSrcweir# 710*cdf0e10cSrcweir# Verify that input options are correctly set. 711*cdf0e10cSrcweir# Assumes pose_exe, pose_prc, xml_orig, xml_new_dir, 712*cdf0e10cSrcweir# pdb_orig_dir, and pdb_new_dir are already set. 713*cdf0e10cSrcweir# 714*cdf0e10cSrcweirsub verify_env_options 715*cdf0e10cSrcweir{ 716*cdf0e10cSrcweir if (!-e "$pose_exe") 717*cdf0e10cSrcweir { 718*cdf0e10cSrcweir die "The pose executable cannot be found at $pose_exe."; 719*cdf0e10cSrcweir } 720*cdf0e10cSrcweir if (!-x $pose_exe) 721*cdf0e10cSrcweir { 722*cdf0e10cSrcweir die "$pose_exe exists but is not executable."; 723*cdf0e10cSrcweir } 724*cdf0e10cSrcweir 725*cdf0e10cSrcweir if (!-e "$pose_prc") 726*cdf0e10cSrcweir { 727*cdf0e10cSrcweir die "The PRC directory specified as $pose_prc does not exist."; 728*cdf0e10cSrcweir } 729*cdf0e10cSrcweir if (!-d "$pose_prc") 730*cdf0e10cSrcweir { 731*cdf0e10cSrcweir die "The PRC location specified as $pose_prc exists, but is not a directory."; 732*cdf0e10cSrcweir } 733*cdf0e10cSrcweir 734*cdf0e10cSrcweir if (!-e "$pdb_orig_dir") 735*cdf0e10cSrcweir { 736*cdf0e10cSrcweir die "The original PDB directory specified as $pdb_orig_dir does not exist."; 737*cdf0e10cSrcweir } 738*cdf0e10cSrcweir if (!-d "$pdb_orig_dir") 739*cdf0e10cSrcweir { 740*cdf0e10cSrcweir die "The original PDB directory specified as $pdb_orig_dir exists but is not a directory."; 741*cdf0e10cSrcweir } 742*cdf0e10cSrcweir 743*cdf0e10cSrcweir if (!-e "$pdb_new_dir") 744*cdf0e10cSrcweir { 745*cdf0e10cSrcweir die "The new PDB directory specified as $pdb_new_dir does not exist."; 746*cdf0e10cSrcweir } 747*cdf0e10cSrcweir if (!-d "$pdb_new_dir") 748*cdf0e10cSrcweir { 749*cdf0e10cSrcweir die "The new PDB directory specified as $pdb_new_dir exists but is not a directory."; 750*cdf0e10cSrcweir } 751*cdf0e10cSrcweir 752*cdf0e10cSrcweir if (!-e "$xml_orig") 753*cdf0e10cSrcweir { 754*cdf0e10cSrcweir die "The original Office document directory specified as $xml_orig does not exist."; 755*cdf0e10cSrcweir } 756*cdf0e10cSrcweir if (!-d "$xml_orig") 757*cdf0e10cSrcweir { 758*cdf0e10cSrcweir die "The original Office document location specified as $xml_orig exists but is not a directory."; 759*cdf0e10cSrcweir } 760*cdf0e10cSrcweir 761*cdf0e10cSrcweir if (!-e "$xml_new_dir") 762*cdf0e10cSrcweir { 763*cdf0e10cSrcweir die "The new Office document directory specified as $xml_new_dir does not exist."; 764*cdf0e10cSrcweir } 765*cdf0e10cSrcweir if (!-d "$xml_new_dir") 766*cdf0e10cSrcweir { 767*cdf0e10cSrcweir die "The new Office document location specified as $xml_new_dir exists but is not a directory."; 768*cdf0e10cSrcweir } 769*cdf0e10cSrcweir} 770*cdf0e10cSrcweir 771*cdf0e10cSrcweir# verify_prcs_exist 772*cdf0e10cSrcweir# prcfile - the PRC file to check 773*cdf0e10cSrcweir# 774*cdf0e10cSrcweir# Verifies that the specified PRC file exists. 775*cdf0e10cSrcweir# 776*cdf0e10cSrcweirsub verify_prcs_exist 777*cdf0e10cSrcweir{ 778*cdf0e10cSrcweir my $prcfile = $_[0]; 779*cdf0e10cSrcweir 780*cdf0e10cSrcweir if (!-e "$pose_prc/$prcfile") 781*cdf0e10cSrcweir { 782*cdf0e10cSrcweir die "The pose PRC directory ($pose_prc) is correct, but I can't find $prcfile there."; 783*cdf0e10cSrcweir } 784*cdf0e10cSrcweir} 785*cdf0e10cSrcweir 786