1 eval 'exec perl -wS $0 ${1+"$@"}'
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # This file incorporates work covered by the following license notice:
12 # Licensed to the Apache Software Foundation (ASF) under one or more
13 # contributor license agreements. See the NOTICE file distributed
14 # with this work for additional information regarding copyright
15 # ownership. The ASF licenses this file to you under the Apache
16 # License, Version 2.0 (the "License"); you may not use this file
17 # except in compliance with the License. You may obtain a copy of
18 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
33 sub initEnvironment
();
35 sub checkForKillobj
();
41 my $nGlobalFailures = 0;
43 my %libraryRunThrough;
46 # LLA: this does not exist, ... use a little bit simpler method.
47 # use File::Temp qw/ :POSIX /;
54 $params = "test "; # debug=t TESTOPTADD=\"-boom\" TESTOPTADD=\"-noerroronexit\"
57 # my $sLocalParams = $params;
58 # $sLocalParams =~ s/test\s/test$nNumber /;
59 # print "Testparams: $sLocalParams\n";
66 if (checkForKillobj
() == 1)
70 elsif (checkARGVFor
("buildall") == 1)
77 # always run test, but envelope the other in 'TESTOPT="..."'
78 $params = "test TESTOPT=\"";
80 foreach $param (@ARGV)
82 $params = $params . " " . $param;
84 $params = $params . "\"";
86 print "User defined ";
89 print "parameters for dmake: $params\n";
94 # ------------------------------------------------------------------------------
97 my $sCheckValue = shift;
100 foreach $sLocalParam (@ARGV)
102 if ($sLocalParam =~ /^${sCheckValue}$/)
110 # ------------------------------------------------------------------------------
111 sub checkForKillobj
()
115 foreach $sLocalParam (@ARGV)
117 if ($sLocalParam =~ /^killobj$/)
126 # ------------------------------------------------------------------------------
127 sub initEnvironment
()
130 # no error output in forms of message boxes
131 $ENV{'DISABLE_SAL_DBGBOX'}="t";
134 if ( $os eq "WNT" ) {
136 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "c:${FS}tmp${FS}";
141 $g_sTempDir = $ENV{TMP
} ?
"$ENV{TMP}${FS}" : "${FS}tmp${FS}";
144 print STDERR
"buildall.pl: unknown platform\n";
148 # ------------------------------------------------------------------------------
153 $oldstr =~ s/^\s*(.*?)\s*$/$1/;
157 # ------------------------------------------------------------------------------
161 if ($OSNAME eq "linux" || $OSNAME eq "solaris")
163 return "lib" . $sFile . ".so";
165 if ($OSNAME eq "MSWin32")
167 return $sFile . ".dll";
171 # ------------------------------------------------------------------------------
174 my $sFailureFile = shift;
176 if (! open(IN
, $sFailureFile))
178 print "ERROR: Can't open output file $sFailureFile\n";
189 # ------------------------------------------------------------------------------
190 sub giveOutFailures
($$)
193 my $sFailureFile = shift;
200 if (! open(IN
, $sFailureFile))
202 print "ERROR: Can't open output file $sFailureFile\n";
206 my $bStartUnitTest = 0;
210 if ( $line =~ /^- start unit test/)
217 if ($bStartUnitTest == 0)
219 print "\nFailure: Unit test not started. Maybe compiler error.\n";
220 giveOutAll
($sFailureFile);
226 open(IN
, $sFailureFile);
227 # check if testshl2 was started
232 # handling of the states
233 if ( $line =~ /^\# -- BEGIN:/)
237 elsif ( $line =~ /^\# -- END:/)
255 # extra return for a better output
256 print "\nFailures occurred: $nFailures\n";
257 print "The whole output can be found in $sFailureFile\n";
261 $nGlobalFailures += $nFailures;
264 # ------------------------------------------------------------------------------
265 sub printOnLibrary
($)
268 print " on library: " . getLibName
($sTarget);
270 # ------------------------------------------------------------------------------
271 sub runASingleTest
($$)
275 my $dmake = "dmake $params";
277 my $sLogPath = $g_sTempDir . "dmake_out_$$";
279 my $sLogFile = $sLogPath . "/" . $sTarget . ".out";
281 # due to the fact, a library name in one project is distinct, we should remember all already run through libraries and
282 # supress same libraries, if they occur one more.
284 if (exists $libraryRunThrough{getLibName
($sTarget)})
289 printOnLibrary
($sTarget);
292 # redirect tcsh ">&" (stdout, stderr)
293 # redirect 4nt ">" (stdout), "2>" (stderr)
294 # print "OSNAME: $OSNAME\n";
295 # LLA: redirect check canceled, seems to be not work as I want.
297 # if ($OSNAME eq "linux" || $OSNAME eq "solaris")
299 # # print "UNIX, linux or solaris\n";
300 # $redirect = '>>&!' . $sLogFile;
304 # if ($OSNAME eq "MSWin32")
307 # $redirect = ">>$sLogFile 2>>$sLogFile";
310 # print "$dmake $redirect\n";
312 # LLA: so system does also not work as I imagine
313 # system("$dmake $redirect");
315 # LLA: next check, use open with pipe
318 if (! open( LOGFILE
, '>' . "$sLogFile"))
320 print "ERROR: can't open logfile: $sLogFile\n";
326 if (! open( DMAKEOUTPUT
, "$dmake 2>&1 |"))
328 print "ERROR: can't open dmake\n";
331 while ($line = <DMAKEOUTPUT
>)
334 print LOGFILE
"$line\n";
339 giveOutFailures
($sTarget, $sLogFile);
341 $libraryRunThrough{getLibName
($sTarget)} = "done";
344 # ------------------------------------------------------------------------------
352 if ($line =~ /^\#/ || $line =~ /^$/)
354 # remark or empty line
358 # special format, $file == $path
359 ($path, $file) = split(/;/, $line);
369 # ------------------------------------------------------------------------------
370 sub runTestsOnPath
($$$)
377 if (!$path || $path eq "")
379 # DBG: print "empty path '$path'\n";
382 if (!$file || $file eq "")
384 # DBG: print "empty file '$file'\n";
388 # print "File: '$file', Path: '$path'\n";
389 print "Work in directory: $path\n";
390 my $newpath = $cwd . $FS . $path;
391 # print "chdir to $newpath\n";
393 my $error = chdir($newpath);
396 # run through the hole makefile.mk and check if SHL<D>TARGET = ... exist, for every target call "dmake test<D>"
399 if (! open(MAKEFILE_MK
, "makefile.mk"))
401 print "ERROR: can't open makefile.mk in path: $newpath\n";
402 print "please check your libs2test.txt file in qa directory.\n";
409 while($line = <MAKEFILE_MK
>)
413 if ($line =~ /SHL(\d)TARGET=(.*)/)
418 # DBG: print "test$number is lib: $target\n";
419 $sLocalParams = $params . " "; # append a whitespace, so we can check if 'test' exist without additional digits
420 $sLocalParams =~ s/test\s/test$nNumber/;
421 # DBG: print "$sLocalParams\n";
422 if ($bBuildAll == 1 ||
425 # print "runASingleTest on Target: $sTarget 'dmake $sLocalParams'\n";
426 runASingleTest
($sTarget, $sLocalParams);
430 # printOnLibrary($sTarget);
431 # print " suppressed, not in libs2test.txt\n";
438 # ------------------------------------------------------------------------------
443 # my $sLogFile = shift; # "buildall_$$.out";
445 my $filename = "libs2test.txt";
448 open(LIBS2TEST
, $filename) || die "can't open $filename\n";
450 while($line = <LIBS2TEST
>)
457 $line = substr($line, 0, -1);
463 ($path, $file) = interpretLine
($line);
464 runTestsOnPath
($path, $file, $params);
468 print "\nComplete logging information will be found in dir: ".$g_sTempDir."dmake_out_$$/\n";
470 if ($nGlobalFailures > 0)
472 print "\nFailures over all occurred: $nGlobalFailures\n";
473 print "\nPASSED FAILED.\n";
477 print "\nPASSED OK.\n";
481 # ------------------------------------------------------------------------------