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 "OS2" ) {
155 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "c:${FS}tmp${FS}";
158 if ( $gui eq "UNX" ) {
160 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "${FS}tmp${FS}";
163 print STDERR
"buildall.pl: unkown platform\n";
167 # ------------------------------------------------------------------------------
172 $oldstr =~ s/^\s*(.*?)\s*$/$1/;
176 # ------------------------------------------------------------------------------
180 if ($OSNAME eq "linux" || $OSNAME eq "solaris")
182 return "lib" . $sFile . ".so";
184 if ($OSNAME eq "MSWin32" || $OSNAME eq "OS2")
186 return $sFile . ".dll";
190 # ------------------------------------------------------------------------------
193 my $sFailureFile = shift;
195 if (! open(IN
, $sFailureFile))
197 print "ERROR: Can't open output file $sFailureFile\n";
208 # ------------------------------------------------------------------------------
209 sub giveOutFailures
($$)
212 my $sFailureFile = shift;
219 if (! open(IN
, $sFailureFile))
221 print "ERROR: Can't open output file $sFailureFile\n";
225 my $bStartUnitTest = 0;
229 if ( $line =~ /^- start unit test/)
236 if ($bStartUnitTest == 0)
238 print "\nFailure: Unit test not started. Maybe compiler error.\n";
239 giveOutAll
($sFailureFile);
245 open(IN
, $sFailureFile);
246 # check if testshl2 was started
251 # handling of the states
252 if ( $line =~ /^\# -- BEGIN:/)
256 elsif ( $line =~ /^\# -- END:/)
274 # extra return for a better output
275 print "\nFailures occured: $nFailures\n";
276 print "The whole output can be found in $sFailureFile\n";
280 $nGlobalFailures += $nFailures;
283 # ------------------------------------------------------------------------------
284 sub printOnLibrary
($)
287 print " on library: " . getLibName
($sTarget);
289 # ------------------------------------------------------------------------------
290 sub runASingleTest
($$)
294 my $dmake = "dmake $params";
296 my $sLogPath = $g_sTempDir . "dmake_out_$$";
298 my $sLogFile = $sLogPath . "/" . $sTarget . ".out";
300 # due to the fact, a library name in one project is distinct, we should remember all already run through libraries and
301 # supress same libraries, if they occur one more.
303 if (exists $libraryRunThrough{getLibName
($sTarget)})
308 printOnLibrary
($sTarget);
311 # redirect tcsh ">&" (stdout, stderr)
312 # redirect 4nt ">" (stdout), "2>" (stderr)
313 # print "OSNAME: $OSNAME\n";
314 # LLA: redirect check canceled, seems to be not work as I want.
316 # if ($OSNAME eq "linux" || $OSNAME eq "solaris")
318 # # print "UNIX, linux or solaris\n";
319 # $redirect = '>>&!' . $sLogFile;
323 # if ($OSNAME eq "MSWin32" || $OSNAME eq "OS2")
326 # $redirect = ">>$sLogFile 2>>$sLogFile";
329 # print "$dmake $redirect\n";
331 # LLA: so system does also not work as I imagine
332 # system("$dmake $redirect");
334 # LLA: next check, use open with pipe
337 if (! open( LOGFILE
, '>' . "$sLogFile"))
339 print "ERROR: can't open logfile: $sLogFile\n";
345 if (! open( DMAKEOUTPUT
, "$dmake 2>&1 |"))
347 print "ERROR: can't open dmake\n";
350 while ($line = <DMAKEOUTPUT
>)
353 print LOGFILE
"$line\n";
358 giveOutFailures
($sTarget, $sLogFile);
360 $libraryRunThrough{getLibName
($sTarget)} = "done";
363 # ------------------------------------------------------------------------------
371 if ($line =~ /^\#/ || $line =~ /^$/)
373 # remark or empty line
377 # special format, $file == $path
378 ($path, $file) = split(/;/, $line);
388 # ------------------------------------------------------------------------------
389 sub runTestsOnPath
($$$)
396 if (!$path || $path eq "")
398 # DBG: print "empty path '$path'\n";
401 if (!$file || $file eq "")
403 # DBG: print "empty file '$file'\n";
407 # print "File: '$file', Path: '$path'\n";
408 print "Work in directory: $path\n";
409 my $newpath = $cwd . $FS . $path;
410 # print "chdir to $newpath\n";
412 my $error = chdir($newpath);
415 # run through the hole makefile.mk and check if SHL<D>TARGET = ... exist, for every target call "dmake test<D>"
418 if (! open(MAKEFILE_MK
, "makefile.mk"))
420 print "ERROR: can't open makefile.mk in path: $newpath\n";
421 print "please check your libs2test.txt file in qa directory.\n";
428 while($line = <MAKEFILE_MK
>)
432 if ($line =~ /SHL(\d)TARGET=(.*)/)
437 # DBG: print "test$number is lib: $target\n";
438 $sLocalParams = $params . " "; # append a whitespace, so we can check if 'test' exist without additional digits
439 $sLocalParams =~ s/test\s/test$nNumber/;
440 # DBG: print "$sLocalParams\n";
441 if ($bBuildAll == 1 ||
444 # print "runASingleTest on Target: $sTarget 'dmake $sLocalParams'\n";
445 runASingleTest
($sTarget, $sLocalParams);
449 # printOnLibrary($sTarget);
450 # print " suppressed, not in libs2test.txt\n";
457 # ------------------------------------------------------------------------------
462 # my $sLogFile = shift; # "buildall_$$.out";
464 my $filename = "libs2test.txt";
467 open(LIBS2TEST
, $filename) || die "can't open $filename\n";
469 while($line = <LIBS2TEST
>)
476 $line = substr($line, 0, -1);
482 ($path, $file) = interpretLine
($line);
483 runTestsOnPath
($path, $file, $params);
487 print "\nComplete logging information will be found in dir: ".$g_sTempDir."dmake_out_$$/\n";
489 if ($nGlobalFailures > 0)
491 print "\nFailures over all occured: $nGlobalFailures\n";
492 print "\nPASSED FAILED.\n";
496 print "\nPASSED OK.\n";
500 # ------------------------------------------------------------------------------