2 eval 'exec perl -wS $0 ${1+"$@"}'
5 #*************************************************************************
7 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
9 # Copyright 2000, 2010 Oracle and/or its affiliates.
11 # OpenOffice.org - a multi-platform office productivity suite
13 # This file is part of OpenOffice.org.
15 # OpenOffice.org is free software: you can redistribute it and/or modify
16 # it under the terms of the GNU Lesser General Public License version 3
17 # only, as published by the Free Software Foundation.
19 # OpenOffice.org is distributed in the hope that it will be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU Lesser General Public License version 3 for more details
23 # (a copy is included in the LICENSE file that accompanied this code).
25 # You should have received a copy of the GNU Lesser General Public License
26 # version 3 along with OpenOffice.org. If not, see
27 # <http://www.openoffice.org/license.html>
28 # for a copy of the LGPLv3 License.
30 #*************************************************************************
33 # cwstestresult.pl - publish results of CWS tests to EIS
43 if ( !defined($ENV{SOLARENV
}) ) {
44 die "No environment found (environment variable SOLARENV is undefined)";
46 push(@lib_dirs, "$ENV{SOLARENV}/bin/modules");
47 push(@lib_dirs, "$ENV{COMMON_ENV_TOOLS}/modules") if defined($ENV{COMMON_ENV_TOOLS
});
54 ( my $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/;
56 my $is_debug = 1; # enable debug
57 my $opt_master; # option: master workspace
58 my $opt_child; # option: child workspace
59 my $opt_milestone; # option: milestone
60 my $opt_testrunName; # option: testrunName
61 my $opt_testrunPlatform; # option: testrunPlatfrom
62 my $opt_resultPage; # option: resultPage
67 my $arg_status= parse_options
();
68 testresult
($arg_status);
76 # get master and child workspace
77 my $masterws = $opt_master ?
uc($opt_master) : $ENV{WORK_STAMP
};
78 my $milestone = $opt_milestone ?
$opt_milestone : $ENV{UPDMINOR
};
79 my $childws = $opt_milestone ?
undef : ( $opt_child ?
$opt_child : $ENV{CWS_WORK_STAMP
} );
81 if ( !defined($masterws) ) {
82 print_error
("Can't determine master workspace environment.\n"
83 . "Please initialize environment with setsolar ...", 1);
86 if ( !defined($childws) && !defined($milestone) ) {
87 print_error
("Can't determine child workspace environment or milestone.\n"
88 . "Please initialize environment with setsolar ...", 1);
90 if ( !defined($opt_resultPage) ) {
94 if ( defined($childws) ) {
95 $cws->child($childws);
97 $cws->master($masterws);
98 my $eis = $cws->eis();
103 if ( defined($childws) ) {
104 $opt_resultPage=SOAP
::Data
->type(string
=> $opt_resultPage);
105 my $id = $cws->eis_id();
106 if ( is_valid_cws
($cws) ) {
107 $result=$eis->submitTestResult($id,$opt_testrunName,$opt_testrunPlatform, $opt_resultPage, $status);
109 print STDERR
"cws is not valid";
112 $opt_resultPage=SOAP
::Data
->type(string
=> $opt_resultPage);
113 $result=$eis->submitTestResultMWS($masterws,$milestone,$opt_testrunName,$opt_testrunPlatform, $opt_resultPage, $status);
124 my $masterws = $cws->master();
125 my $childws = $cws->child();
126 # check if we got a valid child workspace
127 my $id = $cws->eis_id();
129 print_error
("Child workspace '$childws' for master workspace '$masterws' not found in EIS database.", 2);
136 # parse options and do some sanity checks
137 Getopt
::Long
::Configure
("no_ignore_case");
139 my $success = GetOptions
('h' => \
$help,
140 'M=s' => \
$opt_master,
141 'm=s' => \
$opt_milestone,
142 'c=s' => \
$opt_child,
143 'n=s' => \
$opt_testrunName,
144 'p=s' => \
$opt_testrunPlatform ,
145 'r=s' => \
$opt_resultPage );
146 if ( $help || !$success || $#ARGV < 0 || (!defined($opt_testrunName)) || ( !defined($opt_testrunPlatform)) ) {
151 print "$opt_master\n";
152 print "$opt_milestone\n";
153 print "$opt_child\n";
154 print "$opt_testrunName\n";
155 print "$opt_testrunPlatform\n";
156 print "$opt_resultPage\n";
158 if ( defined($opt_milestone) && defined($opt_child) ) {
159 print_error
("-m and -c are mutually exclusive options",1);
167 # my $message = shift;
169 # print STDERR "$script_name: ";
170 # print STDERR "$message\n";
177 my $error_code = shift;
179 print STDERR
"$script_name: ";
180 print STDERR
"ERROR: $message\n";
183 print STDERR
"\nFAILURE: $script_name aborted.\n";
191 print STDERR
"Usage: cwstestresult[-h] [-M masterws] [-m milestone|-c childws] <-n testrunName> <-p testrunPlatform> <-r resultPage> statusName\n";
193 print STDERR
"Publish result of CWS- or milestone-test to EIS\n";
195 print STDERR
"Options:\n";
196 print STDERR
"\t-h\t\t\thelp\n";
197 print STDERR
"\t-M master\t\toverride MWS specified in environment\n";
198 print STDERR
"\t-m milestone\t\toverride milestone specified in environment\n";
199 print STDERR
"\t-c child\t\toverride CWS specified in environment\n";
200 print STDERR
"\t-n testrunName\t\tspecifiy name of the test\n";
201 print STDERR
"\t-p testrunPlatform\tspecify platform where the test ran on\n";
202 print STDERR
"\t-r resultPage\t\tspecify name of attachment or hyperlink\n";
203 print STDERR
"\t\t\t\tfor resultPage\n";
206 print STDERR
"\nExample:\n";
207 print STDERR
"\tcwstestresult -c mycws -n Performance -p Windows -r PerfomanceTestWindows.html ok\n";