2000-02-07 02:17:39 +00:00
#!/usr/bin/perl
2001-12-15 00:11:16 +00:00
# -*- Mode: perl; indent-tabs-mode: nil -*-
2004-04-13 23:48:24 +00:00
# vim:sw=4:ts=8:et:ai:
2002-03-25 08:26:34 +00:00
#
2000-03-21 02:52:34 +00:00
# Requires: tinder-defaults.pl
#
# Intent: This is becoming a general-purpose tinderbox
# script, specific uses (mozilla, commercial, etc.) should
# set variables and then call into this script.
#
# Status: In the process of re-arranging things so a commercial
# version can re-use this script.
#
2000-02-07 02:17:39 +00:00
2000-07-30 19:59:28 +00:00
require 5.003 ;
2000-02-07 02:17:39 +00:00
use Sys::Hostname ;
2000-02-25 21:40:56 +00:00
use strict ;
2000-03-22 00:18:06 +00:00
use POSIX qw( sys_wait_h strftime ) ;
use Cwd ;
use File::Basename ; # for basename();
2002-03-13 08:08:52 +00:00
use File::Path ; # for rmtree();
use Config ; # for $Config{sig_name} and $Config{sig_num}
2002-03-29 04:25:12 +00:00
use File::Find ( ) ;
2003-03-01 00:55:20 +00:00
use File::Copy ;
2001-09-25 01:36:11 +00:00
2004-04-13 23:48:24 +00:00
$ ::UtilsVersion = '$Revision: 1.256 $ ' ;
2000-02-07 03:13:59 +00:00
2000-03-21 02:52:34 +00:00
package TinderUtils ;
2001-07-16 20:23:52 +00:00
#
2001-12-15 10:19:25 +00:00
# Optional, external, post-mozilla build
2001-07-16 20:23:52 +00:00
#
require "post-mozilla.pl" if - e "post-mozilla.pl" ;
2001-09-25 01:36:11 +00:00
#
# Test for Time::HiRes, for ms resolution from gettimeofday().
#
require "gettime.pl" ;
2001-07-16 20:23:52 +00:00
2003-04-09 23:59:52 +00:00
#
# For performance tests, we need the following perl modules installed:
# (MacOSX, Linux, Win2k):
#
# Time::HiRes for higher timer resolution
# Bundle::LWP for http (to report data to graph)
#
# The "CPAN" way of installing this is to start here:
2003-04-10 00:52:09 +00:00
# % sudo perl -MCPAN -e shell
2003-04-09 23:59:52 +00:00
# <take defaults..>
# cpan> install Time::HiRes
# [...]
# cpan> install Bundle::LWP
#
2003-04-21 08:28:57 +00:00
my $ co_time_str = 0 ; # Global, let tests send cvs co time to graph server.
2000-03-22 00:18:06 +00:00
sub Setup {
2002-03-25 08:26:34 +00:00
InitVars ( ) ;
my $ args = ParseArgs ( ) ;
LoadConfig ( ) ;
ApplyArgs ( $ args ) ; # Apply command-line arguments after the config file.
GetSystemInfo ( ) ;
SetupEnv ( ) ;
SetupPath ( ) ;
2004-03-24 03:37:38 +00:00
ValidateSettings ( ) ; # Perform some basic validation on settings
2000-03-22 00:18:06 +00:00
}
sub Build {
2002-03-25 08:26:34 +00:00
#my () = @_;
BuildIt ( ) ;
2000-03-22 00:18:06 +00:00
}
sub PrintUsage {
die << END_USAGE
usage: $ 0 [ options ]
Options:
- - depend Build depend ( must have this option or clobber ) .
- - clobber Build clobber .
- - example - config Print an example 'tinder-config.pl' .
- - display DISPLAY Set DISPLAY for tests .
- - once Do not loop .
- - noreport Do not report status to tinderbox server .
- - nofinalreport Do not report final status , only start status .
- - notest Do not run smoke tests .
- - testonly Only run the smoke tests ( do not pull or build ) .
- - notimestamp Do not pull by date .
- tag TREETAG Pull by tag ( - r TREETAG ) .
- t TREENAME The name of the tree
2003-06-26 01:06:48 +00:00
- - mozconfig FILENAME Provide a mozconfig file for $ Settings:: moz_client_mk
2000-03-22 00:18:06 +00:00
- - version Print the version number ( same as cvs revision ) .
- - help
More details:
To get started , run '$0 --example-config' .
END_USAGE
}
2000-03-21 02:52:34 +00:00
2000-03-22 00:18:06 +00:00
sub ParseArgs {
PrintUsage ( ) if $# ARGV == - 1 ;
my $ args = { } ;
2000-07-30 19:59:28 +00:00
my $ arg ;
while ( $ arg = shift @ ARGV ) {
$ args - > { BuildDepend } = 0 , next if $ arg eq '--clobber' ;
$ args - > { BuildDepend } = 1 , next if $ arg eq '--depend' ;
2000-03-22 00:18:06 +00:00
TinderUtils:: PrintExampleConfig ( ) , exit if $ arg eq '--example-config' ;
PrintUsage ( ) , exit if $ arg eq '--help' or $ arg eq '-h' ;
$ args - > { ReportStatus } = 0 , next if $ arg eq '--noreport' ;
$ args - > { ReportFinalStatus } = 0 , next if $ arg eq '--nofinalreport' ;
2002-12-20 06:04:39 +00:00
$ args - > { RunMozillaTests } = 0 , next if $ arg eq '--notest' ;
2000-03-22 00:18:06 +00:00
$ args - > { TestOnly } = 1 , next if $ arg eq '--testonly' ;
$ args - > { BuildOnce } = 1 , next if $ arg eq '--once' ;
$ args - > { UseTimeStamp } = 0 , next if $ arg eq '--notimestamp' ;
2002-03-25 08:26:34 +00:00
2003-01-08 02:50:57 +00:00
# debug post-mozilla.pl
$ args - > { SkipMozilla } = 1 , next if $ arg eq '--skip-mozilla' ;
2000-03-22 00:18:06 +00:00
my % args_with_options = qw(
- - display DisplayServer
- tag BuildTag
- t BuildTree
- - mozconfig MozConfigFileName
) ;
if ( defined $ args_with_options { $ arg } ) {
my $ arg_arg = shift @ ARGV ;
PrintUsage ( ) if $ arg_arg eq '' or $ arg_arg =~ /^-/ ;
$ args - > { $ args_with_options { $ arg } } = $ arg_arg ;
} elsif ( $ arg eq '--version' or $ arg eq '-v' ) {
die "$0: version" . substr ( $ ::Version , 9 , 6 ) . "\n" ;
} else {
warn "Error: Unknown option: $arg\n" ;
PrintUsage ( ) ;
}
}
return $ args ;
}
sub ApplyArgs {
my ( $ args ) = @ _ ;
my ( $ variable_name , $ value ) ;
while ( ( $ variable_name , $ value ) = each % { $ args } ) {
eval "\$Settings::$variable_name = \"$value\";" ;
2002-03-25 08:26:34 +00:00
}
2000-03-22 00:18:06 +00:00
}
2004-03-24 03:37:38 +00:00
sub ValidateSettings {
# Lowercase the LogCompression and LogEncoding variables for convenience.
$ Settings:: LogCompression = lc $ Settings:: LogCompression ;
$ Settings:: LogEncoding = lc $ Settings:: LogEncoding ;
# Make sure LogCompression and LogEncoding are set to valid values.
if ( $ Settings:: LogCompression !~ /^(bzip2|gzip)?$/ ) {
warn "Invalid value for LogCompression: $Settings::LogCompression.\n" ;
exit ;
}
if ( $ Settings:: LogEncoding !~ /^(base64|uuencode)?$/ ) {
warn "Invalid value for LogEncoding: $Settings::LogEncoding.\n" ;
exit ;
}
# If LogEncoding is set to 'base64', ensure we have the MIME::Base64
# module before we go through the entire build.
if ( $ Settings:: LogEncoding eq 'base64' ) {
eval "use MIME::Base64 ();" ;
if ( $@ ) {
warn "LogEncoding set to base64 but the MIME::Base64 module could not be loaded.\n" ;
warn "The error message was:\n\n" ;
warn $@ ;
exit ;
}
}
# If LogCompression is set, make sure LogEncoding is set or else the log
# will not be transferred properly.
if ( $ Settings:: LogCompression ne '' && $ Settings:: LogEncoding eq '' ) {
warn "LogEncoding must be set if LogCompression is set.\n" ;
exit ;
}
}
2000-03-22 00:18:06 +00:00
2002-03-25 08:26:34 +00:00
my $ tinder_defaults = "tinder-defaults.pl" ;
sub InitVars {
2000-03-21 02:52:34 +00:00
local $ _ ;
for ( @ ARGV ) {
2002-03-25 08:26:34 +00:00
# Save DATA section for printing the example.
return if /^--example-config$/ ;
2000-03-21 02:52:34 +00:00
}
no strict 'vars' ;
2002-03-25 08:26:34 +00:00
open DEFAULTS , $ tinder_defaults or print "can't open $tinder_defaults, $?\n" ;
2000-03-21 02:52:34 +00:00
while ( <DEFAULTS> ) {
2002-03-25 08:26:34 +00:00
package Settings ;
#warn "config:$_";
eval ;
}
close DEFAULTS ;
}
sub PrintExampleConfig {
2000-03-21 02:52:34 +00:00
local $ _ ;
print "#- tinder-config.pl - Tinderbox configuration file.\n" ;
print "#- Uncomment the variables you need to set.\n" ;
print "#- The default values are the same as the commented variables.\n" ;
print "\n" ;
2002-03-25 08:26:34 +00:00
open DEFAULTS , $ tinder_defaults or print "can't open $tinder_defaults, $!\n" ;
2000-03-21 02:52:34 +00:00
while ( <DEFAULTS> ) {
2002-03-25 08:26:34 +00:00
s/^\$/\#\$/ ;
print ;
2000-03-21 02:52:34 +00:00
}
2002-03-25 08:26:34 +00:00
close DEFAULTS ;
2000-03-21 02:52:34 +00:00
}
2000-03-22 00:18:06 +00:00
2000-02-07 02:17:39 +00:00
sub GetSystemInfo {
2000-02-25 21:40:56 +00:00
$ Settings:: OS = `uname -s` ;
my $ os_ver = `uname -r` ;
$ Settings:: CPU = `uname -m` ;
2000-04-18 07:03:15 +00:00
#$Settings::ObjDir = '';
2000-02-25 21:40:56 +00:00
my $ build_type = $ Settings:: BuildDepend ? 'Depend' : 'Clobber' ;
my $ host = :: hostname ( ) ;
2001-12-21 03:05:28 +00:00
$ host = $ 1 if $ host =~ /(.*?)\./ ;
2000-02-25 21:40:56 +00:00
chomp ( $ Settings:: OS , $ os_ver , $ Settings:: CPU , $ host ) ;
2002-03-25 08:26:34 +00:00
# Redirecting stderr to stdout works on *nix, winnt, but not on win98.
2002-03-13 08:04:28 +00:00
$ Settings:: TieStderr = '2>&1' ;
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'AIX' ) {
my $ osAltVer = `uname -v` ;
chomp ( $ osAltVer ) ;
$ os_ver = "$osAltVer.$os_ver" ;
2000-02-07 02:17:39 +00:00
}
2002-03-25 08:26:34 +00:00
2000-02-25 21:40:56 +00:00
$ Settings:: OS = 'BSD_OS' if $ Settings:: OS eq 'BSD/OS' ;
$ Settings:: OS = 'IRIX' if $ Settings:: OS eq 'IRIX64' ;
2002-03-25 08:26:34 +00:00
2001-12-21 03:05:28 +00:00
if ( $ Settings:: OS eq 'SCO_SV' ) {
$ Settings:: OS = 'SCOOS' ;
$ os_ver = '5.0' ;
}
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'QNX' ) {
$ os_ver = `uname -v` ;
chomp ( $ os_ver ) ;
$ os_ver =~ s/^([0-9])([0-9]*)$/$1.$2/ ;
}
2002-03-13 08:04:28 +00:00
if ( $ Settings:: OS =~ /^CYGWIN_(.*?)-(.*)$/ ) {
# the newer cygwin apparently has different output for 'uname'
# e.g., CYGWIN_98-4.10 == win98SE, and CYGWIN_NT-5.0 == win2k
$ Settings:: OS = 'WIN' . $ 1 ;
$ os_ver = $ 2 ;
$ host =~ tr /A-Z/ a - z / ;
}
if ( $ Settings:: OS =~ /^WIN/ ) {
2001-12-21 06:52:19 +00:00
$ host =~ tr /A-Z/ a - z / ;
2002-04-11 01:42:41 +00:00
$ Settings:: TieStderr = "" if $ Settings:: OS eq 'WIN98' ;
2001-12-21 06:52:19 +00:00
}
2002-03-25 08:26:34 +00:00
2002-03-13 08:04:28 +00:00
$ Settings:: DirName = "${Settings::OS}_${os_ver}_$build_type" ;
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS ${os_ver} $host $build_type" ;
2002-03-25 08:26:34 +00:00
2002-04-13 05:27:01 +00:00
$ Settings:: DistBin = "dist/bin" ;
2000-02-25 21:40:56 +00:00
# Make the build names reflect architecture/OS
2002-03-25 08:26:34 +00:00
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'AIX' ) {
2000-03-16 22:29:48 +00:00
# $Settings::BuildName set above.
2000-02-25 21:40:56 +00:00
}
if ( $ Settings:: OS eq 'BSD_OS' ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "BSD/OS $os_ver $host $build_type" ;
2000-02-25 21:40:56 +00:00
}
2002-03-25 20:25:15 +00:00
if ( $ Settings:: OS eq 'Darwin' ) {
2002-12-21 00:08:26 +00:00
$ Settings:: BuildName = "MacOSX Darwin $os_ver $host $build_type" ;
2002-03-25 20:25:15 +00:00
}
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'FreeBSD' ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS/$Settings::CPU $os_ver $host $build_type" ;
2000-02-25 21:40:56 +00:00
}
if ( $ Settings:: OS eq 'HP-UX' ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS $os_ver $host $build_type" ;
2000-02-25 21:40:56 +00:00
}
if ( $ Settings:: OS eq 'IRIX' ) {
2000-03-16 22:29:48 +00:00
# $Settings::BuildName set above.
2000-02-25 21:40:56 +00:00
}
if ( $ Settings:: OS eq 'Linux' ) {
if ( $ Settings:: CPU eq 'alpha' or $ Settings:: CPU eq 'sparc' ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS/$Settings::CPU $os_ver $host $build_type" ;
2000-02-25 21:40:56 +00:00
} elsif ( $ Settings:: CPU eq 'armv4l' or $ Settings:: CPU eq 'sa110' ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS/arm $os_ver $host $build_type" ;
2000-02-25 21:40:56 +00:00
} elsif ( $ Settings:: CPU eq 'ppc' ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS/$Settings::CPU $os_ver $host $build_type" ;
2001-05-19 07:20:26 +00:00
} elsif ( ( $ Settings:: CPU eq 'i686' ) or ( $ Settings:: CPU eq 'i586' ) ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS $host $build_type" ;
2000-02-25 21:40:56 +00:00
} else {
2000-03-16 22:29:48 +00:00
# $Settings::BuildName set above
2000-02-25 21:40:56 +00:00
}
}
if ( $ Settings:: OS eq 'NetBSD' ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS/$Settings::CPU $os_ver $host $build_type" ;
2000-02-25 21:40:56 +00:00
}
if ( $ Settings:: OS eq 'OSF1' ) {
# Assumes 4.0D for now.
}
if ( $ Settings:: OS eq 'QNX' ) {
}
if ( $ Settings:: OS eq 'SunOS' ) {
if ( $ Settings:: CPU eq 'i86pc' ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS/i386 $os_ver $host $build_type" ;
2000-02-25 21:40:56 +00:00
} else {
$ Settings:: OSVerMajor = substr ( $ os_ver , 0 , 1 ) ;
if ( $ Settings:: OSVerMajor ne '4' ) {
2002-03-26 23:28:00 +00:00
$ Settings:: BuildName = "$Settings::OS/sparc $os_ver $host $build_type" ;
2000-02-25 21:40:56 +00:00
}
}
2000-02-07 02:17:39 +00:00
}
2000-05-04 07:30:45 +00:00
$ Settings:: BuildName . = " $Settings::BuildNameExtra" ;
2000-02-07 02:17:39 +00:00
}
2000-02-07 03:13:59 +00:00
sub LoadConfig {
2000-02-25 21:40:56 +00:00
if ( - r 'tinder-config.pl' ) {
2002-03-25 08:26:34 +00:00
no strict 'vars' ;
open CONFIG , 'tinder-config.pl' or
print "can't open tinder-config.pl, $?\n" ;
while ( <CONFIG> ) {
package Settings ;
#warn "config:$_";
eval ;
}
close CONFIG ;
2000-02-25 21:40:56 +00:00
} else {
warn "Error: Need tinderbox config file, tinder-config.pl\n" ;
warn " To get started, run the following,\n" ;
warn " $0 --example-config > tinder-config.pl\n" ;
exit ;
}
2000-02-07 03:13:59 +00:00
}
2003-03-16 08:07:17 +00:00
my $ objdir ;
2000-02-07 02:34:30 +00:00
sub SetupEnv {
2000-02-25 21:40:56 +00:00
umask 0 ;
2001-06-16 06:30:22 +00:00
2002-03-25 08:26:34 +00:00
# Assume this file lives in the base dir, this will
# avoid human error from setting this manually.
$ Settings:: BaseDir = get_system_cwd ( ) ;
2001-06-16 06:30:22 +00:00
2000-02-28 23:51:02 +00:00
my $ topsrcdir = "$Settings::BaseDir/$Settings::DirName/mozilla" ;
2003-03-16 08:07:17 +00:00
$ objdir = "$topsrcdir/${Settings::ObjDir}" ;
2000-08-01 23:17:59 +00:00
2004-02-12 22:06:59 +00:00
if ( $ Settings:: ReleaseBuild ) {
$ ENV { BUILD_OFFICIAL } = 1 ;
$ ENV { MOZILLA_OFFICIAL } = 1 ;
2004-03-31 23:54:26 +00:00
if ( $ Settings:: OS =~ /^WIN/ ) {
$ ENV { MOZ_PROFILE } = 1 ;
$ ENV { PDBFILE } = "NONE" ;
}
2004-02-12 22:06:59 +00:00
}
2002-03-25 08:26:34 +00:00
if ( $ Settings:: ObjDir ne '' ) {
2002-09-15 08:12:41 +00:00
$ ENV { LD_LIBRARY_PATH } = "$topsrcdir/${Settings::ObjDir}/$Settings::DistBin:" . "$ENV{LD_LIBRARY_PATH}" ;
2002-03-25 08:26:34 +00:00
} else {
2003-02-20 21:25:22 +00:00
$ ENV { LD_LIBRARY_PATH } = "$topsrcdir/$Settings::DistBin:" . ( $ ENV { LD_LIBRARY_PATH } || "" ) ;
2002-04-13 05:27:01 +00:00
}
# MacOSX needs this set.
if ( $ Settings:: OS eq 'Darwin' ) {
$ ENV { DYLD_LIBRARY_PATH } = "$ENV{LD_LIBRARY_PATH}" ;
2002-03-25 08:26:34 +00:00
}
2000-08-01 23:17:59 +00:00
2002-04-13 05:27:01 +00:00
$ ENV { LIBPATH } = "$topsrcdir/${Settings::ObjDir}/$Settings::DistBin:"
2003-02-20 21:20:21 +00:00
. ( $ ENV { LIBPATH } || "" ) ;
2002-05-22 08:54:18 +00:00
# BeOS requires that components/ be in the library search path per bug 51655
2002-04-13 05:27:01 +00:00
$ ENV { LIBRARY_PATH } = "$topsrcdir/${Settings::ObjDir}/$Settings::DistBin:"
2002-05-22 08:54:18 +00:00
. "$topsrcdir/${Settings::ObjDir}/$Settings::DistBin/components:"
2003-02-20 21:20:21 +00:00
. ( $ ENV { LIBRARY_PATH } || "" ) ;
2002-04-13 05:27:01 +00:00
$ ENV { ADDON_PATH } = "$topsrcdir/${Settings::ObjDir}/$Settings::DistBin:"
2003-02-20 21:20:21 +00:00
. ( $ ENV { ADDON_PATH } || "" ) ;
2002-04-13 05:27:01 +00:00
$ ENV { MOZILLA_FIVE_HOME } = "$topsrcdir/${Settings::ObjDir}/$Settings::DistBin" ;
2000-02-25 21:40:56 +00:00
$ ENV { DISPLAY } = $ Settings:: DisplayServer ;
2002-03-25 08:26:34 +00:00
$ ENV { MOZCONFIG } = "$Settings::BaseDir/$Settings::MozConfigFileName"
if $ Settings:: MozConfigFileName ne '' and - e $ Settings:: MozConfigFileName ;
2001-12-08 03:02:09 +00:00
2002-03-25 08:26:34 +00:00
# Mail test needs build-time env set. -mcafee
if ( $ Settings:: MailBloatTest ) {
$ ENV { BUILD_MAIL_SMOKETEST } = "1" ;
}
2003-02-01 01:16:37 +00:00
# Codesighs/codesize test needs this to pull the right stuff.
if ( $ Settings:: CodesizeTest or $ Settings:: EmbedCodesizeTest ) {
$ ENV { MOZ_MAPINFO } = "1" ;
}
2000-02-07 02:34:30 +00:00
}
sub SetupPath {
2000-02-25 21:40:56 +00:00
#print "Path before: $ENV{PATH}\n";
2002-04-13 05:27:01 +00:00
$ ENV { PATH } . = ":$Settings::BaseDir/$Settings::DirName/mozilla/${Settings::ObjDir}/$Settings::DistBin" ;
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'AIX' ) {
$ ENV { PATH } = "/builds/local/bin:$ENV{PATH}:/usr/lpp/xlC/bin" ;
$ Settings:: ConfigureArgs . = '--x-includes=/usr/include/X11 '
2002-03-25 08:26:34 +00:00
. '--x-libraries=/usr/lib --disable-shared' ;
2001-12-21 03:05:28 +00:00
$ Settings:: ConfigureEnvArgs || = 'CC=xlC_r CXX=xlC_r' ;
$ Settings:: Compiler || = 'xlC_r' ;
2000-02-25 21:40:56 +00:00
$ Settings:: NSPRArgs . = 'NS_USE_NATIVE=1 USE_PTHREADS=1' ;
2000-02-07 02:34:30 +00:00
}
2002-03-25 08:26:34 +00:00
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'BSD_OS' ) {
2002-05-13 03:59:31 +00:00
$ ENV { PATH } = "/usr/contrib/bin:/usr/contrib/gnome/bin:/usr/bin:$ENV{PATH}" ;
2003-11-04 22:14:12 +00:00
$ ENV { LD_LIBRARY_PATH } = "/usr/contrib/lib:/usr/contrib/gnome/lib:$ENV{LD_LIBRARY_PATH}" ;
2001-05-11 02:28:23 +00:00
#$Settings::ConfigureArgs .= '--disable-shared';
2001-12-21 03:05:28 +00:00
#$Settings::ConfigureEnvArgs ||= 'CC=shlicc2 CXX=shlicc2';
#$Settings::Compiler ||= 'shlicc2';
#$Settings::mail ||= '/usr/ucb/mail';
2000-02-25 21:40:56 +00:00
# Because ld dies if it encounters -include
2001-12-21 03:05:28 +00:00
#$Settings::MakeOverrides ||= 'CPP_PROG_LINK=0 CCF=shlicc2';
2000-02-25 21:40:56 +00:00
$ Settings:: NSPRArgs . = 'NS_USE_GCC=1 NS_USE_NATIVE=' ;
2000-02-07 02:34:30 +00:00
}
2002-03-25 08:26:34 +00:00
2002-03-25 20:25:15 +00:00
if ( $ Settings:: OS eq 'Darwin' ) {
2002-04-05 00:07:06 +00:00
$ ENV { PATH } = "/bin:/usr/bin:/sw/bin:$ENV{PATH}" ;
2002-03-28 00:34:23 +00:00
$ Settings:: ConfigureEnvArgs = 'CC=cc CXX=c++' ;
2002-03-25 20:25:15 +00:00
$ Settings:: Compiler = 'cc' ;
2002-03-28 04:02:24 +00:00
$ Settings:: mail = '/usr/bin/mail' ;
2002-04-12 03:31:33 +00:00
$ Settings:: Make = '/usr/bin/make' ;
2003-01-08 02:50:57 +00:00
# There should be a way of auto-detecting this, for now
# you have to match BuildDebug and --enable-optimize,
# --disable-debug to make things work here.
if ( $ Settings:: BuildDebug ) {
2003-04-23 19:54:55 +00:00
$ Settings:: DistBin = "dist/" . $ Settings:: ProductName . "Debug.app/Contents/MacOS" ;
2003-01-08 02:50:57 +00:00
} else {
2003-04-23 19:54:55 +00:00
$ Settings:: DistBin = "dist/" . $ Settings:: ProductName . ".app/Contents/MacOS" ;
2003-01-08 02:50:57 +00:00
}
2002-03-25 20:25:15 +00:00
}
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'FreeBSD' ) {
$ ENV { PATH } = "/bin:/usr/bin:$ENV{PATH}" ;
if ( $ ENV { HOST } eq 'angelus.mcom.com' ) {
$ Settings:: ConfigureEnvArgs = 'CC=egcc CXX=eg++' ;
$ Settings:: Compiler = 'egcc' ;
}
2001-12-21 03:05:28 +00:00
$ Settings:: mail || = '/usr/bin/mail' ;
2000-02-25 21:40:56 +00:00
}
2002-03-25 08:26:34 +00:00
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'HP-UX' ) {
$ ENV { PATH } = "/opt/ansic/bin:/opt/aCC/bin:/builds/local/bin:"
2002-03-25 08:26:34 +00:00
. "$ENV{PATH}" ;
2000-02-25 21:40:56 +00:00
$ ENV { LPATH } = "/usr/lib:$ENV{LD_LIBRARY_PATH}:/builds/local/lib" ;
$ ENV { SHLIB_PATH } = $ ENV { LPATH } ;
$ Settings:: ConfigureArgs . = '--x-includes=/usr/include/X11 '
2002-03-25 08:26:34 +00:00
. '--x-libraries=/usr/lib --disable-gtktest ' ;
2001-12-21 03:05:28 +00:00
$ Settings:: ConfigureEnvArgs || = 'CC="cc -Ae" CXX="aCC -ext"' ;
$ Settings:: Compiler || = 'cc/aCC' ;
2000-02-25 21:40:56 +00:00
# Use USE_PTHREADS=1 instead of CLASSIC_NSPR if DCE is installed.
$ Settings:: NSPRArgs . = 'NS_USE_NATIVE=1 CLASSIC_NSPR=1' ;
}
2002-03-25 08:26:34 +00:00
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'IRIX' ) {
$ ENV { PATH } = "/opt/bin:$ENV{PATH}" ;
$ ENV { LD_LIBRARY_PATH } . = ':/opt/lib' ;
$ ENV { LD_LIBRARYN32_PATH } = $ ENV { LD_LIBRARY_PATH } ;
2001-12-21 03:05:28 +00:00
$ Settings:: ConfigureEnvArgs || = 'CC=cc CXX=CC CFLAGS="-n32 -O" CXXFLAGS="-n32 -O"' ;
$ Settings:: Compiler || = 'cc/CC' ;
2000-02-25 21:40:56 +00:00
$ Settings:: NSPRArgs . = 'NS_USE_NATIVE=1 USE_PTHREADS=1' ;
}
2002-03-25 08:26:34 +00:00
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'NetBSD' ) {
$ ENV { PATH } = "/bin:/usr/bin:$ENV{PATH}" ;
$ ENV { LD_LIBRARY_PATH } . = ':/usr/X11R6/lib' ;
2001-12-21 03:05:28 +00:00
$ Settings:: ConfigureEnvArgs || = 'CC=egcc CXX=eg++' ;
$ Settings:: Compiler || = 'egcc' ;
$ Settings:: mail || = '/usr/bin/mail' ;
2000-02-25 21:40:56 +00:00
}
2002-03-25 08:26:34 +00:00
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'OSF1' ) {
$ ENV { PATH } = "/usr/gnu/bin:$ENV{PATH}" ;
$ ENV { LD_LIBRARY_PATH } . = ':/usr/gnu/lib' ;
2001-12-21 03:05:28 +00:00
$ Settings:: ConfigureEnvArgs || = 'CC="cc -readonly_strings" CXX="cxx"' ;
$ Settings:: Compiler || = 'cc/cxx' ;
$ Settings:: MakeOverrides || = 'SHELL=/usr/bin/ksh' ;
2000-02-25 21:40:56 +00:00
$ Settings:: NSPRArgs . = 'NS_USE_NATIVE=1 USE_PTHREADS=1' ;
2001-12-21 03:05:28 +00:00
$ Settings:: ShellOverride || = '/usr/bin/ksh' ;
2000-02-25 21:40:56 +00:00
}
2002-03-25 08:26:34 +00:00
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'QNX' ) {
$ ENV { PATH } = "/usr/local/bin:$ENV{PATH}" ;
$ ENV { LD_LIBRARY_PATH } . = ':/usr/X11/lib' ;
$ Settings:: ConfigureArgs . = '--x-includes=/usr/X11/include '
2002-03-25 08:26:34 +00:00
. '--x-libraries=/usr/X11/lib --disable-shared ' ;
2001-12-21 03:05:28 +00:00
$ Settings:: ConfigureEnvArgs || = 'CC="cc -DQNX" CXX="cc -DQNX"' ;
$ Settings:: Compiler || = 'cc' ;
$ Settings:: mail || = '/usr/bin/sendmail' ;
2000-02-25 21:40:56 +00:00
}
2002-03-25 08:26:34 +00:00
2000-02-25 21:40:56 +00:00
if ( $ Settings:: OS eq 'SunOS' ) {
if ( $ Settings:: OSVerMajor eq '4' ) {
$ ENV { PATH } = "/usr/gnu/bin:/usr/local/sun4/bin:/usr/bin:$ENV{PATH}" ;
$ ENV { LD_LIBRARY_PATH } = "/home/motif/usr/lib:$ENV{LD_LIBRARY_PATH}" ;
$ Settings:: ConfigureArgs . = '--x-includes=/home/motif/usr/include/X11 '
2002-03-25 08:26:34 +00:00
. '--x-libraries=/home/motif/usr/lib' ;
2001-12-21 03:05:28 +00:00
$ Settings:: ConfigureEnvArgs || = 'CC="egcc -DSUNOS4" CXX="eg++ -DSUNOS4"' ;
$ Settings:: Compiler || = 'egcc' ;
2000-02-25 21:40:56 +00:00
} else {
$ ENV { PATH } = '/usr/ccs/bin:' . $ ENV { PATH } ;
}
if ( $ Settings:: CPU eq 'i86pc' ) {
$ ENV { PATH } = '/opt/gnu/bin:' . $ ENV { PATH } ;
2002-03-30 02:38:13 +00:00
$ ENV { LD_LIBRARY_PATH } = '/opt/gnu/lib:' . $ ENV { LD_LIBRARY_PATH } ;
2002-03-25 08:26:34 +00:00
if ( $ Settings:: ConfigureEnvArgs eq '' ) {
$ Settings:: ConfigureEnvArgs || = 'CC=egcc CXX=eg++' ;
$ Settings:: Compiler || = 'egcc' ;
}
2000-02-25 21:40:56 +00:00
# Possible NSPR bug... If USE_PTHREADS is defined, then
# _PR_HAVE_ATOMIC_CAS gets defined (erroneously?) and
# libnspr21 does not work.
$ Settings:: NSPRArgs . = 'CLASSIC_NSPR=1 NS_USE_GCC=1 NS_USE_NATIVE=' ;
} else {
# This is utterly lame....
if ( $ ENV { HOST } eq 'fugu' ) {
$ ENV { PATH } = "/tools/ns/workshop/bin:/usrlocal/bin:$ENV{PATH}" ;
$ ENV { LD_LIBRARY_PATH } = '/tools/ns/workshop/lib:/usrlocal/lib:'
2002-03-25 08:26:34 +00:00
. $ ENV { LD_LIBRARY_PATH } ;
2001-12-21 03:05:28 +00:00
$ Settings:: ConfigureEnvArgs || = 'CC=cc CXX=CC' ;
2000-02-25 21:40:56 +00:00
my $ comptmp = `cc -V 2>&1 | head -1` ;
chomp ( $ comptmp ) ;
2001-12-21 03:05:28 +00:00
$ Settings:: Compiler || = "cc/CC \($comptmp\)" ;
2000-02-25 21:40:56 +00:00
$ Settings:: NSPRArgs . = 'NS_USE_NATIVE=1' ;
} else {
$ Settings:: NSPRArgs . = 'NS_USE_GCC=1 NS_USE_NATIVE=' ;
}
if ( $ Settings:: OSVerMajor eq '5' ) {
$ Settings:: NSPRArgs . = ' USE_PTHREADS=1' ;
}
}
2000-02-07 02:34:30 +00:00
}
2002-03-13 08:04:28 +00:00
if ( $ Settings:: OS =~ /^WIN/ ) {
2001-12-21 06:52:19 +00:00
$ Settings:: use_blat = 1 ;
$ Settings:: Compiler = 'cl' ;
}
2002-03-25 08:26:34 +00:00
2000-09-24 20:45:54 +00:00
$ Settings:: ConfigureArgs . = '--cache-file=/dev/null' ;
2001-03-23 21:37:13 +00:00
2002-03-25 08:26:34 +00:00
# Pass $ObjDir along to the build system.
if ( $ Settings:: ObjDir ) {
my $ _objdir . = "MOZ_OBJDIR=$Settings::ObjDir" ;
$ Settings:: MakeOverrides . = $ _objdir ;
}
2001-03-23 21:37:13 +00:00
2000-02-25 21:40:56 +00:00
#print "Path after: $ENV{PATH}\n";
2000-02-07 02:34:30 +00:00
}
2000-03-22 00:18:06 +00:00
sub print_log {
my ( $ text ) = @ _ ;
print LOG $ text ;
print $ text ;
}
2004-01-31 21:31:54 +00:00
sub run_shell_command_with_timeout {
my ( $ shell_command , $ timeout_secs ) = @ _ ;
my $ now = localtime ( ) ;
local $ _ ;
chomp ( $ shell_command ) ;
print_log "Begin: $now\n" ;
print_log "$shell_command\n" ;
my $ pid = fork ; # Fork off a child process.
unless ( $ pid ) { # child
my $ status = 0 ;
open CMD , "$shell_command $Settings::TieStderr |" or die "open: $!" ;
print_log $ _ while <CMD> ;
close CMD or $ status = 1 ;
exit ( $ status ) ;
}
my $ result = wait_for_pid ( $ pid , $ timeout_secs ) ;
$ now = localtime ( ) ;
print_log "End: $now\n" ;
return $ result ;
}
2000-03-22 00:18:06 +00:00
sub run_shell_command {
my ( $ shell_command ) = @ _ ;
local $ _ ;
my $ status = 0 ;
chomp ( $ shell_command ) ;
print_log "$shell_command\n" ;
2002-03-13 08:04:28 +00:00
open CMD , "$shell_command $Settings::TieStderr |" or die "open: $!" ;
2000-03-22 00:18:06 +00:00
print_log $ _ while <CMD> ;
close CMD or $ status = 1 ;
return $ status ;
}
sub adjust_start_time {
# Allows the start time to match up with the update times of a mirror.
my ( $ start_time ) = @ _ ;
# Since we are not pulling for cvs-mirror anymore, just round times
# to 1 minute intervals to make them nice and even.
my $ cycle = 1 * 60 ; # Updates every 1 minutes.
my $ begin = 0 * 60 ; # Starts 0 minutes after the hour.
2001-08-14 06:36:41 +00:00
my $ lag = 0 * 60 ; # Takes 0 minute to update.
2000-03-22 00:18:06 +00:00
return int ( ( $ start_time - $ begin - $ lag ) / $ cycle ) * $ cycle + $ begin ;
}
sub mail_build_started_message {
my ( $ start_time ) = @ _ ;
2001-12-21 06:52:19 +00:00
my $ msg_log = "build_start_msg.tmp" ;
open LOG , ">$msg_log" ;
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
PrintUsage ( ) if $ Settings:: BuildTree =~ /^\s+$/i ;
2002-03-13 08:04:28 +00:00
my $ platform = $ Settings:: OS =~ /^WIN/ ? 'windows' : 'unix' ;
2000-03-22 00:18:06 +00:00
print_log "\n" ;
print_log "tinderbox: tree: $Settings::BuildTree\n" ;
print_log "tinderbox: builddate: $start_time\n" ;
print_log "tinderbox: status: building\n" ;
print_log "tinderbox: build: $Settings::BuildName\n" ;
2002-03-13 08:04:28 +00:00
print_log "tinderbox: errorparser: $platform\n" ;
print_log "tinderbox: buildfamily: $platform\n" ;
2000-03-22 00:18:06 +00:00
print_log "tinderbox: version: $::Version\n" ;
print_log "tinderbox: END\n" ;
print_log "\n" ;
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
close LOG ;
2001-12-21 06:52:19 +00:00
if ( $ Settings:: blat ne "" && $ Settings:: use_blat ) {
system ( "$Settings::blat $msg_log -t $Settings::Tinderbox_server" ) ;
} else {
system "$Settings::mail $Settings::Tinderbox_server "
. " < $msg_log" ;
}
unlink "$msg_log" ;
2000-03-22 00:18:06 +00:00
}
2004-03-24 03:37:38 +00:00
sub encode_log {
my $ input_file = shift ;
my $ output_file = shift ;
my $ buf ;
if ( $ Settings:: LogEncoding eq 'base64' ) {
eval "use MIME::Base64 ();" ;
while ( read ( $ input_file , $ buf , 60 * 57 ) ) {
print $ output_file MIME::Base64:: encode ( $ buf ) ;
}
}
elsif ( $ Settings:: LogEncoding eq 'uuencode' ) {
while ( read ( $ input_file , $ buf , 45 ) ) {
print $ output_file pack ( "u*" , $ buf ) ;
}
}
else {
# Make sendmail happy.
# Split lines longer than 1000 charaters into 1000 character lines.
# If any line is a dot on a line by itself, replace it with a blank
# line. This prevents cases where a <cr>.<cr> occurs in the log file.
# Sendmail interprets that as the end of the mail, and truncates the
# log before it gets to Tinderbox. (terry weismann, chris yeh)
while ( <$input_file> ) {
my $ length = length ( $ _ ) ;
my $ offset ;
for ( $ offset = 0 ; $ offset < $ length ; $ offset += 1000 ) {
my $ chars_left = $ length - $ offset ;
my $ output_length = $ chars_left < 1000 ? $ chars_left : 1000 ;
my $ output = substr $ _ , $ offset , $ output_length ;
$ output =~ s/^\.$//g ;
$ output =~ s/\n//g ;
print $ output_file "$output\n" ;
}
}
}
}
2000-03-22 00:18:06 +00:00
sub mail_build_finished_message {
2003-07-26 00:17:45 +00:00
my ( $ start_time , $ build_status , $ binary_url , $ logfile ) = @ _ ;
2000-03-22 00:18:06 +00:00
# Rewrite LOG to OUTLOG, shortening lines.
open OUTLOG , ">$logfile.last" or die "Unable to open logfile, $logfile: $!" ;
2002-03-13 08:04:28 +00:00
my $ platform = $ Settings:: OS =~ /^WIN/ ? 'windows' : 'unix' ;
2000-03-22 00:18:06 +00:00
# Put the status at the top of the log, so the server will not
# have to search through the entire log to find it.
2001-05-11 02:36:32 +00:00
print OUTLOG "\n" ;
2000-03-22 00:18:06 +00:00
print OUTLOG "tinderbox: tree: $Settings::BuildTree\n" ;
print OUTLOG "tinderbox: builddate: $start_time\n" ;
print OUTLOG "tinderbox: status: $build_status\n" ;
2003-07-26 00:17:45 +00:00
print OUTLOG "tinderbox: binaryurl: $binary_url\n" if ( $ binary_url ne "" ) ;
2000-03-22 00:18:06 +00:00
print OUTLOG "tinderbox: build: $Settings::BuildName\n" ;
2002-03-13 08:04:28 +00:00
print OUTLOG "tinderbox: errorparser: $platform\n" ;
print OUTLOG "tinderbox: buildfamily: $platform\n" ;
2000-03-22 00:18:06 +00:00
print OUTLOG "tinderbox: version: $::Version\n" ;
2000-03-22 00:45:13 +00:00
print OUTLOG "tinderbox: utilsversion: $::UtilsVersion\n" ;
2004-03-24 03:37:38 +00:00
print OUTLOG "tinderbox: logcompression: $Settings::LogCompression\n" ;
print OUTLOG "tinderbox: logencoding: $Settings::LogEncoding\n" ;
2000-03-22 00:45:13 +00:00
print OUTLOG "tinderbox: END\n" ;
2002-03-25 08:26:34 +00:00
2004-03-24 03:37:38 +00:00
if ( $ Settings:: LogCompression eq 'gzip' ) {
open GZIPLOG , "gzip -c $logfile |" or die "Couldn't open gzip'd logfile: $!\n" ;
encode_log ( \ * GZIPLOG , \ * OUTLOG ) ;
close GZIPLOG ;
}
elsif ( $ Settings:: LogCompression eq 'bzip2' ) {
open BZ2LOG , "bzip2 -c $logfile |" or die "Couldn't open bzip2'd logfile: $!\n" ;
encode_log ( \ * BZ2LOG , \ * OUTLOG ) ;
close BZ2LOG ;
}
else {
open LOG , "$logfile" or die "Couldn't open logfile, $logfile: $!" ;
encode_log ( \ * LOG , \ * OUTLOG ) ;
close LOG ;
}
2000-03-22 00:18:06 +00:00
close OUTLOG ;
unlink ( $ logfile ) ;
2002-03-25 08:26:34 +00:00
2002-10-20 07:28:24 +00:00
# If on Windows, make sure the log mail has unix lineendings, or
# we'll confuse the log scraper.
if ( $ platform eq 'windows' ) {
2003-03-01 00:55:20 +00:00
open ( IN , "$logfile.last" ) || die ( "$logfile.last: $!\n" ) ;
open ( OUT , ">$logfile.new" ) || die ( "$logfile.new: $!\n" ) ;
while ( <IN> ) {
s/\r\n$/\n/ ;
print OUT "$_" ;
}
close ( IN ) ;
close ( OUT ) ;
File::Copy:: move ( "$logfile.new" , "$logfile.last" ) or die ( "move: $!\n" ) ;
2002-10-20 07:28:24 +00:00
}
2000-03-22 00:18:06 +00:00
if ( $ Settings:: ReportStatus and $ Settings:: ReportFinalStatus ) {
2001-12-21 06:52:19 +00:00
if ( $ Settings:: blat ne "" && $ Settings:: use_blat ) {
system ( "$Settings::blat $logfile.last -t $Settings::Tinderbox_server" ) ;
} else {
system "$Settings::mail $Settings::Tinderbox_server "
. " < $logfile.last" ;
}
2002-03-25 08:26:34 +00:00
}
2000-03-22 00:18:06 +00:00
}
sub BuildIt {
2001-07-16 20:23:52 +00:00
# $Settings::DirName is set in build-seamonkey-utils.pl
2000-03-22 00:18:06 +00:00
mkdir $ Settings:: DirName , 0777 ;
chdir $ Settings:: DirName or die "Couldn't enter $Settings::DirName" ;
2002-03-25 08:26:34 +00:00
2001-12-21 03:05:28 +00:00
my $ build_dir = get_system_cwd ( ) ;
2001-03-03 02:14:29 +00:00
2003-08-28 07:22:43 +00:00
if ( $ Settings:: OS =~ /^WIN/ && $ build_dir !~ m/^.:\// ) {
chomp ( $ build_dir = `cygpath -w $build_dir` ) ;
$ build_dir =~ s/\\/\//g ;
2002-03-13 08:04:28 +00:00
}
2000-03-22 00:18:06 +00:00
my $ binary_basename = "$Settings::BinaryName" ;
2002-04-13 05:27:01 +00:00
my $ binary_dir ;
$ binary_dir = "$build_dir/$Settings::Topsrcdir/${Settings::ObjDir}/$Settings::DistBin" ;
2002-01-15 04:19:31 +00:00
my $ dist_dir = "$build_dir/$Settings::Topsrcdir/${Settings::ObjDir}/dist" ;
2000-03-22 00:18:06 +00:00
my $ full_binary_name = "$binary_dir/$binary_basename" ;
2001-03-03 02:14:29 +00:00
2002-01-15 04:19:31 +00:00
my $ embed_binary_basename = "$Settings::EmbedBinaryName" ;
my $ embed_binary_dir = "$build_dir/$Settings::Topsrcdir/${Settings::ObjDir}/${Settings::EmbedDistDir}" ;
2001-03-03 02:14:29 +00:00
my $ full_embed_binary_name = "$embed_binary_dir/$embed_binary_basename" ;
2000-03-22 00:18:06 +00:00
my $ exit_early = 0 ;
my $ start_time = 0 ;
2002-01-15 04:19:31 +00:00
my $ build_failure_count = 0 ; # Keep count of build failures.
2001-08-16 02:50:16 +00:00
2001-11-30 02:02:57 +00:00
# Bypass profile manager at startup.
2000-03-22 00:18:06 +00:00
$ ENV { MOZ_BYPASS_PROFILE_AT_STARTUP } = 1 ;
2002-03-25 08:26:34 +00:00
2002-03-13 08:04:28 +00:00
# Avoid debug assertion dialogs (win32)
$ ENV { XPCOM_DEBUG_BREAK } = "warn" ;
2002-03-25 08:26:34 +00:00
2002-01-15 04:19:31 +00:00
# Set up tag stuff.
2000-08-01 22:40:53 +00:00
# Only one tag per file, so -r will override any -D settings.
2002-01-15 04:19:31 +00:00
$ Settings:: CVSCO . = " -r $Settings::BuildTag"
2002-03-25 08:26:34 +00:00
unless not defined ( $ Settings:: BuildTag ) or $ Settings:: BuildTag eq '' ;
2000-08-01 22:40:53 +00:00
2000-03-22 00:18:06 +00:00
print "Starting dir is : $build_dir\n" ;
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
while ( not $ exit_early ) {
# $BuildSleep is the minimum amount of time a build is allowed to take.
# It prevents sending too many messages to the tinderbox server when
# something is broken.
my $ sleep_time = ( $ Settings:: BuildSleep * 60 ) - ( time - $ start_time ) ;
if ( not $ Settings:: TestOnly and $ sleep_time > 0 ) {
print "\n\nSleeping $sleep_time seconds ...\n" ;
sleep $ sleep_time ;
}
$ start_time = time ( ) ;
2001-08-23 04:59:55 +00:00
2001-09-08 21:37:06 +00:00
# Set this each time, since post-mozilla.pl can reset this.
$ ENV { MOZILLA_FIVE_HOME } = "$binary_dir" ;
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
my $ cvsco = '' ;
2001-09-08 22:31:24 +00:00
2002-03-25 08:26:34 +00:00
# Note: Pull-by-date works on a branch, but cvs stat won't show
# you this. Thanks to cls for figuring this out.
2001-09-08 22:31:24 +00:00
if ( $ Settings:: UseTimeStamp ) {
2000-03-22 00:18:06 +00:00
$ start_time = adjust_start_time ( $ start_time ) ;
my $ time_str = POSIX:: strftime ( "%m/%d/%Y %H:%M" , localtime ( $ start_time ) ) ;
2002-08-29 02:31:34 +00:00
2003-04-21 08:28:57 +00:00
# Global, sorry. Tests need this, it's everywhere.
# Switch to format the graph server uses, to be consistant.
$ co_time_str = POSIX:: strftime ( "%Y:%m:%d:%H:%M:%S" , localtime ( $ start_time ) ) ;
2002-08-29 02:31:34 +00:00
# Figure out the timezone. Some platform issues here:
#
# Win32/Activate returns the long form, e.g. "Pacific Daylight Time"
# which chokes win32 cvs. Win32/cygwin perl returns "".
#
# Jaguar/MacOSX 10.2 posix call crashes.
#
my $ timezone ;
if ( $ Settings:: Timezone ) {
# If this is set in tinder-config.pl, use it.
$ timezone = $ Settings:: Timezone ;
} elsif ( not ( $ Settings:: OS =~ /^(Darwin|WIN)/ ) ) {
# Try posix call to find timezone.
# Don't do this for Darwin, Win32.
$ timezone = POSIX:: strftime ( "%Z" , localtime ( $ start_time ) ) ;
2003-10-30 04:01:33 +00:00
} else {
2002-08-29 02:31:34 +00:00
# Fallback to what `date` says.
chomp ( $ timezone = `date "+%Z"` ) ;
}
print "timezone = $timezone\n" ;
2001-12-21 06:54:10 +00:00
$ time_str . = " $timezone" ;
2000-03-22 00:18:06 +00:00
$ ENV { MOZ_CO_DATE } = "$time_str" ;
2002-03-13 08:04:28 +00:00
# command.com/win9x loathes single quotes in command line
$ cvsco = "$Settings::CVSCO -D \"$time_str\"" ;
2001-09-08 22:31:24 +00:00
} else {
2000-03-22 00:18:06 +00:00
$ cvsco = "$Settings::CVSCO -A" ;
2001-09-08 22:31:24 +00:00
}
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
mail_build_started_message ( $ start_time ) if $ Settings:: ReportStatus ;
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
chdir $ build_dir ;
my $ logfile = "$Settings::DirName.log" ;
print "Opening $logfile\n" ;
open LOG , ">$logfile"
2002-03-25 08:26:34 +00:00
or die "Cannot open logfile, $logfile: $?\n" ;
2003-02-20 21:20:21 +00:00
print_log "current dir is -- " . :: hostname ( ) . ":$build_dir\n" ;
2000-03-22 00:18:06 +00:00
print_log "Build Administrator is $Settings::BuildAdministrator\n" ;
2002-03-25 08:26:34 +00:00
2002-01-15 04:19:31 +00:00
# Print user comment if there is one.
if ( $ Settings:: UserComment ) {
2002-03-25 08:26:34 +00:00
print_log "$Settings::UserComment\n" ;
2002-01-15 04:19:31 +00:00
}
2002-03-25 08:26:34 +00:00
2002-01-15 04:19:31 +00:00
# System id
print_log "uname -a = " . `uname -a` ;
2002-03-25 08:26:34 +00:00
2002-01-15 04:19:31 +00:00
# Print out redhat version if we have it.
if ( - e "/etc/redhat-release" ) {
2002-03-25 08:26:34 +00:00
print_log `cat /etc/redhat-release` ;
2002-01-15 04:19:31 +00:00
}
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
PrintEnv ( ) ;
2002-03-25 08:26:34 +00:00
2002-01-15 04:19:31 +00:00
# Print out failure count
if ( $ build_failure_count > 0 ) {
2002-03-25 08:26:34 +00:00
print_log "Previous consecutive build failures: $build_failure_count\n" ;
2002-01-15 04:19:31 +00:00
}
2002-03-25 08:26:34 +00:00
2003-01-08 02:50:57 +00:00
my $ build_status = 'none' ;
2003-08-06 02:08:06 +00:00
my $ binary_url = '' ;
2003-01-08 02:50:57 +00:00
# Allow skipping of mozilla phase.
unless ( $ Settings:: SkipMozilla ) {
2003-06-26 01:06:48 +00:00
# Make sure we have $Settings::moz_client_mk
unless ( - e "$TreeSpecific::name/$Settings::moz_client_mk" ) {
2003-01-08 02:50:57 +00:00
2002-03-25 08:26:34 +00:00
# Set CVSROOT here. We should only need to checkout a new
2003-06-26 01:06:48 +00:00
# version of $Settings::moz_client_mk once; we might have
# more than one cvs tree so set CVSROOT here to avoid confusion.
2002-03-25 08:26:34 +00:00
$ ENV { CVSROOT } = $ Settings:: moz_cvsroot ;
2003-01-17 19:27:14 +00:00
2004-03-25 22:22:00 +00:00
run_shell_command ( "$Settings::CVS $cvsco $TreeSpecific::name/$Settings::moz_client_mk $TreeSpecific::extrafiles" ) ;
2003-01-08 02:50:57 +00:00
}
# Create toplevel source directory.
chdir $ Settings:: Topsrcdir or die "chdir $Settings::Topsrcdir: $!\n" ;
# Build it
unless ( $ Settings:: TestOnly ) { # Do not build if testing smoke tests.
2002-03-13 08:04:28 +00:00
if ( $ Settings:: OS =~ /^WIN/ ) {
2003-01-08 02:50:57 +00:00
DeleteBinaryDir ( $ binary_dir ) ;
2002-03-13 08:04:28 +00:00
} else {
2003-01-08 02:50:57 +00:00
# Delete binary so we can test for it to determine success after building.
DeleteBinary ( $ full_binary_name ) ;
if ( $ Settings:: EmbedTest or $ Settings:: BuildEmbed ) {
DeleteBinary ( $ full_embed_binary_name ) ;
}
# Delete dist directory to avoid accumulating cruft there, some commercial
# build processes also need to do this.
if ( - e $ dist_dir ) {
print_log "Deleting $dist_dir\n" ;
File::Path:: rmtree ( $ dist_dir , 0 , 0 ) ;
if ( - e "$dist_dir" ) {
print_log "Error: rmtree('$dist_dir', 0, 0) failed.\n" ;
2002-03-25 08:26:34 +00:00
}
2003-01-08 02:50:57 +00:00
}
2002-01-15 04:19:31 +00:00
}
2004-01-31 21:31:54 +00:00
my $ status = 0 ;
# Pull using separate step so that we can timeout if necessary
my $ make_co = "$Settings::Make -f $Settings::moz_client_mk " .
"$TreeSpecific::checkout_target" ;
if ( $ Settings:: FastUpdate ) {
$ make_co = "$Settings::Make -f $Settings::moz_client_mk fast-update" ;
}
# Run the checkout command.
if ( $ build_status ne 'busted' ) {
$ status = run_shell_command_with_timeout ( "$make_co" ,
$ Settings:: CVSCheckoutTimeout ) ;
if ( $ status - > { exit_value } != 0 ) {
$ build_status = 'busted' ;
if ( $ status - > { timed_out } ) {
print_log "Error: CVS checkout timed out.\n" ;
# Need to figure out how to kill rogue cvs processes
my $ _cvs_pid = `ps -u $ENV{USER} | grep cvs` ;
$ _cvs_pid =~ s/[a-zA-Z]*\s*(\d+).*/$1/ ;
chomp ( $ _cvs_pid ) ;
if ( "$_cvs_pid" eq "" ) {
print_log "Cannot find cvs process to kill.\n" ;
} else {
print "cvs pid $_cvs_pid\n" ;
kill_process ( $ _cvs_pid ) ;
}
} else {
print_log "Error: CVS checkout failed.\n" ;
}
} else {
$ build_status = 'success' ;
}
}
2003-01-14 08:27:05 +00:00
# Build up initial make command.
2003-06-26 01:06:48 +00:00
my $ make = "$Settings::Make -f $Settings::moz_client_mk $Settings::MakeOverrides CONFIGURE_ENV_ARGS='$Settings::ConfigureEnvArgs'" ;
2003-01-17 19:27:14 +00:00
if ( $ Settings:: FastUpdate ) {
2003-06-26 01:06:48 +00:00
$ make = "$Settings::Make -f $Settings::moz_client_mk fast-update && $Settings::Make -f $Settings::moz_client_mk $Settings::MakeOverrides CONFIGURE_ENV_ARGS='$Settings::ConfigureEnvArgs' build" ;
2003-01-17 19:27:14 +00:00
}
2003-01-14 08:27:05 +00:00
2002-03-25 08:26:34 +00:00
# Make sure we have an ObjDir if we need one.
mkdir $ Settings:: ObjDir , 0777 if ( $ Settings:: ObjDir && ! - e $ Settings:: ObjDir ) ;
2004-03-25 22:22:00 +00:00
# Run the clobber target.
if ( ! $ Settings:: BuildDepend && $ build_status ne 'busted' ) {
$ status = run_shell_command "$make $TreeSpecific::clobber_target" ;
if ( $ status != 0 ) {
$ build_status = 'busted' ;
}
}
# Run the build target.
2004-01-31 21:31:54 +00:00
if ( $ build_status ne 'busted' ) {
2004-03-25 22:22:00 +00:00
$ status = run_shell_command "$make $TreeSpecific::build_target" ;
2004-01-31 21:31:54 +00:00
if ( $ status != 0 ) {
$ build_status = 'busted' ;
} elsif ( not BinaryExists ( $ full_binary_name ) ) {
print_log "Error: binary not found: $binary_basename\n" ;
$ build_status = 'busted' ;
} else {
$ build_status = 'success' ;
}
2002-03-25 08:26:34 +00:00
}
# TestGtkEmbed is only built by default on certain platforms.
if ( $ build_status ne 'busted' and ( $ Settings:: EmbedTest or $ Settings:: BuildEmbed ) ) {
2003-01-08 02:50:57 +00:00
if ( not BinaryExists ( $ full_embed_binary_name ) ) {
print_log "Error: binary not found: $Settings::EmbedBinaryName\n" ;
$ build_status = 'busted' ;
} else {
$ build_status = 'success' ;
}
2001-09-11 07:43:37 +00:00
}
2003-01-08 02:50:57 +00:00
}
2001-03-03 02:14:29 +00:00
2003-01-08 02:50:57 +00:00
if ( $ build_status ne 'busted' and BinaryExists ( $ full_binary_name ) ) {
2002-03-25 08:26:34 +00:00
print_log "$binary_basename binary exists, build successful.\n" ;
2002-07-22 21:45:52 +00:00
2002-12-20 06:04:39 +00:00
if ( $ Settings:: RunMozillaTests ) {
2003-01-08 02:50:57 +00:00
$ build_status = run_all_tests ( $ full_binary_name ,
$ full_embed_binary_name ,
$ build_dir ) ;
2002-03-25 08:26:34 +00:00
} else {
2003-03-04 02:59:48 +00:00
print_log "Skipping Mozilla tests.\n" ;
2003-01-08 02:50:57 +00:00
$ build_status = 'success' ;
2002-03-25 08:26:34 +00:00
}
2003-01-08 02:50:57 +00:00
}
} # SkipMozilla
2000-03-22 00:18:06 +00:00
2002-01-15 04:19:31 +00:00
#
# Run (optional) external, post-mozilla build here.
#
my $ external_build = "$Settings::BaseDir/post-mozilla.pl" ;
2003-01-08 02:50:57 +00:00
if ( ( ( - e $ external_build ) and ( $ build_status eq 'success' ) ) ||
( $ Settings:: SkipMozilla ) ) {
2003-07-26 00:17:45 +00:00
( $ build_status , $ binary_url ) = PostMozilla:: main ( $ build_dir ) ;
2002-01-15 04:19:31 +00:00
}
2002-03-25 08:26:34 +00:00
2002-01-15 04:19:31 +00:00
# Increment failure count if we failed.
if ( $ build_status eq 'busted' ) {
2002-03-25 08:26:34 +00:00
$ build_failure_count + + ;
} else {
$ build_failure_count = 0 ;
2002-01-15 04:19:31 +00:00
}
2001-08-16 02:50:16 +00:00
2002-04-15 05:40:49 +00:00
# win98 just ain't up to the task of continuous builds
print_log "System going down for a reboot!! " . scalar localtime ( ) . "\n"
if $ Settings:: OS eq 'WIN98' && $ Settings:: RebootSystem ;
2000-03-22 00:18:06 +00:00
close LOG ;
chdir $ build_dir ;
2002-01-15 04:19:31 +00:00
2003-07-26 00:17:45 +00:00
mail_build_finished_message ( $ start_time , $ build_status , $ binary_url , $ logfile )
2002-03-25 08:26:34 +00:00
if $ Settings:: ReportStatus ;
2000-03-22 00:18:06 +00:00
2002-04-15 05:40:49 +00:00
rebootSystem ( ) if $ Settings:: OS eq 'WIN98' && $ Settings:: RebootSystem ;
2003-01-07 00:33:31 +00:00
$ exit_early + + if $ Settings:: TestOnly and ( $ build_status ne 'success' ) ;
2000-03-22 00:18:06 +00:00
$ exit_early + + if $ Settings:: BuildOnce ;
}
}
2001-03-03 02:14:29 +00:00
2002-04-15 05:40:49 +00:00
sub rebootSystem {
# assumption is that system has been configured to automatically
# startup tinderbox again on the other side of the reboot
if ( $ Settings:: OS eq 'WIN98' ) {
# http://support.microsoft.com/directory/article.asp?ID=KB;EN-US;Q234216
# 6 == RESTART | FORCE; applies to win98 and winME
print "System going down for a reboot!! " , scalar localtime , "\n" ;
system ( "rundll32.exe shell32.dll,SHExitWindowsEx 6" ) == 0 ||
warn "Failed to $! $@ $?" ;
} else {
print "rebootSystem() called on non-Win9x system. wtf?\n" ;
}
}
2001-11-30 02:02:57 +00:00
# Create a profile named $Settings::MozProfileName in the normal $build_dir place.
sub create_profile {
2002-03-25 08:26:34 +00:00
my ( $ build_dir , $ binary_dir , $ binary ) = @ _ ;
2003-08-13 22:21:13 +00:00
my $ profile_log = "$build_dir/create-profile.log" ;
2002-03-25 08:26:34 +00:00
my $ result = run_cmd ( $ build_dir , $ binary_dir ,
2002-10-20 07:28:24 +00:00
[ $ binary , "-CreateProfile" , $ Settings:: MozProfileName ] ,
2003-08-13 22:21:13 +00:00
$ profile_log , $ Settings:: CreateProfileTimeout ) ;
print_logfile ( $ profile_log , "Profile Creation" ) ;
2002-03-25 08:26:34 +00:00
return $ result ;
2001-11-30 02:02:57 +00:00
}
2003-02-18 00:22:42 +00:00
# Find mozilla profile.
2002-10-20 07:28:24 +00:00
sub get_profile_dir {
2002-04-07 05:52:21 +00:00
my $ build_dir = shift ;
2002-10-20 07:28:24 +00:00
my $ profile_dir ;
2002-04-07 05:52:21 +00:00
if ( $ Settings:: OS =~ /^WIN/ ) {
2002-04-11 01:42:41 +00:00
if ( $ Settings:: OS =~ /^WIN9/ ) { # 98 [but what does uname say on Me?]
2002-04-07 05:52:21 +00:00
$ profile_dir = $ ENV { winbootdir } || $ ENV { windir } || "C:\\WINDOWS" ;
$ profile_dir . = "\\Application Data" ;
2002-04-11 01:42:41 +00:00
} elsif ( $ Settings:: OS =~ /^WINNT/ ) { # NT 4, 2K, XP(?)
# afaict, %USERPROFILE% should always be there, NT 4.0 and up
if ( $ ENV { USERPROFILE } ) {
$ profile_dir = $ ENV { USERPROFILE } . "\\Application Data" ;
} else { # use %APPDATA% as a fallback (or prepare to fail)
$ profile_dir = $ ENV { APPDATA } || "C:\\_UNKNOWN_" ;
}
2002-04-07 05:52:21 +00:00
}
2002-10-20 07:28:24 +00:00
$ profile_dir . = "\\$Settings::ProductName\\Profiles\\$Settings::MozProfileName" ;
2002-04-07 05:52:21 +00:00
$ profile_dir =~ s | \ \ | / | g ;
2002-10-20 07:28:24 +00:00
} elsif ( $ Settings:: OS eq "BeOS" ) {
$ profile_dir = "/boot/home/config/settings/Mozilla/$Settings::MozProfileName" ;
2002-12-21 00:08:26 +00:00
} elsif ( $ Settings:: OS eq "Darwin" ) {
2003-04-22 06:54:26 +00:00
$ profile_dir = "$ENV{HOME}/Library/$Settings::ProductName/Profiles/$Settings::MozProfileName" ;
2002-10-20 07:28:24 +00:00
} else {
# *nix
2003-04-16 00:01:54 +00:00
$ profile_dir = "$build_dir/." . lc ( $ Settings:: ProductName ) . "/$Settings::MozProfileName" ;
2002-04-07 05:52:21 +00:00
}
2002-10-20 07:28:24 +00:00
return $ profile_dir ;
}
2002-12-21 02:46:17 +00:00
#
# Given profile directory, find pref file hidden in salt directory.
# profile $Settings::MozProfileName must exist before calling this sub.
#
2002-10-20 07:28:24 +00:00
sub find_pref_file {
2002-12-21 02:46:17 +00:00
my $ profile_dir = shift ;
2002-10-20 07:28:24 +00:00
# default to *nix
my $ pref_file = "prefs.js" ;
2002-12-21 02:46:17 +00:00
2002-04-07 05:52:21 +00:00
unless ( - e $ profile_dir ) {
2002-04-15 05:40:49 +00:00
print_log "ERROR: profile $profile_dir does not exist\n" ;
#XXX should make 'run_all_tests' throw a 'testfailed' exception
# and just skip all the continual checking for $test_result
return ; # empty list
2002-04-07 05:52:21 +00:00
}
my $ found = undef ;
my $ sub = sub { $ pref_file = $ File:: Find:: name , $ found + + if $ pref_file eq $ _ } ;
File::Find:: find ( $ sub , $ profile_dir ) ;
unless ( $ found ) {
2002-04-15 05:40:49 +00:00
print_log "ERROR: couldn't find prefs.js in $profile_dir\n" ;
return ; # empty list
2002-04-07 05:52:21 +00:00
}
# Find full profile_dir while we're at it.
$ profile_dir = File::Basename:: dirname ( $ pref_file ) ;
print_log "profile dir = $profile_dir\n" ;
print_log "prefs.js = $pref_file\n" ;
return ( $ pref_file , $ profile_dir ) ;
}
2001-03-03 02:14:29 +00:00
2002-07-30 22:22:38 +00:00
sub BinaryExists {
my ( $ binary ) = @ _ ;
my ( $ binary_basename ) = File::Basename:: basename ( $ binary ) ;
2000-03-22 00:18:06 +00:00
2002-07-30 22:22:38 +00:00
if ( not - e $ binary ) {
print_log "$binary does not exist.\n" ;
0 ;
} elsif ( not - s _ ) {
print_log "$binary is zero-size.\n" ;
0 ;
} elsif ( not - x _ ) {
print_log "$binary is not executable.\n" ;
0 ;
} else {
print_log "$binary_basename exists, is nonzero, and executable.\n" ;
1 ;
2002-03-13 08:04:28 +00:00
}
2002-07-30 22:22:38 +00:00
}
2002-03-13 08:04:28 +00:00
2002-07-30 22:22:38 +00:00
sub min {
my $ m = $ _ [ 0 ] ;
my $ i ;
foreach $ i ( @ _ ) {
$ m = $ i if ( $ m > $ i ) ;
2002-03-25 08:26:34 +00:00
}
2002-07-30 22:22:38 +00:00
return $ m ;
}
2001-10-06 09:12:29 +00:00
2002-03-13 08:04:28 +00:00
2002-07-30 22:22:38 +00:00
sub DeleteBinary {
my ( $ binary ) = @ _ ;
my ( $ binary_basename ) = File::Basename:: basename ( $ binary ) ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
if ( BinaryExists ( $ binary ) ) {
print_log "Deleting binary: $binary_basename\n" ;
print_log "unlinking $binary\n" ;
unlink $ binary or print_log "Error: Unlinking $binary failed\n" ;
} else {
print_log "No binary detected; none deleted.\n" ;
}
}
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
sub DeleteBinaryDir {
my ( $ binarydir ) = @ _ ;
if ( - e $ binarydir ) {
print_log "Deleting $binarydir\n" ;
my $ count = File::Path:: rmtree ( $ binarydir , 0 , 0 ) ;
if ( - e "$binarydir" ) {
print_log "Error: rmtree('$binarydir', 0, 0) failed.\n" ;
2002-03-25 08:26:34 +00:00
}
2002-07-30 22:22:38 +00:00
} else {
print_log "No binarydir detected; none deleted.\n" ;
}
}
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
sub PrintEnv {
local $ _ ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
# Print out environment settings.
my $ key ;
foreach $ key ( sort keys % ENV ) {
print_log "$key=$ENV{$key}\n" ;
2002-03-25 08:26:34 +00:00
}
2002-07-30 22:22:38 +00:00
# Print out mozconfig if found.
if ( defined $ ENV { MOZCONFIG } and - e $ ENV { MOZCONFIG } ) {
print_log "-->mozconfig<----------------------------------------\n" ;
open CONFIG , "$ENV{MOZCONFIG}" ;
print_log $ _ while <CONFIG> ;
close CONFIG ;
print_log "-->end mozconfig<----------------------------------------\n" ;
}
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
# Say if we found post-mozilla.pl
if ( - e "$Settings::BaseDir/post-mozilla.pl" ) {
print_log "Found post-mozilla.pl\n" ;
} else {
print_log "Didn't find $Settings::BaseDir/post-mozilla.pl\n" ;
2002-03-25 08:26:34 +00:00
}
2002-07-30 22:22:38 +00:00
# Print compiler setting
if ( $ Settings:: Compiler ne '' ) {
print_log "===============================\n" ;
if ( $ Settings:: Compiler eq 'gcc' or $ Settings:: Compiler eq 'egcc' ) {
my $ comptmp = `$Settings::Compiler --version` ;
chomp ( $ comptmp ) ;
print_log "Compiler is -- $Settings::Compiler ($comptmp)\n" ;
2002-04-07 05:52:21 +00:00
} else {
2002-07-30 22:22:38 +00:00
print_log "Compiler is -- $Settings::Compiler\n" ;
2002-04-07 05:52:21 +00:00
}
2002-07-30 22:22:38 +00:00
print_log "===============================\n" ;
2001-12-15 09:08:56 +00:00
}
2002-07-30 22:22:38 +00:00
}
2001-12-15 09:08:56 +00:00
2002-07-30 22:22:38 +00:00
# Parse a file for $token, given a file handle.
sub file_has_token {
my ( $ filename , $ token ) = @ _ ;
local $ _ ;
my $ has_token = 0 ;
open TESTLOG , "<$filename" or die "Cannot open file, $filename: $!" ;
while ( <TESTLOG> ) {
if ( /$token/ ) {
$ has_token = 1 ;
last ;
}
2000-03-22 00:18:06 +00:00
}
2002-07-30 22:22:38 +00:00
close TESTLOG ;
return $ has_token ;
}
2000-03-22 00:18:06 +00:00
2002-07-30 22:22:38 +00:00
# Parse a file for $token, return the token.
# Look for the line "<token><delimiter><return-value>", e.g.
# for "__startuptime,5501"
# token = "__startuptime"
# delimiter = ","
# return-value = "5501";
#
sub extract_token_from_file {
my ( $ filename , $ token , $ delimiter ) = @ _ ;
local $ _ ;
my $ token_value = 0 ;
open TESTLOG , "<$filename" or die "Cannot open file, $filename: $!" ;
while ( <TESTLOG> ) {
if ( /$token/ ) {
# pull the token out of $_
$ token_value = substr ( $ _ , index ( $ _ , $ delimiter ) + 1 ) ;
2002-12-17 03:13:52 +00:00
chomp ( $ token_value ) ;
2002-07-30 22:22:38 +00:00
last ;
}
2001-08-23 01:06:35 +00:00
}
2002-07-30 22:22:38 +00:00
close TESTLOG ;
return $ token_value ;
}
2002-03-25 08:26:34 +00:00
2001-08-23 01:06:35 +00:00
2001-03-03 02:14:29 +00:00
2002-07-30 22:22:38 +00:00
sub kill_process {
my ( $ target_pid ) = @ _ ;
my $ start_time = time ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
# Try to kill and wait 10 seconds, then try a kill -9
my $ sig ;
for $ sig ( 'TERM' , 'KILL' ) {
2004-01-31 21:31:54 +00:00
print "kill $sig $target_pid\n" ;
2002-07-30 22:22:38 +00:00
kill $ sig = > $ target_pid ;
my $ interval_start = time ;
while ( time - $ interval_start < 10 ) {
# the following will work with 'cygwin' perl on win32, but not
# with 'MSWin32' (ActiveState) perl
my $ pid = waitpid ( $ target_pid , POSIX:: WNOHANG ( ) ) ;
if ( ( $ pid == $ target_pid and POSIX:: WIFEXITED ( $? ) ) or $ pid == - 1 ) {
my $ secs = time - $ start_time ;
$ secs = $ secs == 1 ? '1 second' : "$secs seconds" ;
print_log "Process killed. Took $secs to die.\n" ;
return ;
}
sleep 1 ;
}
2001-11-19 23:29:48 +00:00
}
2002-07-30 22:22:38 +00:00
die "Unable to kill process: $target_pid" ;
}
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
BEGIN {
my % sig_num = ( ) ;
my @ sig_name = ( ) ;
2001-12-05 09:27:28 +00:00
2002-07-30 22:22:38 +00:00
sub signal_name {
# Find the name of a signal number
my ( $ number ) = @ _ ;
2001-12-05 09:27:28 +00:00
2002-07-30 22:22:38 +00:00
unless ( @ sig_name ) {
unless ( $ Config:: Config { sig_name } && $ Config:: Config { sig_num } ) {
die "No sigs?" ;
} else {
my @ names = split ' ' , $ Config:: Config { sig_name } ;
@ sig_num { @ names } = split ' ' , $ Config:: Config { sig_num } ;
foreach ( @ names ) {
$ sig_name [ $ sig_num { $ _ } ] || = $ _ ;
}
}
}
return $ sig_name [ $ number ] ;
}
}
2001-12-05 09:27:28 +00:00
2002-07-30 22:22:38 +00:00
sub fork_and_log {
# Fork a sub process and log the output.
2002-10-20 07:28:24 +00:00
my ( $ home , $ dir , $ args , $ logfile ) = @ _ ;
2001-12-05 09:27:28 +00:00
2002-07-30 22:22:38 +00:00
my $ pid = fork ; # Fork off a child process.
2001-12-05 09:27:28 +00:00
2002-07-30 22:22:38 +00:00
unless ( $ pid ) { # child
2001-12-05 09:27:28 +00:00
2002-07-30 22:22:38 +00:00
# Chimera doesn't want to reset home dir.
if ( $ Settings:: ResetHomeDirForTests ) {
$ ENV { HOME } = $ home if ( $ Settings:: OS ne "BeOS" ) ;
}
# Explicitly set cwd to home dir.
chdir $ home or die "chdir($home): $!\n" ;
2001-12-05 09:27:28 +00:00
2002-07-30 22:22:38 +00:00
# Now cd to dir where binary is..
chdir $ dir or die "chdir($dir): $!\n" ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
open STDOUT , ">$logfile" ;
open STDERR , ">&STDOUT" ;
select STDOUT ; $| = 1 ; # make STDOUT unbuffered
select STDERR ; $| = 1 ; # make STDERR unbuffered
2003-05-17 08:34:44 +00:00
exec { $ args - > [ 0 ] } @$ args ;
2002-07-30 22:22:38 +00:00
die "Could not exec()" ;
2002-03-25 08:26:34 +00:00
}
2002-07-30 22:22:38 +00:00
return $ pid ;
}
2001-11-30 02:02:57 +00:00
2002-07-30 22:22:38 +00:00
# Stripped down version of fork_and_log().
sub system_fork_and_log {
# Fork a sub process and log the output.
my ( $ cmd ) = @ _ ;
2001-11-30 02:02:57 +00:00
2002-07-30 22:22:38 +00:00
my $ pid = fork ; # Fork off a child process.
unless ( $ pid ) { # child
exec $ cmd ;
die "Could not exec()" ;
2000-03-22 00:18:06 +00:00
}
2002-07-30 22:22:38 +00:00
return $ pid ;
}
2001-03-03 02:14:29 +00:00
2002-04-10 03:38:40 +00:00
2002-07-30 22:22:38 +00:00
sub wait_for_pid {
# Wait for a process to exit or kill it if it takes too long.
my ( $ pid , $ timeout_secs ) = @ _ ;
my ( $ exit_value , $ signal_num , $ dumped_core , $ timed_out ) = ( 0 , 0 , 0 , 0 ) ;
my $ sig_name ;
my $ loop_count ;
2002-04-10 03:38:40 +00:00
2002-07-30 22:22:38 +00:00
die ( "Invalid timeout value passed to wait_for_pid()\n" )
if ( $ timeout_secs <= 0 ) ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
eval {
$ loop_count = 0 ;
while ( + + $ loop_count < $ timeout_secs ) {
my $ wait_pid = waitpid ( $ pid , POSIX:: WNOHANG ( ) ) ;
# the following will work with 'cygwin' perl on win32, but not
# with 'MSWin32' (ActiveState) perl
last if ( $ wait_pid == $ pid and POSIX:: WIFEXITED ( $? ) ) or $ wait_pid == - 1 ;
sleep 1 ;
}
2002-04-10 03:38:40 +00:00
2002-07-30 22:22:38 +00:00
$ exit_value = $? >> 8 ;
$ signal_num = $? >> 127 ;
$ dumped_core = $? & 128 ;
if ( $ loop_count >= $ timeout_secs ) {
die "timeout" ;
2002-04-10 03:38:40 +00:00
}
2002-07-30 22:22:38 +00:00
return "done" ;
} ;
2002-05-05 17:25:33 +00:00
2002-07-30 22:22:38 +00:00
if ( $@ ) {
if ( $@ =~ /timeout/ ) {
kill_process ( $ pid ) ;
$ timed_out = 1 ;
} else { # Died for some other reason.
die ; # Propagate the error up.
2002-03-25 08:26:34 +00:00
}
}
2002-07-30 22:22:38 +00:00
$ sig_name = $ signal_num ? signal_name ( $ signal_num ) : '' ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
return { timed_out = > $ timed_out ,
exit_value = > $ exit_value ,
sig_name = > $ sig_name ,
dumped_core = > $ dumped_core } ;
}
2002-04-10 03:38:40 +00:00
2002-07-30 22:22:38 +00:00
#
# Note that fork_and_log() sets the HOME env variable to do
# the command, this allows us to have a local profile in the
# shared cltbld user account.
#
sub run_cmd {
2002-10-20 07:28:24 +00:00
my ( $ home_dir , $ binary_dir , $ args , $ logfile , $ timeout_secs ) = @ _ ;
2002-07-30 22:22:38 +00:00
my $ now = localtime ( ) ;
2001-12-17 07:26:48 +00:00
2002-07-30 22:22:38 +00:00
print_log "Begin: $now\n" ;
2003-08-13 22:21:13 +00:00
print_log "cmd = " . join ( ' ' , @ { $ args } ) . "\n" ;
2002-03-25 08:26:34 +00:00
2002-10-20 07:28:24 +00:00
my $ pid = fork_and_log ( $ home_dir , $ binary_dir , $ args , $ logfile ) ;
2002-07-30 22:22:38 +00:00
my $ result = wait_for_pid ( $ pid , $ timeout_secs ) ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
$ now = localtime ( ) ;
print_log "End: $now\n" ;
2001-12-02 06:44:20 +00:00
2002-07-30 22:22:38 +00:00
return $ result ;
}
2001-12-17 07:26:48 +00:00
2002-07-30 22:22:38 +00:00
# System version of run_cmd().
sub run_system_cmd {
my ( $ cmd , $ timeout_secs ) = @ _ ;
print_log "cmd = $cmd\n" ;
my $ pid = system_fork_and_log ( $ cmd ) ;
my $ result = wait_for_pid ( $ pid , $ timeout_secs ) ;
return $ result ;
}
sub get_system_cwd {
my $ a = Cwd:: getcwd ( ) || `pwd` ;
chomp ( $ a ) ;
return $ a ;
}
sub print_test_errors {
my ( $ result , $ name ) = @ _ ;
if ( not $ result - > { timed_out } and $ result - > { exit_value } != 0 ) {
if ( $ result - > { sig_name } ne '' ) {
print_log "Error: $name: received SIG$result->{sig_name}\n" ;
}
print_log "Error: $name: exited with status $result->{exit_value}\n" ;
if ( $ result - > { dumped_core } ) {
print_log "Error: $name: dumped core.\n" ;
2002-03-25 08:26:34 +00:00
}
}
2002-07-30 22:22:38 +00:00
}
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
# Report test results back to a server.
# Netscape-internal now, will push to mozilla.org, ask
# mcafee or jrgm for details.
#
# Needs the following perl stubs, installed for rh7.1:
# perl-Digest-MD5-2.13-1.i386.rpm
# perl-MIME-Base64-2.12-6.i386.rpm
# perl-libnet-1.0703-6.noarch.rpm
# perl-HTML-Tagset-3.03-3.i386.rpm
# perl-HTML-Parser-3.25-2.i386.rpm
# perl-URI-1.12-5.noarch.rpm
# perl-libwww-perl-5.53-3.noarch.rpm
#
sub send_results_to_server {
2003-04-21 08:28:57 +00:00
my ( $ value , $ raw_data , $ testname , $ tbox ) = @ _ ;
# Prepend raw data with cvs checkout date, performance
# Use MOZ_CO_DATE, but with same graph/collect.cgi format. (server)
my $ data_plus_co_time = "MOZ_CO_DATE=$co_time_str\t$raw_data" ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
my $ tmpurl = "http://$Settings::results_server/graph/collect.cgi" ;
2003-04-21 08:28:57 +00:00
$ tmpurl . = "?value=$value&data=$data_plus_co_time&testname=$testname&tbox=$tbox" ;
2002-07-30 22:22:38 +00:00
print_log "send_results_to_server(): \n" ;
print_log "tmpurl = $tmpurl\n" ;
2002-10-20 07:28:24 +00:00
# libwww-perl has process control problems on windows,
# spawn wget instead.
if ( $ Settings:: OS =~ /^WIN/ ) {
system ( "wget" , "-O" , "/dev/null" , $ tmpurl ) ;
2002-07-30 22:22:38 +00:00
print_log "send_results_to_server() succeeded.\n" ;
2002-10-20 07:28:24 +00:00
} else {
my $ res = eval q{
use LWP::UserAgent ;
use HTTP::Request ;
my $ ua = LWP::UserAgent - > new ;
$ ua - > timeout ( 10 ) ; # seconds
my $ req = HTTP::Request - > new ( GET = > $ tmpurl ) ;
my $ res = $ ua - > request ( $ req ) ;
return $ res ;
} ;
if ( $@ ) {
warn "Failed to submit startup results: $@" ;
print_log "send_results_to_server() failed.\n" ;
} else {
print "Results submitted to server: \n" ,
$ res - > status_line , "\n" , $ res - > content , "\n" ;
print_log "send_results_to_server() succeeded.\n" ;
}
2002-07-30 22:22:38 +00:00
}
}
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
sub print_logfile {
my ( $ logfile , $ test_name ) = @ _ ;
print_log "----------- Output from $test_name ------------- \n" ;
open READRUNLOG , "$logfile" ;
print_log " $_" while <READRUNLOG> ;
close READRUNLOG ;
print_log "----------- End Output from $test_name --------- \n" ;
}
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
##################################################
# #
# Test definitions start here. #
# #
##################################################
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
# Run all tests. Had to pass in both binary and embed_binary.
#
sub run_all_tests {
my ( $ binary , $ embed_binary , $ build_dir ) = @ _ ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
my $ binary_basename = File::Basename:: basename ( $ binary ) ;
my $ binary_dir = File::Basename:: dirname ( $ binary ) ;
my $ embed_binary_basename = File::Basename:: basename ( $ embed_binary ) ;
my $ embed_binary_dir = File::Basename:: dirname ( $ embed_binary ) ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
my $ test_result = 'success' ;
2002-03-25 08:26:34 +00:00
2002-08-12 15:51:00 +00:00
# Windows needs this for file: urls.
2002-07-30 22:22:38 +00:00
my $ win32_build_dir = $ build_dir ;
2003-08-28 07:22:43 +00:00
if ( $ Settings:: OS =~ /^WIN/ && $ win32_build_dir !~ m/^.:\// ) {
chomp ( $ win32_build_dir = `cygpath -w $win32_build_dir` ) ;
$ win32_build_dir =~ s/\\/\//g ;
2002-07-30 22:22:38 +00:00
}
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
#
# Before running tests, run regxpcom so that we don't crash when
# people change contractids on us (since we don't autoreg opt builds)
#
unlink ( "$binary_dir/component.reg" ) or warn "$binary_dir/component.reg not removed\n" ;
if ( $ Settings:: RegxpcomTest ) {
2002-10-20 07:28:24 +00:00
AliveTest ( "regxpcom" , $ build_dir , [ "$binary_dir/regxpcom" ] ,
2002-07-30 22:22:38 +00:00
$ Settings:: RegxpcomTestTimeout ) ;
}
2002-03-25 08:26:34 +00:00
2002-12-21 00:08:26 +00:00
2003-02-18 00:22:42 +00:00
my ( $ pref_file , $ profile_dir ) ;
2002-03-25 08:26:34 +00:00
2003-02-18 00:22:42 +00:00
if ( $ Settings:: UseMozillaProfile ) {
# Profile directory. This lives in way-different places
# depending on the OS.
#
my $ profiledir = get_profile_dir ( $ build_dir ) ;
#
# Make sure we have a profile to run tests. This is assumed to be called
# $Settings::MozProfileName and will live in $build_dir/.mozilla.
# Also assuming only one profile here.
#
my $ cp_result = 0 ;
2002-12-21 00:08:26 +00:00
2003-02-18 00:22:42 +00:00
unless ( - d "$profiledir" ) {
2002-10-20 07:28:24 +00:00
print_log "No profile found, creating profile.\n" ;
$ cp_result = create_profile ( $ build_dir , $ binary_dir , $ binary ) ;
2003-02-18 00:22:42 +00:00
} else {
2002-10-20 07:28:24 +00:00
print_log "Found profile.\n" ;
# Recreate profile if we have $Settings::CleanProfile set.
if ( $ Settings:: CleanProfile ) {
2003-02-18 00:22:42 +00:00
my $ deletedir = $ profiledir ;
2002-12-21 02:46:17 +00:00
2003-02-18 00:22:42 +00:00
print_log "Creating clean profile ...\n" ;
print_log "Deleting $deletedir ...\n" ;
File::Path:: rmtree ( [ $ deletedir ] , 0 , 0 ) ;
if ( - e "$deletedir" ) {
print_log "Error: rmtree([$deletedir], 0, 0) failed.\n" ;
}
$ cp_result = create_profile ( $ build_dir , $ binary_dir , $ binary ) ;
2002-07-30 22:22:38 +00:00
}
2003-02-18 00:22:42 +00:00
}
2002-03-25 08:26:34 +00:00
2003-02-18 00:22:42 +00:00
# Set status, in case create profile failed.
if ( $ cp_result ) {
if ( not $ cp_result - > { timed_out } and $ cp_result - > { exit_value } != 0 ) {
$ test_result = "success" ;
2002-10-20 07:28:24 +00:00
} else {
2003-02-18 00:22:42 +00:00
$ test_result = "testfailed" ;
2002-03-25 08:26:34 +00:00
}
2003-02-18 00:22:42 +00:00
}
2001-04-09 22:44:49 +00:00
2003-02-18 00:22:42 +00:00
#
# Find the prefs file, remember we have that random string now
# e.g. <build-dir>/.mozilla/default/uldx6pyb.slt/prefs.js
# so File::Path::find will find the prefs.js file.
#
( $ pref_file , $ profile_dir ) = find_pref_file ( $ profiledir ) ;
#XXX this is ugly and hacky
$ test_result = 'testfailed' unless $ pref_file ; ;
} elsif ( $ Settings:: BinaryName eq "TestGtkEmbed" ) {
print_log "Using TestGtkEmbed profile\n" ;
$ pref_file = "$build_dir/.TestGtkEmbed/TestGtkEmbed/prefs.js" ;
$ profile_dir = "$build_dir" ;
# Create empty prefs file if needed
#unless (-e $pref_file) {
# system("mkdir -p $build_dir/.TestGtkEmbed/TestGtkEmbed");
# system("touch $pref_file");
#}
# Run TestGtkEmbed to generate proper pref file.
# This should only need to be run the first time for a given tree.
unless ( - e $ pref_file ) {
$ test_result = AliveTest ( "EmbedAliveTest_profile" , $ build_dir ,
[ "$embed_binary_dir/$embed_binary_basename" ] ,
$ Settings:: EmbedTestTimeout ) ;
}
}
2000-03-22 00:18:06 +00:00
2002-07-30 22:22:38 +00:00
#
# Set prefs to run tests properly.
#
2004-04-13 23:48:24 +00:00
if ( $ pref_file && $ test_result eq 'success' ) { #XXX lame
2002-07-30 22:22:38 +00:00
if ( $ Settings:: LayoutPerformanceTest or
$ Settings:: XULWindowOpenTest or
$ Settings:: StartupPerformanceTest or
$ Settings:: MailBloatTest or
2003-02-13 02:31:08 +00:00
$ Settings:: QATest or
2002-07-30 22:22:38 +00:00
$ Settings:: BloatTest2 or
$ Settings:: BloatTest ) {
# Chances are we will be timing these tests. Bring gettime() into memory
# by calling it once, before any tests run.
Time::PossiblyHiRes:: getTime ( ) ;
# Some tests need browser.dom.window.dump.enabled set to true, so
# that JS dump() will work in optimized builds.
2004-04-13 23:48:24 +00:00
set_pref ( $ pref_file , 'browser.dom.window.dump.enabled' , 'true' ) ;
2002-07-30 22:22:38 +00:00
# Set security prefs to allow us to close our own window,
# pageloader test (and possibly other tests) needs this on.
2004-04-13 23:48:24 +00:00
set_pref ( $ pref_file , 'dom.allow_scripts_to_close_windows' , 'true' ) ;
# Suppress firefox's popup blocking
if ( $ Settings:: BinaryName =~ /^firefox/ ) {
set_pref ( $ pref_file , 'privacy.popups.firstTime' , 'false' ) ;
set_pref ( $ pref_file , 'dom.disable_open_during_load' , 'false' ) ;
2002-07-30 22:22:38 +00:00
}
2003-03-06 03:02:32 +00:00
# Suppress security warnings for QA test.
2004-04-13 23:48:24 +00:00
if ( $ Settings:: QATest ) {
set_pref ( $ pref_file , 'security.warn_submit_insecure' , 'true' ) ;
2003-03-06 03:02:32 +00:00
}
2002-07-30 22:22:38 +00:00
}
2000-03-22 00:18:06 +00:00
}
2002-07-30 22:22:38 +00:00
#
# Assume that we want to test modern skin for all tests.
#
2004-04-13 23:48:24 +00:00
if ( $ pref_file && $ test_result eq 'success' and $ Settings:: UseMozillaProfile ) { #XXX lame
2002-07-30 22:22:38 +00:00
if ( system ( "\\grep -s general.skins.selectedSkin $pref_file > /dev/null" ) ) {
print_log "Setting general.skins.selectedSkin to modern/1.0\n" ;
open PREFS , ">>$pref_file" or die "can't open $pref_file ($?)\n" ;
print PREFS "user_pref(\"general.skins.selectedSkin\", \"modern/1.0\");\n" ;
close PREFS ;
} else {
print_log "Modern skin already set.\n" ;
}
2001-11-16 01:13:34 +00:00
}
2002-07-30 22:22:38 +00:00
# Mozilla alive test
#
# Note: Bloat & other tests depend this on working.
# Only disable this test if you know it passes and are
# debugging another part of the test sequence. -mcafee
#
if ( $ Settings:: AliveTest and $ test_result eq 'success' ) {
$ test_result = AliveTest ( "MozillaAliveTest" , $ build_dir ,
2002-10-20 07:28:24 +00:00
[ $ binary , "-P" , $ Settings:: MozProfileName ] ,
2002-07-30 22:22:38 +00:00
$ Settings:: AliveTestTimeout ) ;
}
2001-11-16 01:13:34 +00:00
2002-07-30 22:22:38 +00:00
# Mozilla java test
if ( $ Settings:: JavaTest and $ test_result eq 'success' ) {
2000-03-22 00:18:06 +00:00
2002-07-30 22:22:38 +00:00
# Workaround for rh7.1 & jvm < 1.3.0:
$ ENV { LD_ASSUME_KERNEL } = "2.2.5" ;
2000-03-22 00:18:06 +00:00
2002-07-30 22:22:38 +00:00
$ test_result = AliveTest ( "MozillaJavaTest" , $ build_dir ,
2002-10-20 07:28:24 +00:00
[ $ binary , "http://java.sun.com" ] ,
2002-07-30 22:22:38 +00:00
$ Settings:: JavaTestTimeout ) ;
2002-03-13 08:04:28 +00:00
}
2000-03-22 00:18:06 +00:00
2002-07-30 22:22:38 +00:00
# Viewer alive test
if ( $ Settings:: ViewerTest and $ test_result eq 'success' ) {
$ test_result = AliveTest ( "ViewerAliveTest" , $ build_dir ,
2002-10-20 07:28:24 +00:00
[ "$binary_dir/viewer" ] ,
2002-07-30 22:22:38 +00:00
$ Settings:: ViewerTestTimeout ) ;
2000-03-22 00:18:06 +00:00
}
2001-07-16 23:13:52 +00:00
2002-07-30 22:22:38 +00:00
# Embed test. Test the embedded app.
if ( $ Settings:: EmbedTest and $ test_result eq 'success' ) {
$ test_result = AliveTest ( "EmbedAliveTest" , $ build_dir ,
2002-10-20 07:28:24 +00:00
[ "$embed_binary_dir/$embed_binary_basename" ] ,
2002-07-30 22:22:38 +00:00
$ Settings:: EmbedTestTimeout ) ;
2000-03-22 00:18:06 +00:00
}
2001-07-16 23:13:52 +00:00
2002-07-30 22:22:38 +00:00
# Bloat test (based on nsTraceRefcnt)
if ( $ Settings:: BloatTest and $ test_result eq 'success' ) {
2003-02-18 00:22:42 +00:00
my @ app_args ;
2004-04-13 23:48:24 +00:00
if ( $ Settings:: BinaryName eq "TestGtkEmbed" ||
$ Settings:: BinaryName =~ /^firefox/ ) {
2003-02-18 00:22:42 +00:00
@ app_args = [ "resource:///res/bloatcycle.html" ] ;
} else {
@ app_args = [ "-f" , "bloaturls.txt" ] ;
}
$ test_result = BloatTest ( $ binary , $ build_dir ,
@ app_args , "" ,
$ Settings:: BloatTestTimeout ) ;
2002-03-25 08:26:34 +00:00
}
2001-07-16 23:13:52 +00:00
2002-07-30 22:22:38 +00:00
# New and improved bloat/leak test (based on trace-malloc)
if ( $ Settings:: BloatTest2 and $ test_result eq 'success' ) {
$ test_result = BloatTest2 ( $ binary , $ build_dir , $ Settings:: BloatTestTimeout ) ;
2000-03-22 00:18:06 +00:00
}
2002-07-30 22:22:38 +00:00
# Mail bloat/leak test.
# Needs:
# BUILD_MAIL_SMOKETEST=1 set in environment
# $Settings::CleanProfile = 0
#
# Manual steps for this test:
# 1) Create pop account qatest03/Ne!sc-pe
# 2) Login to this mail account, type in password, and select
# "remember password with password manager".
# 3) Add first recipient of new Inbox to AB, select "receives plaintext"
# 4) If mail send fails, sometimes nsmail-2 flakes, may need
# an occasional machine reboot.
#
2003-02-18 00:22:42 +00:00
if ( $ Settings:: MailBloatTest and $ test_result eq 'success'
and $ Settings:: UseMozillaProfile ) {
2000-03-22 00:18:06 +00:00
2002-07-30 22:22:38 +00:00
print_log "______________MailBloatTest______________\n" ;
2001-10-19 06:23:23 +00:00
2002-07-30 22:22:38 +00:00
my $ inbox_dir = "Mail/nsmail-2" ;
2001-10-19 06:23:23 +00:00
2002-07-30 22:22:38 +00:00
chdir ( "$profile_dir/$inbox_dir" ) ;
2001-10-19 06:23:23 +00:00
2002-07-30 22:22:38 +00:00
# Download new, test Inbox on top of existing one.
# wget will not re-download, using -N to check timestamps.
system ( "wget -N -T 60 http://www.mozilla.org/mailnews/bloat_Inbox" ) ;
2000-03-22 00:18:06 +00:00
2002-07-30 22:22:38 +00:00
# Replace the Inbox file.
unlink ( "Inbox" ) ;
system ( "cp bloat_Inbox Inbox" ) ;
2000-03-22 00:18:06 +00:00
2002-07-30 22:22:38 +00:00
# Remove the Inbox.msf file.
# unlink("Inbox.msf");
2000-03-22 00:18:06 +00:00
2002-10-20 07:28:24 +00:00
$ test_result = BloatTest ( $ binary , $ build_dir , [ "-mail" ] , "mail" ,
2002-07-30 22:22:38 +00:00
$ Settings:: MailBloatTestTimeout ) ;
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
# back to build_dir
chdir ( $ build_dir ) ;
2000-03-22 00:18:06 +00:00
}
2002-03-25 08:26:34 +00:00
2002-07-30 22:22:38 +00:00
# DomToTextConversion test
if ( ( $ Settings:: EditorTest or $ Settings:: DomToTextConversionTest )
and $ test_result eq 'success' ) {
$ test_result =
FileBasedTest ( "DomToTextConversionTest" , $ build_dir , $ binary_dir ,
2003-05-28 21:43:41 +00:00
[ "perl" , "TestOutSinks.pl" ] , $ Settings:: DomTestTimeout ,
2002-10-24 01:07:14 +00:00
"FAILED" , 0 , 0 ) ; # Timeout means failure.
2002-07-30 22:22:38 +00:00
}
2002-06-21 19:14:13 +00:00
2003-02-06 20:27:17 +00:00
# XpcomGlue test. Do not run this on MacOSX.
2002-12-17 09:04:00 +00:00
if ( $ Settings:: XpcomGlueTest and $ test_result eq 'success' ) {
$ test_result =
FileBasedTest ( "XpcomGlueTest" , $ build_dir , $ binary_dir ,
[ "nsTestSample" ] , $ Settings:: DomTestTimeout ,
"Test passed" , 1 , 0 ) ; # Timeout means failure.
2002-12-18 02:45:39 +00:00
if ( $ test_result eq 'testfailed' ) {
2002-12-21 02:46:17 +00:00
print_log "XpcomGlueTest: If this fails ask dougt\@netscape.com for help.\n" ;
2002-12-18 02:45:39 +00:00
}
2002-12-17 09:04:00 +00:00
}
2002-10-24 01:07:14 +00:00
2003-01-23 03:16:18 +00:00
# SeaMonkey Codesize test.
2002-10-24 01:07:14 +00:00
#
if ( $ Settings:: CodesizeTest and $ test_result eq 'success' ) {
2003-01-23 03:16:18 +00:00
CodesizeTest ( "SeaMonkeyCodesizeTest" , $ build_dir , 0 ) ;
}
2002-10-25 00:23:18 +00:00
2002-10-24 01:07:14 +00:00
2003-01-23 03:16:18 +00:00
# Embed Codesize test.
if ( $ Settings:: EmbedCodesizeTest and $ test_result eq 'success' ) {
CodesizeTest ( "EmbedCodesizeTest" , $ build_dir , 1 ) ;
2002-10-24 01:07:14 +00:00
}
2002-07-30 22:22:38 +00:00
# Layout performance test.
if ( $ Settings:: LayoutPerformanceTest and $ test_result eq 'success' ) {
2003-02-18 00:22:42 +00:00
my @ app_args ;
2004-04-13 23:48:24 +00:00
if ( $ Settings:: BinaryName eq "TestGtkEmbed" ||
$ Settings:: BinaryName =~ /^firefox/ ) {
2003-02-18 00:22:42 +00:00
@ app_args = [ $ binary ] ;
} else {
@ app_args = [ $ binary , "-P" , $ Settings:: MozProfileName ] ;
}
$ test_result = LayoutPerformanceTest ( "LayoutPerformanceTest" ,
$ build_dir ,
@ app_args ) ;
2001-04-09 22:44:49 +00:00
}
2002-12-17 03:13:52 +00:00
# QA test: Client-side JS, DOM/HTML/Views, form submission.
2002-12-26 22:44:55 +00:00
if ( $ Settings:: QATest and $ test_result eq 'success' ) {
$ test_result = QATest ( "QATest" ,
$ build_dir ,
$ binary_dir ,
[ $ binary , "-P" , $ Settings:: MozProfileName ] ) ;
}
2002-12-17 03:13:52 +00:00
2001-04-09 22:44:49 +00:00
2002-07-30 22:22:38 +00:00
# xul window open test.
#
if ( $ Settings:: XULWindowOpenTest and $ test_result eq 'success' ) {
my $ open_time ;
my $ test_name = "XULWindowOpenTest" ;
my $ binary_log = "$build_dir/$test_name.log" ;
2001-07-30 02:20:35 +00:00
2002-07-30 22:22:38 +00:00
# Settle OS.
2002-12-26 22:44:55 +00:00
run_system_cmd ( "sync; sleep 5" , 35 ) ;
2000-03-22 00:18:06 +00:00
2002-10-20 07:28:24 +00:00
my @ urlargs = ( - chrome , "file:$build_dir/mozilla/xpfe/test/winopen.xul" ) ;
2002-07-30 22:22:38 +00:00
if ( $ test_result eq 'success' ) {
$ open_time = AliveTestReturnToken ( $ test_name ,
$ build_dir ,
2002-10-20 07:28:24 +00:00
[ $ binary , "-P" , $ Settings:: MozProfileName , @ urlargs ] ,
2002-07-30 22:22:38 +00:00
$ Settings:: XULWindowOpenTestTimeout ,
"__xulWinOpenTime" ,
":" ) ;
chomp ( $ open_time ) ;
2000-03-22 00:18:06 +00:00
}
2002-07-30 22:22:38 +00:00
if ( $ open_time ) {
$ test_result = 'success' ;
my $ time = POSIX:: strftime "%Y:%m:%d:%H:%M:%S" , localtime ;
2002-07-19 21:03:01 +00:00
2002-07-30 22:22:38 +00:00
print_log "TinderboxPrint:" .
"<a title=\"Best nav open time of 9 runs\" href=\"http://$Settings::results_server/graph/query.cgi?testname=xulwinopen&tbox=" .
:: hostname ( ) . "&autoscale=1&days=7&avg=1&showpoint=$time,$open_time\">Txul:$open_time" . "ms</a>\n" ;
2002-07-19 21:03:01 +00:00
2002-07-30 22:22:38 +00:00
# Pull out samples data from log.
my $ raw_data = extract_token_from_file ( $ binary_log , "openingTimes" , "=" ) ;
chomp ( $ raw_data ) ;
if ( $ Settings:: TestsPhoneHome ) {
send_results_to_server ( $ open_time , $ raw_data ,
"xulwinopen" , :: hostname ( ) ) ;
}
} else {
$ test_result = 'testfailed' ;
2000-03-22 00:18:06 +00:00
}
}
2002-07-30 22:22:38 +00:00
if ( $ Settings:: StartupPerformanceTest and $ test_result eq 'success' ) {
2000-03-22 00:18:06 +00:00
2003-02-18 00:22:42 +00:00
# Win32 needs to do some url magic for file: urls.
my $ startup_build_dir = $ build_dir ;
if ( $ Settings:: OS =~ /^WIN/ ) {
$ startup_build_dir = $ win32_build_dir ;
}
my @ app_args ;
if ( $ Settings:: BinaryName eq "TestGtkEmbed" ) {
@ app_args = [] ;
} else {
@ app_args = [ "-P" , $ Settings:: MozProfileName ] ;
}
2001-10-30 07:34:34 +00:00
2002-08-12 15:51:00 +00:00
$ test_result = StartupPerformanceTest ( "StartupPerformanceTest" ,
$ binary ,
$ startup_build_dir ,
2003-02-18 00:22:42 +00:00
@ app_args ,
2002-08-13 02:15:26 +00:00
"file:$startup_build_dir/../startup-test.html" ) ;
2002-07-30 22:22:38 +00:00
}
2002-08-19 23:26:22 +00:00
return $ test_result ;
2000-03-22 00:18:06 +00:00
}
2004-04-13 23:48:24 +00:00
sub set_pref {
my ( $ pref_file , $ pref , $ value ) = @ _ ;
if ( system ( "\\grep -s $pref $pref_file > /dev/null" ) ) {
print_log "Setting $pref to $value\n" ;
open PREFS , ">>$pref_file" or die "can't open $pref_file ($?)\n" ;
print PREFS "user_pref(\"$pref\", $value);\n" ;
close PREFS ;
} else {
print_log "Already set $pref\n" ;
}
}
2000-03-22 00:18:06 +00:00
# Start up Mozilla, test passes if Mozilla is still alive
# after $timeout_secs (seconds).
#
sub AliveTest {
2002-10-20 07:28:24 +00:00
my ( $ test_name , $ build_dir , $ args , $ timeout_secs ) = @ _ ;
my $ binary = @$ args [ 0 ] ;
2000-03-22 00:45:13 +00:00
my $ binary_basename = File::Basename:: basename ( $ binary ) ;
my $ binary_dir = File::Basename:: dirname ( $ binary ) ;
2001-04-05 00:33:19 +00:00
my $ binary_log = "$build_dir/$test_name.log" ;
2000-03-22 00:18:06 +00:00
local $ _ ;
2002-03-25 08:26:34 +00:00
# Print out testname
print_log "\n\nRunning $test_name test ...\n" ;
2001-04-05 00:33:19 +00:00
2002-03-25 08:26:34 +00:00
# Debug
#print_log "\n\nbuild_dir = $build_dir ...\n";
#print_log "\n\nbinary_dir = $binary_dir ...\n";
#print_log "\n\nbinary = $binary ...\n";
2001-08-23 04:59:55 +00:00
2002-03-25 08:26:34 +00:00
# Print out timeout.
print_log "Timeout = $timeout_secs seconds.\n" ;
2001-04-05 00:33:19 +00:00
2002-10-20 07:28:24 +00:00
my $ result = run_cmd ( $ build_dir , $ binary_dir , $ args ,
2002-03-25 08:26:34 +00:00
$ binary_log , $ timeout_secs ) ;
2000-03-22 00:18:06 +00:00
2001-04-05 00:33:19 +00:00
print_logfile ( $ binary_log , "$test_name" ) ;
2001-11-30 02:02:57 +00:00
2000-03-22 00:18:06 +00:00
if ( $ result - > { timed_out } ) {
2001-04-05 00:33:19 +00:00
print_log "$test_name: $binary_basename successfully stayed up"
2002-03-25 08:26:34 +00:00
. " for $timeout_secs seconds.\n" ;
2000-03-22 00:18:06 +00:00
return 'success' ;
} else {
print_test_errors ( $ result , $ binary_basename ) ;
return 'testfailed' ;
}
}
2001-10-19 06:23:23 +00:00
# Same as AliveTest, but look for a token in the log and return
# the value. (used for startup iteration test).
sub AliveTestReturnToken {
2002-10-20 07:28:24 +00:00
my ( $ test_name , $ build_dir , $ args , $ timeout_secs , $ token , $ delimiter ) = @ _ ;
2002-03-25 08:26:34 +00:00
my $ status ;
my $ rv = 0 ;
# Same as in AliveTest, needs to match in order to find the log file.
2002-10-20 07:28:24 +00:00
my $ binary = @$ args [ 0 ] ;
2002-03-25 08:26:34 +00:00
my $ binary_basename = File::Basename:: basename ( $ binary ) ;
my $ binary_dir = File::Basename:: dirname ( $ binary ) ;
my $ binary_log = "$build_dir/$test_name.log" ;
2002-10-20 07:28:24 +00:00
$ status = AliveTest ( $ test_name , $ build_dir , $ args , $ timeout_secs ) ;
2002-03-25 08:26:34 +00:00
# Look for and return token
if ( $ status ) {
$ rv = extract_token_from_file ( $ binary_log , $ token , $ delimiter ) ;
2002-10-20 07:02:57 +00:00
chomp ( $ rv ) ;
2003-08-13 22:06:48 +00:00
chop ( $ rv ) if ( $ rv =~ /\r$/ ) ; # cygwin perl doesn't chomp dos-newlinesproperly so use chop.
2002-03-25 08:26:34 +00:00
if ( $ rv ) {
print "AliveTestReturnToken: token value = $rv\n" ;
}
}
return $ rv ;
2001-10-19 06:23:23 +00:00
}
2000-03-22 00:18:06 +00:00
# Run a generic test that writes output to stdout, save that output to a
# file, parse the file looking for failure token and report status based
# on that. A hack, but should be useful for many tests.
#
2002-04-13 05:27:01 +00:00
# test_name = Name of test we're gonna run, in $Settings::DistBin.
2000-03-22 00:18:06 +00:00
# testExecString = How to run the test
# testTimeoutSec = Timeout for hung tests, minimum test time.
2002-03-25 08:26:34 +00:00
# statusToken = What string to look for in test output to
2000-03-22 00:18:06 +00:00
# determine test status.
# statusTokenMeansPass = Default use of status token is to look for
# failure string. If this is set to 1, then invert logic to look for
# success string.
#
# timeout_is_ok = Don't report test failure if test times out.
#
# Note: I tried to merge this function with AliveTest(),
# the process flow control got too confusing :( -mcafee
#
sub FileBasedTest {
2002-10-20 07:28:24 +00:00
my ( $ test_name , $ build_dir , $ binary_dir , $ test_args , $ timeout_secs ,
2000-03-22 00:18:06 +00:00
$ status_token , $ status_token_means_pass , $ timeout_is_ok ) = @ _ ;
local $ _ ;
2002-10-20 07:28:24 +00:00
# Assume the app is the first argument in the array.
my ( $ binary_basename ) = @$ test_args [ 0 ] ;
2000-03-22 00:18:06 +00:00
my $ binary_log = "$build_dir/$test_name.log" ;
2002-03-25 08:26:34 +00:00
# Print out test name
print_log "\n\nRunning $test_name ...\n" ;
2001-04-05 00:33:19 +00:00
2002-10-20 07:28:24 +00:00
my $ result = run_cmd ( $ build_dir , $ binary_dir , $ test_args ,
2002-03-25 08:26:34 +00:00
$ binary_log , $ timeout_secs ) ;
2000-03-22 00:18:06 +00:00
print_logfile ( $ binary_log , $ test_name ) ;
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
if ( ( $ result - > { timed_out } ) and ( ! $ timeout_is_ok ) ) {
2002-12-26 22:44:55 +00:00
print_log "Error: $test_name timed out after $timeout_secs seconds.\n" ;
return 'testfailed' ;
2000-03-22 00:18:06 +00:00
} elsif ( $ result - > { exit_value } != 0 ) {
2002-12-26 22:44:55 +00:00
print_log "Error: $test_name exited with status $result->{exit_value}\n" ;
print_test_errors ( $ result , $ test_name ) ;
return 'testfailed' ;
2000-03-22 00:18:06 +00:00
} else {
2002-12-26 22:44:55 +00:00
print_log "$test_name exited normally\n" ;
2000-03-22 00:18:06 +00:00
}
my $ found_token = file_has_token ( $ binary_log , $ status_token ) ;
if ( $ found_token ) {
print_log "Found status token in log file: $status_token\n" ;
} else {
print_log "Status token, $status_token, not found\n" ;
}
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
if ( ( $ status_token_means_pass and $ found_token ) or
( not $ status_token_means_pass and not $ found_token ) ) {
return 'success' ;
} else {
print_log "Error: $test_name has failed.\n" ;
return 'testfailed' ;
}
} # FileBasedTest
2001-06-19 21:57:07 +00:00
2002-08-08 02:44:54 +00:00
sub LayoutPerformanceTest {
2002-10-20 07:28:24 +00:00
my ( $ test_name , $ build_dir , $ args ) = @ _ ;
2002-08-08 02:44:54 +00:00
my $ layout_test_result ;
my $ layout_time ;
my $ layout_time_details ;
my $ binary_log = "$build_dir/$test_name.log" ;
my $ url = "http://$Settings::pageload_server/page-loader/loader.pl?delay=1000&nocache=0&maxcyc=4&timeout=$Settings::LayoutPerformanceTestPageTimeout&auto=1" ;
# Settle OS.
2002-12-26 22:44:55 +00:00
run_system_cmd ( "sync; sleep 5" , 35 ) ;
2002-08-08 02:44:54 +00:00
$ layout_time = AliveTestReturnToken ( $ test_name ,
$ build_dir ,
2002-10-20 07:28:24 +00:00
[ @$ args , $ url ] ,
2002-08-08 02:44:54 +00:00
$ Settings:: LayoutPerformanceTestTimeout ,
"_x_x_mozilla_page_load" ,
"," ) ;
if ( $ layout_time ) {
chomp ( $ layout_time ) ;
my @ times = split ( ',' , $ layout_time ) ;
$ layout_time = $ times [ 0 ] ; # Set layout time to first number.
} else {
print_log "TinderboxPrint:Tp:[CRASH]\n" ;
# Run the test a second time. Getting intermittent crashes, these
# are expensive to wait, a 2nd run that is successful is still useful.
# Sorry for the cut & paste. -mcafee
$ layout_time = AliveTestReturnToken ( $ test_name ,
$ build_dir ,
2002-10-20 07:28:24 +00:00
[ @$ args , $ url ] ,
2002-08-08 02:44:54 +00:00
$ Settings:: LayoutPerformanceTestTimeout ,
"_x_x_mozilla_page_load" ,
"," ) ;
# Print failure message if we fail 2nd time.
unless ( $ layout_time ) {
print_log "TinderboxPrint:Tp:[CRASH]\n" ;
} else {
chomp ( $ layout_time ) ;
my @ times = split ( ',' , $ layout_time ) ;
$ layout_time = $ times [ 0 ] ; # Set layout time to first number.
}
}
# Set test status.
if ( $ layout_time ) {
$ layout_test_result = 'success' ;
} else {
$ layout_test_result = 'testfailed' ;
}
if ( $ layout_test_result eq 'success' ) {
my $ time = POSIX:: strftime "%Y:%m:%d:%H:%M:%S" , localtime ;
2003-02-18 00:22:42 +00:00
my $ tp_prefix = "" ;
if ( $ Settings:: BinaryName eq "TestGtkEmbed" ) {
$ tp_prefix = "m" ;
}
2002-08-08 02:44:54 +00:00
print_log "TinderboxPrint:" .
"<a title=\"Avg of the median per url pageload time\" href=\"http://$Settings::results_server/graph/query.cgi?testname=pageload&tbox=" .
2003-02-18 00:22:42 +00:00
:: hostname ( ) . "&autoscale=1&days=7&avg=1&showpoint=$time,$layout_time\">" . $ tp_prefix . "Tp:$layout_time" . "ms</a>\n" ;
2002-08-08 02:44:54 +00:00
# Pull out detail data from log.
my $ raw_data = extract_token_from_file ( $ binary_log , "_x_x_mozilla_page_load_details" , "," ) ;
chomp ( $ raw_data ) ;
if ( $ Settings:: TestsPhoneHome ) {
send_results_to_server ( $ layout_time , $ raw_data , "pageload" , :: hostname ( ) ) ;
}
}
2002-07-30 22:22:38 +00:00
2002-08-08 02:44:54 +00:00
return $ layout_test_result ;
}
2002-07-30 22:22:38 +00:00
2003-01-23 03:16:18 +00:00
#
# Codesize test. Needs: cvs checkout mozilla/tools/codesighs
#
# This test can be run in two modes. One for the whole SeaMonkey
# tree, the other for just the embedding stuff.
#
sub CodesizeTest {
my ( $ test_name , $ build_dir , $ isEmbedTest ) = @ _ ;
2003-03-15 02:12:11 +00:00
my $ topsrcdir = "$build_dir/mozilla" ;
2003-01-23 03:16:18 +00:00
# test needs this set
$ ENV { MOZ_MAPINFO } = "1" ;
$ ENV { TINDERBOX_OUTPUT } = "1" ;
#chdir(".."); # up one level.
my $ cwd = get_system_cwd ( ) ;
print_log "cwd = $cwd\n" ;
my $ type ; # "auto" or "base"
my $ zee ; # Letter that shows up on tbox.
my $ testNameString ;
2003-01-23 03:48:15 +00:00
my $ graphName ;
2003-01-23 03:16:18 +00:00
if ( $ isEmbedTest ) {
$ testNameString = "Embed" ;
$ type = "base" ; # Embed test.
2003-01-23 03:48:15 +00:00
$ zee = "mZ" ;
$ graphName = "codesize_embed" ;
2003-01-23 03:16:18 +00:00
} else {
$ testNameString = "SeaMonkey" ;
$ type = "auto" ; # SeaMonkey test.
$ zee = "Z" ;
2003-01-23 03:48:15 +00:00
$ graphName = "codesize" ;
2003-01-23 03:16:18 +00:00
}
my $ new_log = "Codesize-" . $ type . "-new.log" ;
my $ old_log = "Codesize-" . $ type . "-old.log" ;
my $ diff_log = "Codesize-" . $ type . "-diff.log" ;
my $ test_log = "$test_name.log" ;
2003-08-13 22:06:48 +00:00
print_log "\$build_dir = $build_dir\n" ;
2003-01-23 03:16:18 +00:00
# Clear the logs from the last run, so we can properly test for success.
unlink ( "$build_dir/$new_log" ) ;
unlink ( "$build_dir/$diff_log" ) ;
unlink ( "$build_dir/$test_log" ) ;
2003-08-13 22:06:48 +00:00
my $ bash_cmd = "$topsrcdir/tools/codesighs/" ;
2003-03-15 02:12:11 +00:00
if ( $ Settings:: OS =~ /^WIN/ && $ Settings:: Compiler ne "gcc" ) {
$ bash_cmd . = $ type . "summary.win.bash" ;
2003-01-23 03:16:18 +00:00
} else {
# Assume Linux for non-windows for now.
2003-03-15 02:12:11 +00:00
$ bash_cmd . = $ type . "summary.unix.bash" ;
2003-01-23 03:16:18 +00:00
}
2003-03-15 02:12:11 +00:00
2003-08-13 22:06:48 +00:00
my $ cmd = [ "bash" , $ bash_cmd ] ;
push ( @ { $ cmd } , "-o" , "$objdir" ) if ( $ Settings:: ObjDir ne "" ) ;
push ( @ { $ cmd } , $ new_log , $ old_log , $ diff_log ) ;
2003-03-15 02:12:11 +00:00
2003-01-23 03:16:18 +00:00
my $ test_result =
FileBasedTest ( $ test_name ,
"$build_dir" ,
"$build_dir" , # run top of tree, not in dist.
2003-08-13 22:06:48 +00:00
$ cmd ,
2003-01-23 03:16:18 +00:00
$ Settings:: CodesizeTestTimeout ,
"FAILED" , # Fake out failure mode, test file instead.
0 , 0 ) ; # Timeout means failure.
# Set status based on file creation.
if ( - e "$build_dir/$new_log" ) {
print_log "found $build_dir/$new_log\n" ;
$ test_result = 'success' ;
# Print diff data to tbox log.
if ( - e "$build_dir/$diff_log" ) {
print_logfile ( "$build_dir/$diff_log" , "codesize diff log" ) ;
}
#
# Extract data.
#
my $ z_data = extract_token_from_file ( "$build_dir/$test_log" , "__codesize" , ":" ) ;
chomp ( $ z_data ) ;
my $ time = POSIX:: strftime "%Y:%m:%d:%H:%M:%S" , localtime ;
my $ z_data_string = PrintSize ( $ z_data , 4 ) ;
print_log "TinderboxPrint:" .
2003-01-23 03:48:15 +00:00
"<a title=\"$testNameString: Code + data size of all shared libs & executables\" href=\"http://$Settings::results_server/graph/query.cgi?testname=$graphName&tbox=" .
2003-01-23 03:16:18 +00:00
:: hostname ( ) . "&autoscale=1&units=bytes&days=7&avg=0&showpoint=$time,$z_data\">$zee:$z_data_string" . "B</a>\n" ;
if ( $ Settings:: TestsPhoneHome ) {
2003-01-23 03:48:15 +00:00
send_results_to_server ( $ z_data , "--" , $ graphName , :: hostname ( ) ) ;
2003-01-23 03:16:18 +00:00
}
my $ zdiff_data = extract_token_from_file ( "$build_dir/$test_log" , "__codesizeDiff" , ":" ) ;
chomp ( $ zdiff_data ) ;
# Print out Zdiff if not zero. Testing "zero" by looking for "+0 ".
my $ zdiff_sample = substr ( $ zdiff_data , 0 , 3 ) ;
if ( not ( $ zdiff_sample eq "+0 " ) ) {
2003-01-23 03:55:44 +00:00
print_log "<a title=\"Change from last $zee value (+added/-subtracted)\" TinderboxPrint:" . $ zee . "diff:$zdiff_data</a>\n" ;
2003-01-23 03:16:18 +00:00
}
2003-01-30 03:27:36 +00:00
# Testing only! Moves the old log to some unique name for testing.
# my $time = POSIX::strftime "%d%H%M%S", localtime;
# rename("$build_dir/$old_log", "$build_dir/$old_log.$time");
2003-01-23 03:16:18 +00:00
# Get ready for next cycle.
rename ( "$build_dir/$new_log" , "$build_dir/$old_log" ) ;
2003-01-30 03:27:36 +00:00
2003-01-23 03:16:18 +00:00
} else {
print_log "Error: $build_dir/$new_log not found.\n" ;
$ test_result = 'buildfailed' ;
}
}
2002-12-17 03:13:52 +00:00
# Client-side JavaScript, DOM Core/HTML/Views, and Form Submission tests.
# Currently only available inside netscape firewall.
sub QATest {
2002-12-26 22:44:55 +00:00
my ( $ test_name , $ build_dir , $ binary_dir , $ args ) = @ _ ;
2002-12-17 03:13:52 +00:00
my $ binary_log = "$build_dir/$test_name.log" ;
my $ url = "http://geckoqa.mcom.com/ngdriver/cgi-bin/ngdriver.cgi?findsuites=suites&tbox=1" ;
# Settle OS.
2002-12-26 22:44:55 +00:00
run_system_cmd ( "sync; sleep 5" , 35 ) ;
2002-12-17 03:13:52 +00:00
2002-12-17 03:45:21 +00:00
my $ rv ;
2003-01-07 00:33:31 +00:00
2003-01-07 22:13:19 +00:00
$ rv = AliveTest ( "QATest_raw" , $ build_dir ,
[ @$ args , $ url ] ,
$ Settings:: QATestTimeout ) ;
2003-01-07 00:33:31 +00:00
# XXXX testing. -mcafee
2003-02-13 02:31:08 +00:00
$ rv = 'success' ;
2002-12-26 22:44:55 +00:00
2002-12-17 03:13:52 +00:00
# Post-process log of test output.
2003-01-07 00:33:31 +00:00
my $ mode = "express" ;
open QATEST , "perl $build_dir/../qatest.pl $build_dir/QATest_raw.log $mode |"
2002-12-27 03:15:21 +00:00
or die "Unable to run qatest.pl" ;
2003-01-07 00:33:31 +00:00
my $ qatest_html = "" ;
2002-12-27 03:15:21 +00:00
while ( <QATEST> ) {
2003-01-07 00:33:31 +00:00
chomp ;
#$_ =~ s/\"/"/g; #### it doesn't like this line
# $_ =~ s/\012//g;
### $_ =~ s/\s+\S/ /g; # compress whitespace.
$ qatest_html . = $ _ ;
2002-12-27 03:15:21 +00:00
}
close QATEST ;
2003-01-07 00:33:31 +00:00
print_log "\n" ;
# This works.
#$qatest_html = "<table border=2 cellspacing=0><tr%20valign=top><td> </td><td>Passed</td><td>Failed</td><td>Total</td><td>Died</td><td>% Passed</td><td>% Failed</td></tr><tr%20valign=top><td>DHTML</a></td><td>9</td><td>0</td><td>9</td><td>0</td><td>100</td><td>0</td></tr><tr%20valign=top><td>DOM VIEWS</a></td><td>2</td><td>0</td><td>2</td><td>0</td><td>100</td><td>0</td></tr><tr%20valign=top><td>Total:</td><td>11</td><td>0</td><td>11</td><td>0</td><td>100</td><td>0</td></tr></table>";
# Testing output
open TEST_OUTPUT , ">qatest_out.log" ;
print TEST_OUTPUT $ qatest_html ;
close TEST_OUTPUT ;
2002-12-17 03:13:52 +00:00
2003-01-07 00:33:31 +00:00
print_log "TinderboxPrint:<a href=\"javascript:var newwin;newwin=window.open("","","menubar=no,resizable=yes,height=150,width=500");var newdoc=newwin.document;newdoc.write('$qatest_html');newdoc.close();\">QA</a>\n" ;
2002-12-17 03:13:52 +00:00
2002-12-26 22:44:55 +00:00
return $ rv ; # Hard-coded for now.
2002-12-17 03:13:52 +00:00
}
2002-07-30 22:22:38 +00:00
2002-08-12 15:51:00 +00:00
# Startup performance test. Time how fast it takes the browser
# to start up. Some help from John Morrison to get this going.
#
# Needs user_pref("browser.dom.window.dump.enabled", 1);
# (or CPPFLAGS=-DMOZ_ENABLE_JS_DUMP in mozconfig since we
# don't have profiles for tbox right now.)
#
2002-08-13 02:15:26 +00:00
# $startup_url needs ?begin=<time> dynamically inserted.
#
2002-08-12 15:51:00 +00:00
sub StartupPerformanceTest {
2002-08-13 02:15:26 +00:00
my ( $ test_name , $ binary , $ build_dir , $ startup_test_args , $ startup_url ) = @ _ ;
2002-08-12 15:51:00 +00:00
my $ i ;
my $ startuptime ; # Startup time in ms.
my $ agg_startuptime = 0 ; # Aggregate startup time.
my $ startup_count = 0 ; # Number of successful runs.
my $ avg_startuptime = 0 ; # Average startup time.
my @ times ;
my $ startup_test_result = 'success' ;
for ( $ i = 0 ; $ i < 10 ; $ i + + ) {
# Settle OS.
run_system_cmd ( "sync; sleep 5" , 35 ) ;
# Generate URL of form file:///<path>/startup-test.html?begin=986869495000
# Where begin value is current time.
2002-10-20 07:28:24 +00:00
my ( $ time , $ url , $ cwd ) ;
2002-08-12 15:51:00 +00:00
#
# Test for Time::HiRes and report the time.
$ time = Time::PossiblyHiRes:: getTime ( ) ;
$ cwd = get_system_cwd ( ) ;
print "cwd = $cwd\n" ;
2002-08-13 02:15:26 +00:00
$ url = "$startup_url?begin=$time" ;
2002-08-12 15:51:00 +00:00
print "url = $url\n" ;
# Then load startup-test.html, which will pull off the begin argument
# and compare it to the current time to compute startup time.
# Since we are iterating here, save off logs as StartupPerformanceTest-0,1,2...
#
# -P $Settings::MozProfileName added 3% to startup time, assume one profile
# and get the 3% back. (http://bugzilla.mozilla.org/show_bug.cgi?id=112767)
#
if ( $ startup_test_result eq 'success' ) {
$ startuptime =
AliveTestReturnToken ( "StartupPerformanceTest-$i" ,
$ build_dir ,
2002-10-20 07:28:24 +00:00
[ $ binary , @$ startup_test_args , $ url ] ,
2002-08-12 15:51:00 +00:00
$ Settings:: StartupPerformanceTestTimeout ,
"__startuptime" ,
"," ) ;
2002-08-13 02:15:26 +00:00
} else {
print "Startup test failed.\n" ;
2002-08-12 15:51:00 +00:00
}
if ( $ startuptime ) {
$ startup_test_result = 'success' ;
# Add our test to the total.
$ startup_count + + ;
$ agg_startuptime += $ startuptime ;
# Keep track of the results in an array.
push ( @ times , $ startuptime ) ;
} else {
$ startup_test_result = 'testfailed' ;
}
} # for loop
if ( $ startup_test_result eq 'success' ) {
print_log "\nSummary for startup test:\n" ;
# Print startup times.
2002-10-21 04:44:36 +00:00
chomp ( @ times ) ;
2002-08-12 15:51:00 +00:00
my $ times_string = join ( " " , @ times ) ;
print_log "times = [$times_string]\n" ;
# Figure out the average startup time.
$ avg_startuptime = $ agg_startuptime / $ startup_count ;
print_log "Average startup time: $avg_startuptime\n" ;
my $ min_startuptime = min ( @ times ) ;
print_log "Minimum startup time: $min_startuptime\n" ;
2003-02-18 00:22:42 +00:00
my $ ts_prefix = "" ;
if ( $ Settings:: BinaryName eq "TestGtkEmbed" ) {
$ ts_prefix = "m" ;
}
2002-08-12 15:51:00 +00:00
my $ time = POSIX:: strftime "%Y:%m:%d:%H:%M:%S" , localtime ;
my $ print_string = "\n\nTinderboxPrint:<a title=\"Best startup time out of 10 startups\"href=\"http://$Settings::results_server/graph/query.cgi?testname=startup&tbox="
2003-02-18 00:22:42 +00:00
. :: hostname ( ) . "&autoscale=1&days=7&avg=1&showpoint=$time,$min_startuptime\">" . $ ts_prefix . "Ts:" . $ min_startuptime . "ms</a>\n\n" ;
2002-08-12 15:51:00 +00:00
print_log "$print_string" ;
# Report data back to server
if ( $ Settings:: TestsPhoneHome ) {
print_log "phonehome = 1\n" ;
send_results_to_server ( $ min_startuptime , $ times_string ,
"startup" , :: hostname ( ) ) ;
}
}
return $ startup_test_result ;
}
2002-07-30 22:22:38 +00:00
# Page loader/cycling mechanism (mozilla -f option):
2001-06-19 21:57:07 +00:00
# If you are building optimized, you need to add
2001-11-14 05:35:25 +00:00
# --enable-logrefcnt
2001-06-19 21:57:07 +00:00
# to turn the pageloader code on. These are on by default for debug.
#
2000-03-22 00:18:06 +00:00
sub BloatTest {
2002-10-20 07:28:24 +00:00
my ( $ binary , $ build_dir , $ bloat_args , $ bloatdiff_label , $ timeout_secs ) = @ _ ;
2000-03-22 00:45:13 +00:00
my $ binary_basename = File::Basename:: basename ( $ binary ) ;
my $ binary_dir = File::Basename:: dirname ( $ binary ) ;
2000-03-22 00:18:06 +00:00
my $ binary_log = "$build_dir/bloat-cur.log" ;
my $ old_binary_log = "$build_dir/bloat-prev.log" ;
local $ _ ;
rename ( $ binary_log , $ old_binary_log ) ;
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
unless ( - e "$binary_dir/bloaturls.txt" ) {
print_log "Error: bloaturls.txt does not exist.\n" ;
return 'testfailed' ;
}
2003-03-01 00:55:20 +00:00
my $ platform = $ Settings:: OS =~ /^WIN/ ? 'windows' : 'unix' ;
# If on Windows, make sure the urls file has dos lineendings, or
# mozilla won't parse the file correctly
if ( $ platform eq 'windows' ) {
my $ bu = "$binary_dir/bloaturls.txt" ;
open ( IN , "$bu" ) || die ( "$bu: $!\n" ) ;
open ( OUT , ">$bu.new" ) || die ( "$bu.new: $!\n" ) ;
while ( <IN> ) {
if ( ! m/\r\n$/ ) {
s/\n$/\r\n/ ;
}
print OUT "$_" ;
}
close ( IN ) ;
close ( OUT ) ;
File::Copy:: move ( "$bu.new" , "$bu" ) or die ( "move: $!\n" ) ;
}
2000-03-22 00:18:06 +00:00
$ ENV { XPCOM_MEM_BLOAT_LOG } = 1 ; # Turn on ref counting to track leaks.
2001-11-30 02:02:57 +00:00
2001-12-20 01:54:15 +00:00
# Build up binary command, look for profile.
2002-10-20 07:28:24 +00:00
my @ args = ( $ binary_basename ) ;
2003-02-18 00:22:42 +00:00
unless ( ( $ Settings:: MozProfileName eq "" ) or
( $ Settings:: BinaryName eq "TestGtkEmbed" ) ) {
2002-10-20 07:28:24 +00:00
@ args = ( @ args , "-P" , $ Settings:: MozProfileName ) ;
2001-12-20 01:54:15 +00:00
}
2002-10-20 07:28:24 +00:00
@ args = ( @ args , @$ bloat_args ) ;
2002-03-25 08:26:34 +00:00
2002-10-20 07:28:24 +00:00
my $ result = run_cmd ( $ build_dir , $ binary_dir , \ @ args , $ binary_log ,
2002-03-25 08:26:34 +00:00
$ timeout_secs ) ;
2002-03-13 08:04:28 +00:00
$ ENV { XPCOM_MEM_BLOAT_LOG } = 0 ;
2000-03-22 00:18:06 +00:00
delete $ ENV { XPCOM_MEM_BLOAT_LOG } ;
2002-02-05 00:48:59 +00:00
print_logfile ( $ binary_log , "$bloatdiff_label bloat test" ) ;
2002-03-25 08:26:34 +00:00
2000-03-22 00:18:06 +00:00
if ( $ result - > { timed_out } ) {
2002-03-25 08:26:34 +00:00
print_log "Error: bloat test timed out after"
. " $timeout_secs seconds.\n" ;
return 'testfailed' ;
2000-03-22 00:18:06 +00:00
} elsif ( $ result - > { exit_value } ) {
2002-03-25 08:26:34 +00:00
print_test_errors ( $ result , $ binary_basename ) ;
return 'testfailed' ;
2000-03-22 00:18:06 +00:00
}
2001-12-20 01:54:15 +00:00
# Print out bloatdiff stats, also look for TOTAL line for leak/bloat #s.
2000-03-22 00:18:06 +00:00
print_log "<a href=#bloat>\n######################## BLOAT STATISTICS\n" ;
2001-12-20 01:54:15 +00:00
my $ found_total_line = 0 ;
my @ total_line_array ;
2001-12-10 00:00:07 +00:00
open DIFF , "perl $build_dir/../bloatdiff.pl $build_dir/bloat-prev.log $binary_log $bloatdiff_label|"
2002-03-25 08:26:34 +00:00
or die "Unable to run bloatdiff.pl" ;
2001-12-20 01:54:15 +00:00
while ( <DIFF> ) {
2002-03-25 08:26:34 +00:00
print_log $ _ ;
# Look for fist TOTAL line
unless ( $ found_total_line ) {
if ( /TOTAL/ ) {
@ total_line_array = split ( " " , $ _ ) ;
$ found_total_line = 1 ;
}
2001-12-20 01:54:15 +00:00
}
}
2000-03-22 00:18:06 +00:00
close DIFF ;
print_log "######################## END BLOAT STATISTICS\n</a>\n" ;
2002-03-25 08:26:34 +00:00
2001-12-20 01:54:15 +00:00
# Scrape for leak/bloat totals from TOTAL line
2002-03-25 08:26:34 +00:00
# TOTAL 23 0% 876224
2001-12-20 01:54:15 +00:00
my $ leaks = $ total_line_array [ 1 ] ;
my $ bloat = $ total_line_array [ 3 ] ;
print_log "leaks = $leaks\n" ;
print_log "bloat = $bloat\n" ;
# Figure out what the label prefix is.
my $ label_prefix = "" ;
my $ testname_prefix = "" ;
unless ( $ bloatdiff_label eq "" ) {
2002-03-25 08:26:34 +00:00
$ label_prefix = "$bloatdiff_label " ;
$ testname_prefix = "$bloatdiff_label" . "_" ;
2001-12-20 01:54:15 +00:00
}
2001-12-20 06:08:25 +00:00
# Figure out testnames to send to server
2001-12-20 05:41:43 +00:00
my $ leaks_testname = "refcnt_leaks" ;
my $ bloat_testname = "refcnt_bloat" ;
unless ( $ bloatdiff_label eq "" ) {
2002-03-25 08:26:34 +00:00
$ leaks_testname = $ testname_prefix . "refcnt_leaks" ;
$ bloat_testname = $ testname_prefix . "refcnt_bloat" ;
2001-12-20 06:08:25 +00:00
}
# Figure out testname labels
2001-12-20 06:12:44 +00:00
my $ leaks_testname_label = "refcnt Leaks" ;
my $ bloat_testname_label = "refcnt Bloat" ;
2001-12-20 06:08:25 +00:00
unless ( $ bloatdiff_label eq "" ) {
2002-03-25 08:26:34 +00:00
$ leaks_testname_label = $ label_prefix . $ leaks_testname_label ;
$ bloat_testname_label = $ label_prefix . $ bloat_testname_label ;
2001-12-20 05:41:43 +00:00
}
2003-02-18 00:22:42 +00:00
my $ embed_prefix = "" ;
if ( $ Settings:: BinaryName eq "TestGtkEmbed" ) {
$ embed_prefix = "m" ;
}
2001-12-20 05:41:43 +00:00
2001-12-20 01:54:15 +00:00
if ( $ Settings:: TestsPhoneHome ) {
2002-03-25 08:26:34 +00:00
# Generate and print tbox output strings for leak, bloat.
2004-01-21 20:56:42 +00:00
my $ leaks_string = "\n\nTinderboxPrint:<a title=\"" . $ leaks_testname_label . "\"href=\"http://$Settings::results_server/graph/query.cgi?testname=" . $ leaks_testname . "&units=bytes&tbox=" . :: hostname ( ) . "&autoscale=1&days=7&avg=1\">" . $ label_prefix . $ embed_prefix . "RLk:" . PrintSize ( $ leaks , 3 ) . "B</a>\n\n" ;
2002-03-25 08:26:34 +00:00
print_log $ leaks_string ;
# Report numbers to server.
send_results_to_server ( $ leaks , "--" , $ leaks_testname , :: hostname ( ) ) ;
2001-12-20 01:54:15 +00:00
} else {
2004-01-21 20:56:42 +00:00
print_log "TinderboxPrint:" . $ label_prefix . $ embed_prefix . "RLk:<a title=\"" . $ leaks_testname_label . "\">" . PrintSize ( $ leaks , 3 ) . "B</a>\n\n" ;
2001-12-20 01:54:15 +00:00
}
2000-03-22 00:18:06 +00:00
return 'success' ;
}
2001-11-14 05:35:25 +00:00
# Page loader (-f option):
# If you are building optimized, you need to add
# --enable-trace-malloc --enable-perf-metrics
# to turn the pageloader code on. If you are building debug you only
# need
# --enable-trace-malloc
#
sub ReadLeakstatsLog ($) {
my ( $ filename ) = @ _ ;
my $ leaks = 0 ;
my $ leaked_allocs = 0 ;
my $ mhs = 0 ;
my $ bytes = 0 ;
my $ allocs = 0 ;
open LEAKSTATS , "$filename"
2002-03-25 08:26:34 +00:00
or die "unable to open $filename" ;
2001-11-14 05:35:25 +00:00
while ( <LEAKSTATS> ) {
chop ;
my $ line = $ _ ;
if ( $ line =~ /Leaks: (\d+) bytes, (\d+) allocations/ ) {
$ leaks = $ 1 ;
$ leaked_allocs = $ 2 ;
} elsif ( $ line =~ /Maximum Heap Size: (\d+) bytes/ ) {
$ mhs = $ 1 ;
} elsif ( $ line =~ /(\d+) bytes were allocated in (\d+) allocations./ ) {
$ bytes = $ 1 ;
$ allocs = $ 2 ;
}
}
return {
2002-03-25 08:26:34 +00:00
'leaks' = > $ leaks ,
'leaked_allocs' = > $ leaked_allocs ,
'mhs' = > $ mhs ,
'bytes' = > $ bytes ,
'allocs' = > $ allocs
} ;
2001-11-14 05:35:25 +00:00
}
sub PercentChange ($$) {
my ( $ old , $ new ) = @ _ ;
if ( $ old == 0 ) {
return 0 ;
}
return ( $ new - $ old ) / $ old ;
}
2001-11-17 06:05:40 +00:00
# Print a value of bytes out in a reasonable
2002-12-05 00:09:16 +00:00
# KB, MB, or GB form. Sig figs should probably
# be 3, 4, or 5 for most purposes here. This used
# to default to 3 sig figs, but I wanted 4 so I
# generalized here. -mcafee
#
# Usage: PrintSize(valueAsInteger, numSigFigs)
#
sub PrintSize ($$) {
2001-11-14 05:35:25 +00:00
# print a number with 3 significant figures
2002-12-05 00:09:16 +00:00
sub PrintNum ($$) {
my ( $ num , $ sigs ) = @ _ ;
2001-11-14 05:35:25 +00:00
my $ rv ;
2002-12-05 00:09:16 +00:00
# Figure out how many decimal places to show.
# Only doing a few cases here, for normal range
# of test numbers.
2002-12-06 18:52:32 +00:00
# Handle zero case first.
if ( $ num == 0 ) {
$ rv = "0" ;
} elsif ( $ num < 10 ** ( $ sigs - 5 ) ) {
2002-12-05 00:09:16 +00:00
$ rv = sprintf "%.5f" , ( $ num ) ;
} elsif ( $ num < 10 ** ( $ sigs - 4 ) ) {
$ rv = sprintf "%.4f" , ( $ num ) ;
} elsif ( $ num < 10 ** ( $ sigs - 3 ) ) {
$ rv = sprintf "%.3f" , ( $ num ) ;
} elsif ( $ num < 10 ** ( $ sigs - 2 ) ) {
$ rv = sprintf "%.2f" , ( $ num ) ;
} elsif ( $ num < 10 ** ( $ sigs - 1 ) ) {
$ rv = sprintf "%.1f" , ( $ num ) ;
2001-11-14 05:35:25 +00:00
} else {
2002-12-05 00:09:16 +00:00
$ rv = sprintf "%d" , ( $ num ) ;
2001-11-14 05:35:25 +00:00
}
2002-12-05 00:09:16 +00:00
2001-11-14 05:35:25 +00:00
}
2002-12-05 00:09:16 +00:00
my ( $ size , $ sigfigs ) = @ _ ;
# 1K = 1024, previously this was approximated as 1000.
2001-11-14 05:35:25 +00:00
my $ rv ;
2002-12-05 00:09:16 +00:00
if ( $ size > 1073741824 ) { # 1024^3
$ rv = PrintNum ( $ size / 1073741824.0 , $ sigfigs ) . "G" ;
} elsif ( $ size > 1048576 ) { # 1024^2
$ rv = PrintNum ( $ size / 1048576.0 , $ sigfigs ) . "M" ;
} elsif ( $ size > 1024 ) {
$ rv = PrintNum ( $ size / 1024.0 , $ sigfigs ) . "K" ;
2001-11-14 05:35:25 +00:00
} else {
2002-12-05 00:09:16 +00:00
$ rv = PrintNum ( $ size , $ sigfigs ) ;
2001-11-14 05:35:25 +00:00
}
}
sub BloatTest2 {
my ( $ binary , $ build_dir , $ timeout_secs ) = @ _ ;
my $ binary_basename = File::Basename:: basename ( $ binary ) ;
my $ binary_dir = File::Basename:: dirname ( $ binary ) ;
2003-03-16 07:53:31 +00:00
my $ PERL = $^X ;
2003-08-28 07:22:43 +00:00
if ( $ Settings:: OS =~ /^WIN/ && $ build_dir !~ m/^.:\// ) {
chomp ( $ build_dir = `cygpath -w $build_dir` ) ;
$ build_dir =~ s/\\/\//g ;
2002-03-13 08:04:28 +00:00
$ PERL = "perl" ;
2002-03-25 08:26:34 +00:00
}
2001-11-14 05:35:25 +00:00
my $ binary_log = "$build_dir/bloattest2.log" ;
my $ malloc_log = "$build_dir/malloc.log" ;
2001-11-19 23:29:48 +00:00
my $ sdleak_log = "$build_dir/sdleak.log" ;
my $ old_sdleak_log = "$build_dir/sdleak.log.old" ;
2001-11-14 05:35:25 +00:00
my $ leakstats_log = "$build_dir/leakstats.log" ;
my $ old_leakstats_log = "$build_dir/leakstats.log.old" ;
2001-11-19 23:29:48 +00:00
my $ sdleak_diff_log = "$build_dir/sdleak.diff.log" ;
2001-11-14 05:35:25 +00:00
local $ _ ;
unless ( - e "$binary_dir/bloaturls.txt" ) {
print_log "Error: bloaturls.txt does not exist.\n" ;
return 'testfailed' ;
}
2003-03-01 00:55:20 +00:00
my $ platform = $ Settings:: OS =~ /^WIN/ ? 'windows' : 'unix' ;
# If on Windows, make sure the urls file has dos lineendings, or
# mozilla won't parse the file correctly
if ( $ platform eq 'windows' ) {
my $ bu = "$binary_dir/bloaturls.txt" ;
open ( IN , "$bu" ) || die ( "$bu: $!\n" ) ;
open ( OUT , ">$bu.new" ) || die ( "$bu.new: $!\n" ) ;
while ( <IN> ) {
if ( ! m/\r\n$/ ) {
s/\n$/\r\n/ ;
}
print OUT "$_" ;
}
close ( IN ) ;
close ( OUT ) ;
File::Copy:: move ( "$bu.new" , "$bu" ) or die ( "move: $!\n" ) ;
}
2001-11-19 23:29:48 +00:00
rename ( $ sdleak_log , $ old_sdleak_log ) ;
2003-02-18 00:22:42 +00:00
my @ args ;
2004-04-13 23:48:24 +00:00
if ( $ Settings:: BinaryName eq "TestGtkEmbed" ||
$ Settings:: BinaryName =~ /^firefox/ ) {
@ args = ( $ binary_basename , "-P" , $ Settings:: MozProfileName ,
"resource:///res/bloatcycle.html" ,
"--trace-malloc" , $ malloc_log ) ;
2003-02-18 00:22:42 +00:00
} else {
@ args = ( $ binary_basename , "-P" , $ Settings:: MozProfileName ,
2004-04-13 23:48:24 +00:00
"-f" , "bloaturls.txt" ,
"--trace-malloc" , $ malloc_log ) ;
2003-02-18 00:22:42 +00:00
}
2002-03-13 08:04:28 +00:00
# win32 builds crash on multiple runs when --shutdown-leaks is used
2002-10-20 07:28:24 +00:00
@ args = ( @ args , "--shutdown-leaks" , $ sdleak_log ) unless $ Settings:: OS =~ /^WIN/ ;
my $ result = run_cmd ( $ build_dir , $ binary_dir , \ @ args , $ binary_log ,
2002-03-25 08:26:34 +00:00
$ timeout_secs ) ;
2001-11-14 05:35:25 +00:00
2002-02-05 00:48:59 +00:00
print_logfile ( $ binary_log , "trace-malloc bloat test" ) ;
2002-03-25 08:26:34 +00:00
2001-11-14 05:35:25 +00:00
if ( $ result - > { timed_out } ) {
2002-03-25 08:26:34 +00:00
print_log "Error: bloat test timed out after"
. " $timeout_secs seconds.\n" ;
return 'testfailed' ;
2001-11-14 05:35:25 +00:00
} elsif ( $ result - > { exit_value } ) {
2002-03-25 08:26:34 +00:00
print_test_errors ( $ result , $ binary_basename ) ;
return 'testfailed' ;
2001-11-14 05:35:25 +00:00
}
rename ( $ leakstats_log , $ old_leakstats_log ) ;
2002-03-13 08:04:28 +00:00
if ( $ Settings:: OS =~ /^WIN/ ) {
2002-10-20 07:28:24 +00:00
@ args = ( "leakstats" , $ malloc_log ) ;
2002-03-13 08:04:28 +00:00
} else {
2002-10-20 07:28:24 +00:00
@ args = ( "run-mozilla.sh" , "./leakstats" , $ malloc_log ) ;
2002-03-13 08:04:28 +00:00
}
2002-10-20 07:28:24 +00:00
$ result = run_cmd ( $ build_dir , $ binary_dir , \ @ args , $ leakstats_log ,
2001-11-19 23:29:48 +00:00
$ timeout_secs ) ;
2002-02-05 00:48:59 +00:00
print_logfile ( $ leakstats_log , "trace-malloc bloat test: leakstats" ) ;
2001-11-14 05:35:25 +00:00
my $ newstats = ReadLeakstatsLog ( $ leakstats_log ) ;
my $ oldstats ;
if ( - e $ old_leakstats_log ) {
$ oldstats = ReadLeakstatsLog ( $ old_leakstats_log ) ;
} else {
$ oldstats = $ newstats ;
}
my $ leakchange = PercentChange ( $ oldstats - > { 'leaks' } , $ newstats - > { 'leaks' } ) ;
my $ mhschange = PercentChange ( $ oldstats - > { 'mhs' } , $ newstats - > { 'mhs' } ) ;
2002-02-01 19:01:40 +00:00
my $ leaks_testname_label = "Leaks: total bytes 'malloc'ed and not 'free'd" ;
my $ maxheap_testname_label = "Maximum Heap: max (bytes 'malloc'ed - bytes 'free'd) over run" ;
my $ allocs_testname_label = "Allocations: number of calls to 'malloc' and friends" ;
2003-02-18 00:22:42 +00:00
my $ embed_prefix = "" ;
if ( $ Settings:: BinaryName eq "TestGtkEmbed" ) {
$ embed_prefix = "m" ;
}
2002-02-01 19:01:40 +00:00
if ( $ Settings:: TestsPhoneHome ) {
2002-03-25 08:26:34 +00:00
my $ leaks_testname = "trace_malloc_leaks" ;
2003-02-18 00:22:42 +00:00
my $ leaks_string = "\n\nTinderboxPrint:<a title=\"" . $ leaks_testname_label . "\"href=\"http://$Settings::results_server/graph/query.cgi?testname=" . $ leaks_testname . "&units=bytes&tbox=" . :: hostname ( ) . "&autoscale=1&days=7&avg=1\">" . $ embed_prefix . "Lk:" . PrintSize ( $ newstats - > { 'leaks' } , 3 ) . "B</a>\n\n" ;
2002-03-25 08:26:34 +00:00
print_log $ leaks_string ;
2002-02-01 19:01:40 +00:00
2002-03-25 08:26:34 +00:00
my $ maxheap_testname = "trace_malloc_maxheap" ;
2003-02-18 00:22:42 +00:00
my $ maxheap_string = "\n\nTinderboxPrint:<a title=\"" . $ maxheap_testname_label . "\"href=\"http://$Settings::results_server/graph/query.cgi?testname=" . $ maxheap_testname . "&units=bytes&tbox=" . :: hostname ( ) . "&autoscale=1&days=7&avg=1\">" . $ embed_prefix . "MH:" . PrintSize ( $ newstats - > { 'mhs' } , 3 ) . "B</a>\n\n" ;
2002-03-25 08:26:34 +00:00
print_log $ maxheap_string ;
2002-02-01 19:01:40 +00:00
2002-03-25 08:26:34 +00:00
my $ allocs_testname = "trace_malloc_allocs" ;
2003-02-18 00:22:42 +00:00
my $ allocs_string = "\n\nTinderboxPrint:<a title=\"" . $ allocs_testname_label . "\"href=\"http://$Settings::results_server/graph/query.cgi?testname=" . $ allocs_testname . "&units=bytes&tbox=" . :: hostname ( ) . "&autoscale=1&days=7&avg=1\">" . $ embed_prefix . "A:" . PrintSize ( $ newstats - > { 'allocs' } , 3 ) . "</a>\n\n" ;
2002-03-25 08:26:34 +00:00
print_log $ allocs_string ;
2002-02-01 19:01:40 +00:00
2002-03-25 08:26:34 +00:00
# Send results to server.
send_results_to_server ( $ newstats - > { 'leaks' } , "--" , $ leaks_testname , :: hostname ( ) ) ;
send_results_to_server ( $ newstats - > { 'mhs' } , "--" , $ maxheap_testname , :: hostname ( ) ) ;
send_results_to_server ( $ newstats - > { 'allocs' } , "--" , $ allocs_testname , :: hostname ( ) ) ;
2002-02-01 19:01:40 +00:00
} else {
2002-12-27 09:43:21 +00:00
print_log "TinderboxPrint:<abbr title=\"$leaks_testname_label\">Lk</abbr>:" . PrintSize ( $ newstats - > { 'leaks' } , 3 ) . "B\n" ;
print_log "TinderboxPrint:<abbr title=\"$maxheap_testname_label\">MH</abbr>:" . PrintSize ( $ newstats - > { 'mhs' } , 3 ) . "B\n" ;
print_log "TinderboxPrint:<abbr title=\"$allocs_testname_label\">A</abbr>:" . PrintSize ( $ newstats - > { 'allocs' } , 3 ) . "\n" ;
2002-02-01 19:01:40 +00:00
}
2001-11-19 23:29:48 +00:00
if ( - e $ old_sdleak_log && - e $ sdleak_log ) {
2002-03-25 08:26:34 +00:00
print_logfile ( $ old_leakstats_log , "previous run of trace-malloc bloat test leakstats" ) ;
2002-10-20 07:28:24 +00:00
@ args = ( $ PERL , "$build_dir/mozilla/tools/trace-malloc/diffbloatdump.pl" , "--depth=15" , $ old_sdleak_log , $ sdleak_log ) ;
$ result = run_cmd ( $ build_dir , $ binary_dir , \ @ args , $ sdleak_diff_log ,
2002-03-25 08:26:34 +00:00
$ timeout_secs ) ;
print_logfile ( $ sdleak_diff_log , "trace-malloc leak stats differences" ) ;
2001-11-19 23:29:48 +00:00
}
2002-03-25 08:26:34 +00:00
2001-11-14 05:35:25 +00:00
return 'success' ;
}
2000-03-22 00:18:06 +00:00
2000-02-07 02:17:39 +00:00
# Need to end with a true value, (since we're using "require").
1 ;