*** empty log message ***
git-svn-id: svn://10.0.0.236/trunk@88090 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
63
mozilla/webtools/tinderbox2/src/clientbin/binary_runs
Normal file
63
mozilla/webtools/tinderbox2/src/clientbin/binary_runs
Normal file
@@ -0,0 +1,63 @@
|
||||
#!#perl# #perlflags# --
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
#
|
||||
|
||||
# binary_runs - exits with a zero exit code if the binary given on the
|
||||
# command line runs for several seconds, otherwise exits with a
|
||||
# nonzero exit code. This is a tool to be run in the Makefile,
|
||||
# usually by 'make test'.
|
||||
|
||||
|
||||
my (@Binary) = @ARGV;
|
||||
|
||||
my ($waittime) = 30;
|
||||
|
||||
my ($pid) = fork;
|
||||
|
||||
# check that the fork worked
|
||||
|
||||
( defined($pid) ) ||
|
||||
die("$0: Could not fork");
|
||||
|
||||
|
||||
|
||||
# child will become the application
|
||||
|
||||
($pid) ||
|
||||
exec(@Binary) ||
|
||||
die("$0: Could not exec $Binary");
|
||||
|
||||
|
||||
|
||||
# parent - wait $waittime seconds then check on child
|
||||
|
||||
sleep $waittime;
|
||||
my ($status) = waitpid $pid, WNOHANG();
|
||||
($status) &&
|
||||
die("$0: @Binary has crashed or quit. Turn the tree orange now.\n");
|
||||
|
||||
|
||||
print "$0: Success! @Binary is still running. Killing.\n";
|
||||
|
||||
|
||||
# try to kill 3 times, then try a kill -9
|
||||
my ($status);
|
||||
for ($i=0 ; $i<3 ; $i++) {
|
||||
kill 'TERM',$pid;
|
||||
|
||||
# give it 3 seconds to actually die
|
||||
sleep 3;
|
||||
|
||||
my ($status) = waitpid $pid, WNOHANG();
|
||||
($status) &&
|
||||
last;
|
||||
}
|
||||
|
||||
if ( $status == 0 ) {
|
||||
sleep 3;
|
||||
kill 'KILL',$pid;
|
||||
sleep 3;
|
||||
}
|
||||
|
||||
exit 0;
|
||||
|
||||
637
mozilla/webtools/tinderbox2/src/clientbin/build_shellscript
Executable file
637
mozilla/webtools/tinderbox2/src/clientbin/build_shellscript
Executable file
@@ -0,0 +1,637 @@
|
||||
#!#perl# #perlflags# --
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
#
|
||||
|
||||
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Tinderbox build tool.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
|
||||
# complete rewrite by Ken Estes, Mail.com (kestes@staff.mail.com).
|
||||
# Contributor(s):
|
||||
|
||||
# $Revision: 1.1 $
|
||||
# $Date: 2001-02-27 15:43:04 $
|
||||
# $Author: kestes%tradinglinx.com $
|
||||
# $Name: not supported by cvs2svn $
|
||||
|
||||
|
||||
# load standard perl libraries
|
||||
|
||||
use File::Basename;
|
||||
use Getopt::Long;
|
||||
use Sys::Hostname;
|
||||
|
||||
|
||||
# Tinderbox libraries
|
||||
|
||||
# The build script does not use the normal tinderbox libraries, it
|
||||
# does need its own local configuration file though. We find that
|
||||
# file via the normal libarary search path.
|
||||
|
||||
use lib '#tinder_libdir#';
|
||||
|
||||
|
||||
sub usage {
|
||||
|
||||
my ($usage) = <<"EOF";
|
||||
|
||||
$PROGRAM [options]
|
||||
|
||||
Global Options:
|
||||
(These options apply to all builds)
|
||||
|
||||
--once Do not loop repeadly.
|
||||
--noreport Do not mail status reorts to the tinderbox server.
|
||||
--test Print the build commands, do not run the build
|
||||
commands or mail logs.
|
||||
--build BUILDNAME The name of the build type to run
|
||||
--buildcf FILENAME Provide a config file instead of the default: '$BUILDCF'.
|
||||
--mailer MAILER Specify a different binary to use as the mailing
|
||||
program. The default is: '$MAILER'.
|
||||
--version Print the version number (same as cvs revision).
|
||||
--help view this help screen
|
||||
|
||||
|
||||
Build Options:
|
||||
(These depend on how you configure your builds and may not apply to
|
||||
your configuration. They are listed here as a suggestion only.)
|
||||
|
||||
--depend Build depend (must have this option or clobber).
|
||||
--clobber Build clobber (the oposite of depend).
|
||||
--tag TREETAG Checkout CVS sources by tag (-r TREETAG).
|
||||
--tree TREENAME Checkout CVS sources with module name TREENAME
|
||||
|
||||
Summary:
|
||||
|
||||
This program is an automated build client for the tinderbox server.
|
||||
Builds run continually and the build log file is mailed to tinderbox
|
||||
for analysis and display. This script assumes that the hard work in
|
||||
building the application is taken care of by developer supplied
|
||||
scripts (shell/Make). We are assuming that the effort involved in
|
||||
performing a build is similar to:
|
||||
|
||||
builddir=/tmp/build
|
||||
rm -rf \$builddir
|
||||
mkdir \$builddir
|
||||
cd \$builddir
|
||||
cvs checkout Project
|
||||
cd \$project
|
||||
./configure
|
||||
make all
|
||||
make test
|
||||
|
||||
A 'build' is a list (straight line) of commands run in sequence.
|
||||
Different lists of commands will have different names. Notice that
|
||||
there is a clear separation between the commands used to build the
|
||||
software and the developer provided scripts which perform the build
|
||||
(Makefiles, configuration scripts, developer provided build scripts).
|
||||
Developers are responsible for ensuring that they keep their project
|
||||
related build scripts up to date so that the build interface does not
|
||||
change too rapidly. The for a given project the build should always
|
||||
be performed using the same commands and any complex build processing
|
||||
should be performed inside developer maintained scripts (shell, perl
|
||||
Makefile).
|
||||
|
||||
Different sequences of build instructions have different 'build
|
||||
names'. How you name your builds depends on the type of build testing
|
||||
you are performing. You may have architecture build names:
|
||||
(Macintosh, Solaris, NT,) or project/subsystem specific build names
|
||||
(Sendmail, SeaMonkey, Apache).
|
||||
|
||||
What make this a bit compilcated is that several different parameters
|
||||
(clobber/dep, the branch name to checkout from version control,
|
||||
optimize/debug compilation flags, other application specific compile
|
||||
time flags) will likely be tested by the same build script so our
|
||||
notion of build must become flexible and encompass families of builds.
|
||||
This build script will preserve any arguments on the command line
|
||||
after the string '--' for use by the user supplied program which
|
||||
defines the builds.
|
||||
|
||||
It is assumed that each line in the build script can be safely
|
||||
executed in its own shell and that if any command fails it will exit
|
||||
with a non zero exit code. Failed builds are started again from the
|
||||
beginning during the next build cycle.
|
||||
|
||||
The build script can be examined by running this program with the
|
||||
'--test' argument. This will ensure that no commands are actually run
|
||||
but the list of commands that would be run when the '--test' argument
|
||||
is removed is sent to STDOUT for examination.
|
||||
|
||||
Before the logs can be mailed to tinderbox there must be information
|
||||
discribing how to display this information. Tinderbox maintains two
|
||||
variables for this purpose. The tinderbox tree name picks which web
|
||||
page the information will be displayed on. The tinderbox build name
|
||||
is the name used for the column that the data will be displayed in.
|
||||
Typically there is one deamon running continually for each column. It
|
||||
may be clearer to have different build names display on the tinderbox
|
||||
columns then are used by this build script.
|
||||
|
||||
Users should provide functions which prepare the tinderbox tree and
|
||||
build name based on both the command line arguments and the
|
||||
environment. These functions will need to return strings which are
|
||||
meaningful and informative for your local environment.
|
||||
|
||||
|
||||
|
||||
EOF
|
||||
;
|
||||
|
||||
print $usage;
|
||||
exit 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub set_static_vars {
|
||||
|
||||
# This functions sets all the static variables which are often
|
||||
# configuration parameters. Since it only sets variables to static
|
||||
# quantites it can not fail at run time. Some of these variables are
|
||||
# adjusted by parse_args() but asside from that none of these
|
||||
# variables are ever written to. All global variables are defined here
|
||||
# so we have a list of them and a comment of what they are for.
|
||||
|
||||
# Maximum length of a mail line imposed by your mailer.
|
||||
|
||||
$MAX_MAIL_LINE_LEN = 1000;
|
||||
|
||||
# These are useful mailers for testing
|
||||
|
||||
# $MAILER = '/bin/true';
|
||||
# $MAILER = 'cat > /tmp/mail.out';
|
||||
|
||||
# Usually we send mail to the tinderbox webserver but it is possible
|
||||
# to deliver mail directly if the build is running on the same
|
||||
# machine as the server.
|
||||
|
||||
$MAILER = '/usr/lib/sendmail -t';
|
||||
$MAILER = '/export/home/tinderbox2/bin/processmail_builds';
|
||||
|
||||
$ERROR_LOG= "/var/log/tinderbox2/build.log";
|
||||
|
||||
$BUILDCF = "buildcf";
|
||||
|
||||
# minimum time between the start of consecutive builds. Tinderbox
|
||||
# requires this to be grater then 5 mintues.
|
||||
|
||||
$MINIMUM_BUILD_MINUTES = 8;
|
||||
|
||||
@ORIG_ARGV = @ARGV;
|
||||
|
||||
# accept the path from our environment.
|
||||
|
||||
# $ENV{'PATH'}= (
|
||||
# '/bin'.
|
||||
# ':/usr/bin'.
|
||||
# ':/usr/local/bin'.
|
||||
#
|
||||
# ':/opt/gnu/bin'.
|
||||
# ':/usr/ucb'.
|
||||
# ':/usr/ccs/bin'.
|
||||
# '');
|
||||
|
||||
# taint perl requires we clean up these bad environmental variables
|
||||
# and it dos not hurt to do it here.
|
||||
|
||||
delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV', 'LD_PRELOAD'};
|
||||
|
||||
# the version number of this tinderbox release.
|
||||
|
||||
$VERSION = '#tinder_version#';
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
sub get_env {
|
||||
|
||||
# this function sets variables similar to set_static variables. This
|
||||
# function may fail only if the OS is in a very strange state. after
|
||||
# we leave this function we should be all set up to give good error
|
||||
# handling, should things fail.
|
||||
|
||||
# This function should run as early as possible (directly after
|
||||
# set_static_vars) so that the error environment is setup incase of
|
||||
# problems.
|
||||
|
||||
$| = 1;
|
||||
$PROGRAM = File::Basename::basename($0);
|
||||
$PID = $$;
|
||||
$TIME = time();
|
||||
$LOCALTIME = localtime($main::TIME);
|
||||
|
||||
$OS = $^O;
|
||||
$HOSTNAME = Sys::Hostname::hostname();
|
||||
|
||||
open (LOG , ">>$ERROR_LOG") ||
|
||||
die("Could not open logfile: $ERROR_LOG\n");
|
||||
|
||||
|
||||
$SIG{'__DIE__'} = \&fatal_error;
|
||||
$SIG{'__WARN__'} = \&log_warning;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub fatal_error {
|
||||
my @error = @_;
|
||||
foreach $_ (@error) {
|
||||
print LOG "[$LOCALTIME] $_";
|
||||
}
|
||||
print LOG "\n";
|
||||
|
||||
die("\n");
|
||||
}
|
||||
|
||||
|
||||
sub log_warning {
|
||||
my @error = @_;
|
||||
|
||||
foreach $_ (@error) {
|
||||
print LOG "[$LOCALTIME] $_";
|
||||
}
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub parse_args {
|
||||
|
||||
%option_linkage = (
|
||||
"version" => \$version,
|
||||
"help" => \$help,
|
||||
"build" => \$BUILD_NAME,
|
||||
"test" => \$TEST,
|
||||
"mail-each-phase" => \$MAIL_EACH_PHASE,
|
||||
"noreport" => \$NO_REPORT,
|
||||
"mailer" => \$MAILER,
|
||||
"buildcf" => \$BUILDCF,
|
||||
"once" => \$BUILD_ONCE,
|
||||
);
|
||||
|
||||
Getopt::Long::config('require_order', 'auto_abbrev', 'ignore_case');
|
||||
|
||||
if( !GetOptions (\%option_linkage,
|
||||
"version", "help",
|
||||
"build=s", "test!", "once",
|
||||
"mail-each-phase", "noreport!", "mailer=s", "buildcf=s",
|
||||
) ) {
|
||||
|
||||
print("Illegal options in \@ARGV: '@ARGV'\n");
|
||||
usage();
|
||||
exit 1 ;
|
||||
}
|
||||
|
||||
if($version) {
|
||||
print "Version: $VERSION\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
if ($help) {
|
||||
usage();
|
||||
}
|
||||
|
||||
($TEST) &&
|
||||
($BUILD_ONCE = 1);
|
||||
|
||||
(@CMD_LOG) =();
|
||||
|
||||
|
||||
return 1;
|
||||
} # parse_args
|
||||
|
||||
|
||||
sub set_server_args {
|
||||
|
||||
%args = (
|
||||
buildname => $BUILD_NAME,
|
||||
hostname => $HOSTNAME,
|
||||
program => $PROGRAM,
|
||||
os => $OS,
|
||||
argv => [@ARGV],
|
||||
);
|
||||
|
||||
# need to load UserDef from buildcf
|
||||
|
||||
UserDef::build_environment(%args);
|
||||
$BUILDS = UserDef::build_scripts(%args);
|
||||
$SERVER_TREE_NAME = UserDef::tree_name(%args);
|
||||
$SERVER_BUILD_NAME = UserDef::build_name(%args);
|
||||
$SERVER_ERROR_PARSER = UserDef::error_parser_name(%args);
|
||||
|
||||
|
||||
# person responsible for the build machines.
|
||||
$ADMINISTRATOR = UserDef::build_administrator();
|
||||
|
||||
$MAIL_FROM = UserDef::mail_from();
|
||||
$MAIL_TO = UserDef::mail_to();
|
||||
|
||||
check_builds();
|
||||
|
||||
($SERVER_TREE_NAME) ||
|
||||
die("Must define a tree name.\n");
|
||||
|
||||
($SERVER_BUILD_NAME) ||
|
||||
die("Must define a build name.\n");
|
||||
|
||||
($SERVER_ERROR_PARSER) ||
|
||||
die("Must define an error parser.\n");
|
||||
|
||||
($ADMINISTRATOR) ||
|
||||
die("Must define a build adminstrator.\n");
|
||||
|
||||
($MAIL_FROM) ||
|
||||
die("Must define a mailing address to send builds to.\n");
|
||||
|
||||
($MAIL_TO) ||
|
||||
die("Must define an account to have the builds be sent from.\n");
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
# Ensure that user defined build structure has all the manditory
|
||||
# parts.
|
||||
|
||||
sub check_builds {
|
||||
|
||||
foreach $build_name (sort keys %BUILDS) {
|
||||
foreach $i (0..$#{ $BUILDS{$build_name} }) {
|
||||
|
||||
$phase = $BUILDS{$build_name}[$i];
|
||||
my ($dir) = $phase->{'dir'};
|
||||
my ($error_status) = $phase->{'error_status'};
|
||||
my ($phase_name) = $phase->{'phase_name'};
|
||||
|
||||
($phase_name) ||
|
||||
die("phase_name not defined ".
|
||||
"in build: $build_name, phase: $i\n");
|
||||
|
||||
($dir) ||
|
||||
die("dir not defined ".
|
||||
"in build: $build_name, phase: $phase_name,\n");
|
||||
|
||||
($dir =~ m!^/!) ||
|
||||
die("dir does not specify an absolute path ".
|
||||
"in build: $build_name, phase: $phase_name,\n");
|
||||
|
||||
($error_status) ||
|
||||
die("error_status not defined ".
|
||||
"in build: $build_name, phase: $phase_name,\n");
|
||||
|
||||
($error_status eq 'success') ||
|
||||
die("error_status can not be set to 'success' ".
|
||||
"in build: $build_name, phase: $phase_name,\n");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Send mail to the tinderbox server notifying it of a completed build
|
||||
# sequence.
|
||||
|
||||
sub mail_tinderbox_cmdlog {
|
||||
my ($build_status) = @_;
|
||||
|
||||
$TIME = time();
|
||||
$LOCAL_TIME = localtime($TIME);
|
||||
|
||||
# ($SERVER_TREE_NAME && $BUILD_NAME) ||
|
||||
# die("mail_tinderbox_cmdlog requires both".
|
||||
# " TreeName and BuildName.\n");
|
||||
|
||||
|
||||
my ($message) = <<"EOF";
|
||||
|
||||
|
||||
From: $MAIL_FROM
|
||||
To: $MAIL_TO
|
||||
Subject: Tinderbox Build Update
|
||||
|
||||
|
||||
tinderbox: tree: $SERVER_TREE_NAME
|
||||
tinderbox: buildname: $SERVER_BUILD_NAME
|
||||
tinderbox: starttime: $START_TIME
|
||||
tinderbox: localstarttime: $LOCAL_START_TIME
|
||||
tinderbox: timenow: $TIME
|
||||
tinderbox: localtimenow: $LOCAL_TIME
|
||||
tinderbox: errorparser: $SERVER_ERROR_PARSER
|
||||
tinderbox: status: $build_status
|
||||
tinderbox: administrator: $ADMINISTRATOR
|
||||
tinderbox: END
|
||||
|
||||
|
||||
@CMD_LOG
|
||||
|
||||
|
||||
EOF
|
||||
;
|
||||
|
||||
# Split lines into less than 1000 char/line, many
|
||||
# mail systems (sendmail) require this.
|
||||
|
||||
$message =~ s/([^\n]{$MAX_MAIL_LINE_LEN})/$1\n/g;
|
||||
|
||||
# If any line is a dot on a line by itself, replace
|
||||
# that with a blank line. This is to prevent 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.
|
||||
|
||||
$message =~ s/^\.$/\.\./mg;
|
||||
|
||||
# If we are testing then @CMD_LOG contains the list of commands we
|
||||
# would have executed. This is where they get printed. We do not
|
||||
# need to mail the tinderbox server because the log is really
|
||||
# empty.
|
||||
|
||||
if ( ($NO_REPORT) || ($TEST) ){
|
||||
print $message;
|
||||
return 1;
|
||||
}
|
||||
|
||||
my ($pid) = open(MAIL, "|-");
|
||||
|
||||
# did we fork a new process?
|
||||
|
||||
defined ($pid) ||
|
||||
die("Could not fork for cmd: '$MAILER': $!\n");
|
||||
|
||||
# If we are the child exec.
|
||||
# Remember the exec function returns only if there is an error.
|
||||
|
||||
($pid) ||
|
||||
exec($MAILER) ||
|
||||
die("Could not exec: '$MAILER': $!\n");
|
||||
|
||||
print MAIL $message;
|
||||
|
||||
close(MAIL) or
|
||||
($?) or
|
||||
die("Could not close '$MAILER': $!\n");
|
||||
|
||||
($?) &&
|
||||
die("Could not close '$MAILER' wait_status: $? : $!\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
# Run one phase of the build process and report the status, stop if
|
||||
# any command fails.
|
||||
|
||||
sub run_shell_commands {
|
||||
my ($phase) = @_;
|
||||
|
||||
my ($dir) = $phase->{'dir'};
|
||||
my ($error_status) = $phase->{'error_status'};
|
||||
my ($phase_name) = $phase->{'phase_name'};
|
||||
|
||||
my $shell_status;
|
||||
|
||||
($TEST) ||
|
||||
chdir($dir) ||
|
||||
die("Could not chdir to $dir): $!\n");
|
||||
|
||||
push @CMD_LOG, ("\n>--- Starting Phase: $phase_name ".
|
||||
"(in dir: $dir) ---<\n\n");
|
||||
|
||||
foreach $shell_command (@{ $phase->{'script'} }) {
|
||||
|
||||
chomp($shell_command);
|
||||
$shell_command =~ s/\#.*//;
|
||||
|
||||
$shell_command =~ s/\s+/ /g;
|
||||
$shell_command =~ s/^\s+//;
|
||||
$shell_command =~ s/\s+$//;
|
||||
|
||||
($shell_command =~ m/^\s+$/) &&
|
||||
next;
|
||||
|
||||
push @CMD_LOG, ("> $shell_command\n");
|
||||
|
||||
# If we are testing do not run the commands, just add them to
|
||||
# the build log.
|
||||
|
||||
($TEST) &&
|
||||
next;
|
||||
|
||||
# I should replace this open() with an accept() so that if the
|
||||
# command takes 30 minutes to run we can still send log updates to
|
||||
# the tinderbox server every 10 minutes.
|
||||
|
||||
open(CMD, "$shell_command 2>&1 |") or
|
||||
die("Could not run '$shell_command': $!\n");
|
||||
|
||||
my (@results) = <CMD>;
|
||||
|
||||
push @CMD_LOG, (@results);
|
||||
|
||||
close(CMD) or
|
||||
($?) or
|
||||
die("Could not close '$shell_command': $!\n");
|
||||
|
||||
$shell_status = $?;
|
||||
|
||||
($shell_status) &&
|
||||
return $error_status;
|
||||
}
|
||||
|
||||
push @CMD_LOG, "\n";
|
||||
|
||||
return 'success';
|
||||
}
|
||||
|
||||
|
||||
|
||||
# This function ensures that build do not start too frequently. It
|
||||
# will sleep if and only if the last build finished too quickly.
|
||||
|
||||
sub slow_build_speed {
|
||||
|
||||
my ($actual_build_seconds) = $END_TIME - $START_TIME;
|
||||
my ($minimum_build_seconds) = 60 * $MINIMUM_BUILD_MINUTES;
|
||||
|
||||
my ($sleep_time) = 0;
|
||||
|
||||
if ($actual_build_seconds < $minimum_build_seconds) {
|
||||
$sleep_time = $actual_build_seconds - $minimum_build_seconds;
|
||||
}
|
||||
|
||||
sleep($sleep_time);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#--------------
|
||||
# Main function
|
||||
#--------------
|
||||
|
||||
{
|
||||
set_static_vars();
|
||||
get_env();
|
||||
parse_args();
|
||||
|
||||
require $BUILDCF;
|
||||
|
||||
set_server_args();
|
||||
|
||||
do { # foreach build
|
||||
|
||||
(@CMD_LOG) =();
|
||||
|
||||
$START_TIME = time();
|
||||
$LOCAL_START_TIME = localtime($START_TIME);
|
||||
|
||||
my ($status);
|
||||
|
||||
foreach $phase (@{ $BUILDS->{$BUILD_NAME} }) {
|
||||
|
||||
($MAIL_EACH_PHASE) &&
|
||||
mail_tinderbox_cmdlog('building');
|
||||
|
||||
$status = run_shell_commands($phase);
|
||||
|
||||
($status ne 'success') &&
|
||||
last;
|
||||
|
||||
} # foreach $phase
|
||||
|
||||
$END_TIME = time();
|
||||
$LOCAL_END_TIME = localtime($END_TIME);
|
||||
|
||||
mail_tinderbox_cmdlog($status);
|
||||
|
||||
($BUILD_ONCE) ||
|
||||
slow_build_speed();
|
||||
|
||||
} while (!($BUILD_ONCE)); # foreach build
|
||||
|
||||
exit 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
10
mozilla/webtools/tinderbox2/src/clientbin/ignore_waitstatus
Normal file
10
mozilla/webtools/tinderbox2/src/clientbin/ignore_waitstatus
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
# run @ARGV without interpolating any arguments (just pass the
|
||||
# arguments through to the child) then always exit 0.
|
||||
|
||||
# This shell script is safe to call from a taintperl program since it
|
||||
# does not interpolate its arguments.
|
||||
|
||||
"$@"
|
||||
exit 0
|
||||
455
mozilla/webtools/tinderbox2/src/clientbin/mozilla.unix.buildcf
Normal file
455
mozilla/webtools/tinderbox2/src/clientbin/mozilla.unix.buildcf
Normal file
@@ -0,0 +1,455 @@
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
|
||||
# mozilla.uinx.buildcf - this is an example buildcf which looks
|
||||
# similar to the way in which the original tinderbox build clients
|
||||
# work. It is untested and may not actually work but gives an idea
|
||||
# how I envision the buildcf working. This configuration file shows
|
||||
# what I believe belongs in the the build script and what part of the
|
||||
# original build script should be moved to the Makefile. Run --test to
|
||||
# see the completed build script which has all the vairiables
|
||||
# substituted.
|
||||
|
||||
|
||||
# $Revision: 1.1 $
|
||||
# $Date: 2001-02-27 15:43:20 $
|
||||
# $Author: kestes%tradinglinx.com $
|
||||
# $Source: /home/befator/cvs/jail/cvsroot/mozilla/webtools/tinderbox2/src/clientbin/mozilla.unix.buildcf,v $
|
||||
# $Name: not supported by cvs2svn $
|
||||
|
||||
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Tinderbox build tool.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
|
||||
# complete rewrite by Ken Estes, Mail.com (kestes@staff.mail.com).
|
||||
# Contributor(s):
|
||||
|
||||
|
||||
|
||||
package UserDef;
|
||||
|
||||
# User configurable variables live in their own namespace so that they
|
||||
# will not contaminate the build script. The buildscript will get the
|
||||
# values it needs via well known functions. This package may also set
|
||||
# %ENV to effect the build programs.
|
||||
|
||||
|
||||
|
||||
$BUILD_DIR = "/home/build";
|
||||
$BUILD_DIR = "/tmp/build";
|
||||
|
||||
$CVSROOT = ":pserver:kestes\@charzard:/export/home/cvsroot/libs";
|
||||
|
||||
# This is a non standard function and may not be needed for other
|
||||
# build requirments. The mozilla/netscape people wish to see the OS
|
||||
# name in a particular form and this function parses the uname to
|
||||
# return that string. This function is called by the function
|
||||
# build_environment() which is needed in every buildcf file.
|
||||
|
||||
sub GetSystemInfo {
|
||||
$OS = `uname -s`;
|
||||
$OSVer = `uname -r`;
|
||||
|
||||
chop($OS, $OSVer);
|
||||
|
||||
if ( $OS eq 'AIX' ) {
|
||||
$OSVer = `uname -v`;
|
||||
chop($OSVer);
|
||||
$OSVer = $OSVer . "." . `uname -r`;
|
||||
chop($OSVer);
|
||||
}
|
||||
|
||||
if ( $OS eq 'IRIX64' ) {
|
||||
$OS = 'IRIX';
|
||||
}
|
||||
|
||||
if ($OS eq 'QNX') {
|
||||
$os_ver = `uname -v`;
|
||||
chomp($os_ver);
|
||||
$os_ver =~ s/^([0-9])([0-9]*)$/$1.$2/;
|
||||
}
|
||||
|
||||
if ( $OS eq 'SCO_SV' ) {
|
||||
$OS = 'SCOOS';
|
||||
$OSVer = '5.0';
|
||||
}
|
||||
|
||||
if ( $OS eq 'HP-UX' ) {
|
||||
$OSVer = substr($OSVer,0,4);
|
||||
}
|
||||
|
||||
if ( $OS eq 'Linux' ) {
|
||||
$OSVer = substr($OSVer,0,3);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
# The environmental variables for building at mozilla/netscape are
|
||||
# quite complicated, your needs may be much simpler. Putting all
|
||||
# environmental variable differences into a single function makes it
|
||||
# clearer exactly how the environment differes on different platforms.
|
||||
|
||||
sub build_environment{
|
||||
|
||||
GetSystemInfo();
|
||||
#print "Path before: $ENV{PATH}\n";
|
||||
$ENV{PATH} .= ":$BaseDir/$DirName/mozilla/${ObjDir}/dist/bin";
|
||||
if ($OS eq 'AIX') {
|
||||
$ENV{PATH} = "/builds/local/bin:$ENV{PATH}:/usr/lpp/xlC/bin";
|
||||
$ConfigureArgs .= '--x-includes=/usr/include/X11 '
|
||||
. '--x-libraries=/usr/lib --disable-shared';
|
||||
$ConfigureEnvArgs = 'CC=xlC_r CXX=xlC_r';
|
||||
$Compiler = 'xlC_r';
|
||||
$NSPRArgs .= 'NS_USE_NATIVE=1 USE_PTHREADS=1';
|
||||
}
|
||||
|
||||
if ($OS eq 'BSD_OS') {
|
||||
$ENV{PATH} = "/usr/contrib/bin:/bin:/usr/bin:$ENV{PATH}";
|
||||
$ConfigureArgs .= '--disable-shared';
|
||||
$ConfigureEnvArgs = 'CC=shlicc2 CXX=shlicc2';
|
||||
$Compiler = 'shlicc2';
|
||||
$mail = '/usr/ucb/mail';
|
||||
# Because ld dies if it encounters -include
|
||||
$MakeOverrides = 'CPP_PROG_LINK=0 CCF=shlicc2';
|
||||
$NSPRArgs .= 'NS_USE_GCC=1 NS_USE_NATIVE=';
|
||||
}
|
||||
|
||||
if ($OS eq 'FreeBSD') {
|
||||
$ENV{PATH} = "/bin:/usr/bin:$ENV{PATH}";
|
||||
if ($ENV{HOST} eq 'angelus.mcom.com') {
|
||||
$ConfigureEnvArgs = 'CC=egcc CXX=eg++';
|
||||
$Compiler = 'egcc';
|
||||
}
|
||||
$mail = '/usr/bin/mail';
|
||||
}
|
||||
|
||||
if ($OS eq 'HP-UX') {
|
||||
$ENV{PATH} = "/opt/ansic/bin:/opt/aCC/bin:/builds/local/bin:"
|
||||
. "$ENV{PATH}";
|
||||
$ENV{LPATH} = "/usr/lib:$ENV{LD_LIBRARY_PATH}:/builds/local/lib";
|
||||
$ENV{SHLIB_PATH} = $ENV{LPATH};
|
||||
$ConfigureArgs .= '--x-includes=/usr/include/X11 '
|
||||
. '--x-libraries=/usr/lib --disable-gtktest ';
|
||||
$ConfigureEnvArgs = 'CC="cc -Ae" CXX="aCC -ext"';
|
||||
$Compiler = 'cc/aCC';
|
||||
# Use USE_PTHREADS=1 instead of CLASSIC_NSPR if DCE is installed.
|
||||
$NSPRArgs .= 'NS_USE_NATIVE=1 CLASSIC_NSPR=1';
|
||||
}
|
||||
|
||||
if ($OS eq 'IRIX') {
|
||||
$ENV{PATH} = "/opt/bin:$ENV{PATH}";
|
||||
$ENV{LD_LIBRARY_PATH} .= ':/opt/lib';
|
||||
$ENV{LD_LIBRARYN32_PATH} = $ENV{LD_LIBRARY_PATH};
|
||||
$ConfigureEnvArgs = 'CC=cc CXX=CC CFLAGS="-n32 -O" CXXFLAGS="-n32 -O"';
|
||||
$Compiler = 'cc/CC';
|
||||
$NSPRArgs .= 'NS_USE_NATIVE=1 USE_PTHREADS=1';
|
||||
}
|
||||
|
||||
if ($OS eq 'NetBSD') {
|
||||
$ENV{PATH} = "/bin:/usr/bin:$ENV{PATH}";
|
||||
$ENV{LD_LIBRARY_PATH} .= ':/usr/X11R6/lib';
|
||||
$ConfigureEnvArgs = 'CC=egcc CXX=eg++';
|
||||
$Compiler = 'egcc';
|
||||
$mail = '/usr/bin/mail';
|
||||
}
|
||||
|
||||
if ($OS eq 'OSF1') {
|
||||
$ENV{PATH} = "/usr/gnu/bin:$ENV{PATH}";
|
||||
$ENV{LD_LIBRARY_PATH} .= ':/usr/gnu/lib';
|
||||
$ConfigureEnvArgs = 'CC="cc -readonly_strings" CXX="cxx"';
|
||||
$Compiler = 'cc/cxx';
|
||||
$MakeOverrides = 'SHELL=/usr/bin/ksh';
|
||||
$NSPRArgs .= 'NS_USE_NATIVE=1 USE_PTHREADS=1';
|
||||
$ShellOverride = '/usr/bin/ksh';
|
||||
}
|
||||
|
||||
if ($OS eq 'QNX') {
|
||||
$ENV{PATH} = "/usr/local/bin:$ENV{PATH}";
|
||||
$ENV{LD_LIBRARY_PATH} .= ':/usr/X11/lib';
|
||||
$ConfigureArgs .= '--x-includes=/usr/X11/include '
|
||||
. '--x-libraries=/usr/X11/lib --disable-shared ';
|
||||
$ConfigureEnvArgs = 'CC="cc -DQNX" CXX="cc -DQNX"';
|
||||
$Compiler = 'cc';
|
||||
$mail = '/usr/bin/sendmail';
|
||||
}
|
||||
|
||||
if ($OS eq 'SunOS') {
|
||||
if ($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}";
|
||||
$ConfigureArgs .= '--x-includes=/home/motif/usr/include/X11 '
|
||||
. '--x-libraries=/home/motif/usr/lib';
|
||||
$ConfigureEnvArgs = 'CC="egcc -DSUNOS4" CXX="eg++ -DSUNOS4"';
|
||||
$Compiler = 'egcc';
|
||||
} else {
|
||||
$ENV{PATH} = '/usr/ccs/bin:' . $ENV{PATH};
|
||||
}
|
||||
if ($CPU eq 'i86pc') {
|
||||
$ENV{PATH} = '/opt/gnu/bin:' . $ENV{PATH};
|
||||
$ENV{LD_LIBRARY_PATH} .= ':/opt/gnu/lib';
|
||||
$ConfigureEnvArgs = 'CC=egcc CXX=eg++';
|
||||
$Compiler = 'egcc';
|
||||
|
||||
# Possible NSPR bug... If USE_PTHREADS is defined, then
|
||||
# _PR_HAVE_ATOMIC_CAS gets defined (erroneously?) and
|
||||
# libnspr21 does not work.
|
||||
$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:'
|
||||
. $ENV{LD_LIBRARY_PATH};
|
||||
$ConfigureEnvArgs = 'CC=cc CXX=CC';
|
||||
my $comptmp = `cc -V 2>&1 | head -1`;
|
||||
chomp($comptmp);
|
||||
$Compiler = "cc/CC \($comptmp\)";
|
||||
$NSPRArgs .= 'NS_USE_NATIVE=1';
|
||||
} else {
|
||||
$NSPRArgs .= 'NS_USE_GCC=1 NS_USE_NATIVE=';
|
||||
}
|
||||
if ($OSVerMajor eq '5') {
|
||||
$NSPRArgs .= ' USE_PTHREADS=1';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#print "Path after: $ENV{PATH}\n";
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub build_scripts {
|
||||
|
||||
my ($argv) = "@ARGV";
|
||||
|
||||
# the deps_target depends on a command line option. If the user runs
|
||||
# this script with --depend then we run 'make depend' otherwise we run
|
||||
# 'make realclean'
|
||||
|
||||
my ($deps_target);
|
||||
|
||||
|
||||
if ($argv =~ m/--depend/) {
|
||||
$deps_target = 'depend';
|
||||
} else {
|
||||
$deps_target = 'realclean';
|
||||
}
|
||||
|
||||
|
||||
my($tag);
|
||||
if ($argv =~ m/--tag\s*=?\s*(\w+)/) {
|
||||
$tag= $1;
|
||||
}
|
||||
|
||||
$BUILD_DIR = join('_',
|
||||
$OS,
|
||||
$OSVer,
|
||||
($BuildDepend?'Depend':'Clobber')
|
||||
);
|
||||
|
||||
$Make = 'gmake';
|
||||
$Autoconf = 'autoconf -l build/autoconf';
|
||||
$CVS = 'cvs -z3';
|
||||
$CVSCO_FLAGS = 'co -P';
|
||||
($tag) && ($CVSCO_FLAGS .= " -r $tag");
|
||||
|
||||
$CVS_Module ='';
|
||||
|
||||
$Make_flags = " MAKE='$Make -j $cpus' CVSCO='$CVS $CVSCO_FLAGS' ";
|
||||
$ConfigureArgs .= '--cache-file=/dev/null';
|
||||
|
||||
|
||||
|
||||
|
||||
# builds discribe a sequence of steps needed to perform a "build".
|
||||
# Each build either succeeds or fails. Builds can be used for running
|
||||
# tests and checking source code style in addition to creating binaries.
|
||||
|
||||
# Builds may depend on the environment, the OS or special arguments
|
||||
# passed to the program. Arguments which are passed after the '--'
|
||||
# are assumed to be build specific and are ignored by the build
|
||||
# harness and can be used in defining the build sequence.
|
||||
|
||||
# Builds can be architecture dependent (one build name can be used for
|
||||
# all architectures) or independent (each OS uses a different
|
||||
# buildname) depending on your application.
|
||||
|
||||
|
||||
# each build can have as many phases as
|
||||
# are needed (sample: checkout, configure, build, test)
|
||||
|
||||
|
||||
# Each phase must have the following entries:
|
||||
|
||||
# phase_name: which discribes what the phase is.
|
||||
|
||||
# error_status: the tinderbox status which should be returned
|
||||
# if the phase fails.
|
||||
|
||||
# script: a list of shell commands to be exectued in order
|
||||
# until one fails (each command in a separate shell, similar to make).
|
||||
|
||||
# dir: the directory which will be local while the script is
|
||||
# executing.
|
||||
|
||||
|
||||
|
||||
|
||||
$BUILDS = {
|
||||
'seamonkey' => [
|
||||
{
|
||||
'phase_name' => "print_environment",
|
||||
'error_status' => "build_failed",
|
||||
'dir' => "/",
|
||||
'script' => [
|
||||
"show_env",
|
||||
"rpm -qa",
|
||||
"showref -p",
|
||||
],
|
||||
},
|
||||
{
|
||||
'phase_name' => "checkout",
|
||||
'error_status' => "build_failed",
|
||||
'dir' => "$BUILD_DIR",
|
||||
'script' => [
|
||||
"$CVS $CVSCO_FLAGS $CVS_Module",
|
||||
"$Make $Make_flags -f mozilla/client.mk checkout",
|
||||
],
|
||||
},
|
||||
{
|
||||
'phase_name' => "configure",
|
||||
'error_status' => "build_failed",
|
||||
'dir' => "$BUILD_DIR/mozilla",
|
||||
'script' => [
|
||||
"$Topsrcdir/$Autoconf",
|
||||
"$ConfigureEnvArgs $Topsrcdir/../configure $ConfigureArgs",
|
||||
],
|
||||
},
|
||||
{
|
||||
'phase_name' => "build",
|
||||
'error_status' => "build_failed",
|
||||
'dir' => "$BUILD_DIR/mozilla",
|
||||
'script' => [
|
||||
"$Make $Make_flags $deps_target",
|
||||
"rm -rf dist",
|
||||
"rm -f webshell",
|
||||
"$Make $Make_flags all",
|
||||
"ls -l ./webshell/tests/viewer/viewer",
|
||||
],
|
||||
},
|
||||
{
|
||||
'phase_name' => "test",
|
||||
'error_status' => "test_failed",
|
||||
'dir' => "$BUILD_DIR/mozilla/test",
|
||||
'script' => [
|
||||
"$Make $Make_flags test",
|
||||
],
|
||||
},
|
||||
], # end seamonkey
|
||||
|
||||
|
||||
}; # end %BUILDS
|
||||
|
||||
return $BUILDS;
|
||||
}
|
||||
|
||||
|
||||
# If we are using this build script the tinderbox server should always
|
||||
# use the "unix" error parser to process the build logs.
|
||||
|
||||
sub error_parser_name {
|
||||
my (%args) = @_;
|
||||
|
||||
return 'unix';
|
||||
}
|
||||
|
||||
|
||||
# Our build names on the tinderbox server (column names) are the
|
||||
# hostname and OS name (and a few other details). We are running the
|
||||
# same build instructions on each architecture so it makes sense to
|
||||
# speak of the 'Solaris Build'. Other users who do not worry about
|
||||
# porability may use the buildscript buildname. These users will have
|
||||
# tinderbox colums with names like: "seamonkey", "grendel", "aurora"
|
||||
# (these are the names of the 'type' of build).
|
||||
|
||||
sub build_name {
|
||||
my (%args) = @_;
|
||||
|
||||
my ($argv) = "@ARGV";
|
||||
my ($depend) = ($argv =~ m/--depend/);
|
||||
|
||||
my ($build_name) = join('.',
|
||||
$args{'hostname'}, $args{'os'},
|
||||
$ENV{'OS'}, $ENV{'OSVer'},
|
||||
($depend?'Depend':'Clobber'));
|
||||
$build_name =~ s/\.\.+/\./g;
|
||||
|
||||
return $build_name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
# person responsible for the build machines.
|
||||
|
||||
sub build_administrator {
|
||||
return "your.mailing.addres\@company.com";
|
||||
}
|
||||
|
||||
# addressing information for the build messages
|
||||
|
||||
sub mail_to {
|
||||
return "tinderbox_builds\@cvs-mirror.mozilla.org";
|
||||
}
|
||||
|
||||
|
||||
sub mail_from
|
||||
return "tinderbox-build-daemon";
|
||||
}
|
||||
|
||||
|
||||
# Tell the tinderbox webserver what page to display the build
|
||||
# information. In our case we use the same build instructions for
|
||||
# several different products so this information must be passed in on
|
||||
# the command line. We must have this information or the build can
|
||||
# not be displayed on the webserver, so it is a fatal error not to
|
||||
# provide it.
|
||||
|
||||
|
||||
sub tree_name {
|
||||
my (%args) = @_;
|
||||
my ($tree);
|
||||
|
||||
my ($argv) = "@ARGV";
|
||||
if ($argv =~ m/--tree\s*=?\s*(\w+)/) {
|
||||
$tree= $1;
|
||||
} else {
|
||||
die("no tree specified on command line\n");
|
||||
}
|
||||
|
||||
return $1;
|
||||
}
|
||||
|
||||
|
||||
1;
|
||||
|
||||
62
mozilla/webtools/tinderbox2/src/clientbin/show_env
Normal file
62
mozilla/webtools/tinderbox2/src/clientbin/show_env
Normal file
@@ -0,0 +1,62 @@
|
||||
#!#perl# #perlflags# --
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
#
|
||||
|
||||
|
||||
# show_env - a pretty print replacement for the env command.
|
||||
|
||||
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is the Tinderbox build tool.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape Communications
|
||||
# Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
|
||||
# complete rewrite by Ken Estes, Mail.com (kestes@staff.mail.com).
|
||||
# Contributor(s):
|
||||
|
||||
# $Revision: 1.1 $
|
||||
# $Date: 2001-02-27 15:43:27 $
|
||||
# $Author: kestes%tradinglinx.com $
|
||||
# $Name: not supported by cvs2svn $
|
||||
|
||||
|
||||
sub pretty_print {
|
||||
# nicely format %env output
|
||||
|
||||
my ($str)=@_;
|
||||
|
||||
# protect single quotes with a backslash
|
||||
# $str = s!\'!\\\'!
|
||||
|
||||
$str =~ s!:!\'.\n\t\':!g;
|
||||
$str =~ s!,!\'.\n\t\',!g;
|
||||
$str =~ s!;!\'.\n\t\';!g;
|
||||
$str =~ s! !\'.\n\t\' !g;
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
||||
sub main {
|
||||
foreach $env (sort keys %ENV) {
|
||||
print "\$ENV{'$env'}='".
|
||||
&pretty_print($ENV{$env}).
|
||||
"';\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
&main();
|
||||
81
mozilla/webtools/tinderbox2/src/clientbin/test_return
Normal file
81
mozilla/webtools/tinderbox2/src/clientbin/test_return
Normal file
@@ -0,0 +1,81 @@
|
||||
#!#perl# #perlflags# --
|
||||
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
||||
#
|
||||
|
||||
# test_return - a fancy replacement for /bin/true and /bin/false.
|
||||
# This script is for testing how applications handle fatal errors in
|
||||
# their children.
|
||||
|
||||
|
||||
use Getopt::Long;
|
||||
use File::Basename;
|
||||
use POSIX;
|
||||
|
||||
sub usage {
|
||||
|
||||
my ($usage) = <<"EOF";
|
||||
|
||||
$PROGRAM [options]
|
||||
|
||||
Global Options:
|
||||
|
||||
|
||||
stdout print the given string on stdout before exiting.
|
||||
stderr print the given string on stderr before exiting.
|
||||
print a synonym for stdout.
|
||||
sleep wait S seconds before exiting.
|
||||
quit exit with the given return code.
|
||||
signal exit with the given signal number.
|
||||
|
||||
|
||||
|
||||
Summary:
|
||||
|
||||
A fancy replacement for /bin/true and /bin/false.
|
||||
|
||||
This script is for testing how applications handle fatal errors in
|
||||
their children.
|
||||
|
||||
|
||||
EOF
|
||||
;
|
||||
|
||||
print $usage;
|
||||
exit 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
sub parse_args {
|
||||
GetOptions (qw( stdout=s stderr=s print=s sleep=i quit=i signal=s)) ||
|
||||
die "Illegal options in \@ARGV: '@ARGV',";
|
||||
|
||||
if ($opt_stderr){
|
||||
warn "$opt_stderr\n";
|
||||
}
|
||||
|
||||
if ($opt_stdout){
|
||||
print "$opt_stdout\n";
|
||||
}
|
||||
|
||||
if ($opt_print){
|
||||
print "$opt_print\n";
|
||||
}
|
||||
|
||||
if ($opt_sleep){
|
||||
sleep($opt_sleep);
|
||||
}
|
||||
|
||||
if ($opt_quit){
|
||||
exit $opt_quit;
|
||||
}
|
||||
|
||||
if ($opt_signal) {
|
||||
$my_pid = $$;
|
||||
kill $opt_signal, $my_pid;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
parse_args();
|
||||
Reference in New Issue
Block a user