1 eval 'exec perl -wS $0 ${1+"$@"}'
3 #*************************************************************************
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 # Copyright 2008 by Sun Microsystems, Inc.
9 # OpenOffice.org - a multi-platform office productivity suite
11 # $RCSfile: buildall.pl,v $
15 # This file is part of OpenOffice.org.
17 # OpenOffice.org is free software: you can redistribute it and/or modify
18 # it under the terms of the GNU Lesser General Public License version 3
19 # only, as published by the Free Software Foundation.
21 # OpenOffice.org is distributed in the hope that it will be useful,
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 # GNU Lesser General Public License version 3 for more details
25 # (a copy is included in the LICENSE file that accompanied this code).
27 # You should have received a copy of the GNU Lesser General Public License
28 # version 3 along with OpenOffice.org. If not, see
29 # <http://www.openoffice.org/license.html>
30 # for a copy of the LGPLv3 License.
32 #************************************************************************
46 sub initEnvironment
();
48 sub checkForKillobj
();
54 my $nGlobalFailures = 0;
56 my %libraryRunThrough;
59 # LLA: this does not exist, ... use a little bit simpler method.
60 # use File::Temp qw/ :POSIX /;
67 $params = "test "; # debug=t TESTOPTADD=\"-boom\" TESTOPTADD=\"-noerroronexit\"
70 # my $sLocalParams = $params;
71 # $sLocalParams =~ s/test\s/test$nNumber /;
72 # print "Testparams: $sLocalParams\n";
79 if (checkForKillobj
() == 1)
83 elsif (checkARGVFor
("buildall") == 1)
90 # always run test, but envelope the other in 'TESTOPT="..."'
91 $params = "test TESTOPT=\"";
93 foreach $param (@ARGV)
95 $params = $params . " " . $param;
97 $params = $params . "\"";
99 print "User defined ";
102 print "parameters for dmake: $params\n";
107 # ------------------------------------------------------------------------------
110 my $sCheckValue = shift;
113 foreach $sLocalParam (@ARGV)
115 if ($sLocalParam =~ /^${sCheckValue}$/)
123 # ------------------------------------------------------------------------------
124 sub checkForKillobj
()
128 foreach $sLocalParam (@ARGV)
130 if ($sLocalParam =~ /^killobj$/)
139 # ------------------------------------------------------------------------------
140 sub initEnvironment
()
143 # no error output in forms of message boxes
144 $ENV{'DISABLE_SAL_DBGBOX'}="t";
147 if ( $gui eq "WNT" ) {
149 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "c:${FS}tmp${FS}";
152 if ( $gui eq "WIN" ) {
154 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "c:${FS}tmp${FS}";
157 if ( $gui eq "OS2" ) {
159 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "c:${FS}tmp${FS}";
162 if ( $gui eq "UNX" ) {
164 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "${FS}tmp${FS}";
167 print STDERR
"buildall.pl: unkown platform\n";
171 # ------------------------------------------------------------------------------
176 $oldstr =~ s/^\s*(.*?)\s*$/$1/;
180 # ------------------------------------------------------------------------------
184 if ($OSNAME eq "linux" || $OSNAME eq "solaris")
186 return "lib" . $sFile . ".so";
188 if ($OSNAME eq "MSWin32" || $OSNAME eq "OS2")
190 return $sFile . ".dll";
194 # ------------------------------------------------------------------------------
197 my $sFailureFile = shift;
199 if (! open(IN
, $sFailureFile))
201 print "ERROR: Can't open output file $sFailureFile\n";
212 # ------------------------------------------------------------------------------
213 sub giveOutFailures
($$)
216 my $sFailureFile = shift;
223 if (! open(IN
, $sFailureFile))
225 print "ERROR: Can't open output file $sFailureFile\n";
229 my $bStartUnitTest = 0;
233 if ( $line =~ /^- start unit test/)
240 if ($bStartUnitTest == 0)
242 print "\nFailure: Unit test not started. Maybe compiler error.\n";
243 giveOutAll
($sFailureFile);
249 open(IN
, $sFailureFile);
250 # check if testshl2 was started
255 # handling of the states
256 if ( $line =~ /^\# -- BEGIN:/)
260 elsif ( $line =~ /^\# -- END:/)
278 # extra return for a better output
279 print "\nFailures occured: $nFailures\n";
280 print "The whole output can be found in $sFailureFile\n";
284 $nGlobalFailures += $nFailures;
287 # ------------------------------------------------------------------------------
288 sub printOnLibrary
($)
291 print " on library: " . getLibName
($sTarget);
293 # ------------------------------------------------------------------------------
294 sub runASingleTest
($$)
298 my $dmake = "dmake $params";
300 my $sLogPath = $g_sTempDir . "dmake_out_$$";
302 my $sLogFile = $sLogPath . "/" . $sTarget . ".out";
304 # due to the fact, a library name in one project is distinct, we should remember all already run through libraries and
305 # supress same libraries, if they occur one more.
307 if (exists $libraryRunThrough{getLibName
($sTarget)})
312 printOnLibrary
($sTarget);
315 # redirect tcsh ">&" (stdout, stderr)
316 # redirect 4nt ">" (stdout), "2>" (stderr)
317 # print "OSNAME: $OSNAME\n";
318 # LLA: redirect check canceled, seems to be not work as I want.
320 # if ($OSNAME eq "linux" || $OSNAME eq "solaris")
322 # # print "UNIX, linux or solaris\n";
323 # $redirect = '>>&!' . $sLogFile;
327 # if ($OSNAME eq "MSWin32" || $OSNAME eq "OS2")
330 # $redirect = ">>$sLogFile 2>>$sLogFile";
333 # print "$dmake $redirect\n";
335 # LLA: so system does also not work as I imagine
336 # system("$dmake $redirect");
338 # LLA: next check, use open with pipe
341 if (! open( LOGFILE
, '>' . "$sLogFile"))
343 print "ERROR: can't open logfile: $sLogFile\n";
349 if (! open( DMAKEOUTPUT
, "$dmake 2>&1 |"))
351 print "ERROR: can't open dmake\n";
354 while ($line = <DMAKEOUTPUT
>)
357 print LOGFILE
"$line\n";
362 giveOutFailures
($sTarget, $sLogFile);
364 $libraryRunThrough{getLibName
($sTarget)} = "done";
367 # ------------------------------------------------------------------------------
375 if ($line =~ /^\#/ || $line =~ /^$/)
377 # remark or empty line
381 # special format, $file == $path
382 ($path, $file) = split(/;/, $line);
392 # ------------------------------------------------------------------------------
393 sub runTestsOnPath
($$$)
400 if (!$path || $path eq "")
402 # DBG: print "empty path '$path'\n";
405 if (!$file || $file eq "")
407 # DBG: print "empty file '$file'\n";
411 # print "File: '$file', Path: '$path'\n";
412 print "Work in directory: $path\n";
413 my $newpath = $cwd . $FS . $path;
414 # print "chdir to $newpath\n";
416 my $error = chdir($newpath);
419 # run through the hole makefile.mk and check if SHL<D>TARGET = ... exist, for every target call "dmake test<D>"
422 if (! open(MAKEFILE_MK
, "makefile.mk"))
424 print "ERROR: can't open makefile.mk in path: $newpath\n";
425 print "please check your libs2test.txt file in qa directory.\n";
432 while($line = <MAKEFILE_MK
>)
436 if ($line =~ /SHL(\d)TARGET=(.*)/)
441 # DBG: print "test$number is lib: $target\n";
442 $sLocalParams = $params . " "; # append a whitespace, so we can check if 'test' exist without additional digits
443 $sLocalParams =~ s/test\s/test$nNumber/;
444 # DBG: print "$sLocalParams\n";
445 if ($bBuildAll == 1 ||
448 # print "runASingleTest on Target: $sTarget 'dmake $sLocalParams'\n";
449 runASingleTest
($sTarget, $sLocalParams);
453 # printOnLibrary($sTarget);
454 # print " suppressed, not in libs2test.txt\n";
461 # ------------------------------------------------------------------------------
466 # my $sLogFile = shift; # "buildall_$$.out";
468 my $filename = "libs2test.txt";
471 open(LIBS2TEST
, $filename) || die "can't open $filename\n";
473 while($line = <LIBS2TEST
>)
480 $line = substr($line, 0, -1);
486 ($path, $file) = interpretLine
($line);
487 runTestsOnPath
($path, $file, $params);
491 print "\nComplete logging information will be found in dir: ".$g_sTempDir."dmake_out_$$/\n";
493 if ($nGlobalFailures > 0)
495 print "\nFailures over all occured: $nGlobalFailures\n";
496 print "\nPASSED FAILED.\n";
500 print "\nPASSED OK.\n";
504 # ------------------------------------------------------------------------------