1 eval 'exec perl -wS $0 ${1+"$@"}'
3 #*************************************************************************
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 # Copyright 2000, 2010 Oracle and/or its affiliates.
9 # OpenOffice.org - a multi-platform office productivity suite
11 # This file is part of OpenOffice.org.
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.
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).
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.
28 #************************************************************************
42 sub initEnvironment
();
44 sub checkForKillobj
();
50 my $nGlobalFailures = 0;
52 my %libraryRunThrough;
55 # LLA: this does not exist, ... use a little bit simpler method.
56 # use File::Temp qw/ :POSIX /;
63 $params = "test "; # debug=t TESTOPTADD=\"-boom\" TESTOPTADD=\"-noerroronexit\"
66 # my $sLocalParams = $params;
67 # $sLocalParams =~ s/test\s/test$nNumber /;
68 # print "Testparams: $sLocalParams\n";
75 if (checkForKillobj
() == 1)
79 elsif (checkARGVFor
("buildall") == 1)
86 # always run test, but envelope the other in 'TESTOPT="..."'
87 $params = "test TESTOPT=\"";
89 foreach $param (@ARGV)
91 $params = $params . " " . $param;
93 $params = $params . "\"";
95 print "User defined ";
98 print "parameters for dmake: $params\n";
103 # ------------------------------------------------------------------------------
106 my $sCheckValue = shift;
109 foreach $sLocalParam (@ARGV)
111 if ($sLocalParam =~ /^${sCheckValue}$/)
119 # ------------------------------------------------------------------------------
120 sub checkForKillobj
()
124 foreach $sLocalParam (@ARGV)
126 if ($sLocalParam =~ /^killobj$/)
135 # ------------------------------------------------------------------------------
136 sub initEnvironment
()
139 # no error output in forms of message boxes
140 $ENV{'DISABLE_SAL_DBGBOX'}="t";
143 if ( $gui eq "WNT" ) {
145 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "c:${FS}tmp${FS}";
148 if ( $gui eq "WIN" ) {
150 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "c:${FS}tmp${FS}";
153 if ( $gui eq "UNX" ) {
155 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "${FS}tmp${FS}";
158 print STDERR
"buildall.pl: unkown platform\n";
162 # ------------------------------------------------------------------------------
167 $oldstr =~ s/^\s*(.*?)\s*$/$1/;
171 # ------------------------------------------------------------------------------
175 if ($OSNAME eq "linux" || $OSNAME eq "solaris")
177 return "lib" . $sFile . ".so";
179 if ($OSNAME eq "MSWin32")
181 return $sFile . ".dll";
185 # ------------------------------------------------------------------------------
188 my $sFailureFile = shift;
190 if (! open(IN
, $sFailureFile))
192 print "ERROR: Can't open output file $sFailureFile\n";
203 # ------------------------------------------------------------------------------
204 sub giveOutFailures
($$)
207 my $sFailureFile = shift;
214 if (! open(IN
, $sFailureFile))
216 print "ERROR: Can't open output file $sFailureFile\n";
220 my $bStartUnitTest = 0;
224 if ( $line =~ /^- start unit test/)
231 if ($bStartUnitTest == 0)
233 print "\nFailure: Unit test not started. Maybe compiler error.\n";
234 giveOutAll
($sFailureFile);
240 open(IN
, $sFailureFile);
241 # check if testshl2 was started
246 # handling of the states
247 if ( $line =~ /^\# -- BEGIN:/)
251 elsif ( $line =~ /^\# -- END:/)
269 # extra return for a better output
270 print "\nFailures occurred: $nFailures\n";
271 print "The whole output can be found in $sFailureFile\n";
275 $nGlobalFailures += $nFailures;
278 # ------------------------------------------------------------------------------
279 sub printOnLibrary
($)
282 print " on library: " . getLibName
($sTarget);
284 # ------------------------------------------------------------------------------
285 sub runASingleTest
($$)
289 my $dmake = "dmake $params";
291 my $sLogPath = $g_sTempDir . "dmake_out_$$";
293 my $sLogFile = $sLogPath . "/" . $sTarget . ".out";
295 # due to the fact, a library name in one project is distinct, we should remember all already run through libraries and
296 # supress same libraries, if they occur one more.
298 if (exists $libraryRunThrough{getLibName
($sTarget)})
303 printOnLibrary
($sTarget);
306 # redirect tcsh ">&" (stdout, stderr)
307 # redirect 4nt ">" (stdout), "2>" (stderr)
308 # print "OSNAME: $OSNAME\n";
309 # LLA: redirect check canceled, seems to be not work as I want.
311 # if ($OSNAME eq "linux" || $OSNAME eq "solaris")
313 # # print "UNIX, linux or solaris\n";
314 # $redirect = '>>&!' . $sLogFile;
318 # if ($OSNAME eq "MSWin32")
321 # $redirect = ">>$sLogFile 2>>$sLogFile";
324 # print "$dmake $redirect\n";
326 # LLA: so system does also not work as I imagine
327 # system("$dmake $redirect");
329 # LLA: next check, use open with pipe
332 if (! open( LOGFILE
, '>' . "$sLogFile"))
334 print "ERROR: can't open logfile: $sLogFile\n";
340 if (! open( DMAKEOUTPUT
, "$dmake 2>&1 |"))
342 print "ERROR: can't open dmake\n";
345 while ($line = <DMAKEOUTPUT
>)
348 print LOGFILE
"$line\n";
353 giveOutFailures
($sTarget, $sLogFile);
355 $libraryRunThrough{getLibName
($sTarget)} = "done";
358 # ------------------------------------------------------------------------------
366 if ($line =~ /^\#/ || $line =~ /^$/)
368 # remark or empty line
372 # special format, $file == $path
373 ($path, $file) = split(/;/, $line);
383 # ------------------------------------------------------------------------------
384 sub runTestsOnPath
($$$)
391 if (!$path || $path eq "")
393 # DBG: print "empty path '$path'\n";
396 if (!$file || $file eq "")
398 # DBG: print "empty file '$file'\n";
402 # print "File: '$file', Path: '$path'\n";
403 print "Work in directory: $path\n";
404 my $newpath = $cwd . $FS . $path;
405 # print "chdir to $newpath\n";
407 my $error = chdir($newpath);
410 # run through the hole makefile.mk and check if SHL<D>TARGET = ... exist, for every target call "dmake test<D>"
413 if (! open(MAKEFILE_MK
, "makefile.mk"))
415 print "ERROR: can't open makefile.mk in path: $newpath\n";
416 print "please check your libs2test.txt file in qa directory.\n";
423 while($line = <MAKEFILE_MK
>)
427 if ($line =~ /SHL(\d)TARGET=(.*)/)
432 # DBG: print "test$number is lib: $target\n";
433 $sLocalParams = $params . " "; # append a whitespace, so we can check if 'test' exist without additional digits
434 $sLocalParams =~ s/test\s/test$nNumber/;
435 # DBG: print "$sLocalParams\n";
436 if ($bBuildAll == 1 ||
439 # print "runASingleTest on Target: $sTarget 'dmake $sLocalParams'\n";
440 runASingleTest
($sTarget, $sLocalParams);
444 # printOnLibrary($sTarget);
445 # print " suppressed, not in libs2test.txt\n";
452 # ------------------------------------------------------------------------------
457 # my $sLogFile = shift; # "buildall_$$.out";
459 my $filename = "libs2test.txt";
462 open(LIBS2TEST
, $filename) || die "can't open $filename\n";
464 while($line = <LIBS2TEST
>)
471 $line = substr($line, 0, -1);
477 ($path, $file) = interpretLine
($line);
478 runTestsOnPath
($path, $file, $params);
482 print "\nComplete logging information will be found in dir: ".$g_sTempDir."dmake_out_$$/\n";
484 if ($nGlobalFailures > 0)
486 print "\nFailures over all occurred: $nGlobalFailures\n";
487 print "\nPASSED FAILED.\n";
491 print "\nPASSED OK.\n";
495 # ------------------------------------------------------------------------------