summaryrefslogtreecommitdiff
path: root/tests/run_test.pl
diff options
context:
space:
mode:
authorbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-12-14 18:45:34 +0000
committerbrunsch <brunsch@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-12-14 18:45:34 +0000
commit9d5225ea472ea6ec46bd77223b34191f7c6f389b (patch)
tree6c04a00db80e7825ef212e8a7484ed5e4547c2ae /tests/run_test.pl
parentfd8cc097db5cc6ba5001bce1437ffe2af1d6051e (diff)
downloadATCD-9d5225ea472ea6ec46bd77223b34191f7c6f389b.tar.gz
ChangeLogTag:Thu Dec 14 10:36:45 2000 Darrell Brunsch <brunsch@uci.edu>
Diffstat (limited to 'tests/run_test.pl')
-rwxr-xr-xtests/run_test.pl250
1 files changed, 170 insertions, 80 deletions
diff --git a/tests/run_test.pl b/tests/run_test.pl
index 6c689b2bcd5..8410dfbc9d1 100755
--- a/tests/run_test.pl
+++ b/tests/run_test.pl
@@ -7,138 +7,182 @@ eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
# This file is for running the tests in the ACE tests directory.
# It is usually used for auto_compiles.
-unshift @INC, '../bin';
-require ACEutils;
-
-if ($^O ne "MSWin32") {
- #### On platforms other than Windows, use run_tests.sh because
- #### it knows about the various test peculiarities.
- exec "${EXEPREFIX}run_tests.sh";
-}
+use lib '../bin';
+use PerlACE::Run_Test;
use Cwd;
use English;
use Getopt::Std;
+use FileHandle;
-if (!getopts ('tc:') || $opt_h) {
- print "run_test.pl [-h] [-c config] [-t] [file1 file2 ...]\n";
- print "\n";
- print "Runs the tests listed in run_test.lst\n";
- print "\n";
- print "Options:\n";
- print " -c config Run the tests for the <config> platform\n";
- print " -h display this help\n";
- print " -t Runs all the tests passed via the cmd line\n";
- print "\n";
- print "Configs: MSVC\n";
- exit (1);
-}
+$config_list = new PerlACE::ConfigList;
-if ($OSNAME eq 'MSWin32') {
- $config = 'MSVC';
-} else {
- $config = 'UNIX';
-}
+################################################################################
-if ($opt_c) {
- $config = $opt_c;
-}
-else {
- print "Defaulting to configuration: $config\n";
-}
+sub check_for_more_configs ()
+{
+ my $fh = new FileHandle;
+
+ if ($fh->open ("< ../ace/ACE_COMPONENTS.list")) {
+ while (<$fh>) {
+ if (m/ Other /) {
+ print "Adding 'Other' as my config\n" if defined $opt_d;
+ $config_list->add_one_config ('OTHER');
+ }
+ if (m/ Token /) {
+ print "Adding 'Token' as my config\n" if defined $opt_d;
+ $config_list->add_one_config ('TOKEN');
+ }
+ }
+
+ $fh->close ();
+ }
+ elsif (defined $opt_d) {
+ print "Could not open ACE_COMPONENTS.list file\n" if defined $opt_d;
+ print "Assuming TOKEN and OTHER subsets are included\n" if defined $opt_d;
+ $config_list->add_one_config ('OTHER');
+ $config_list->add_one_config ('TOKEN');
+ }
+
+ my $P = new PerlACE::Process ("../netsvcs/servers/main");
-if (!($tmp = $ENV{TMP})) {
- $tmp="/tmp";
+ if (!-x $P->Executable ()) {
+ $config_list->add_one_config ('missing_netsvcs');
+ }
}
################################################################################
-@tests = ();
-
-# Loads the list and runs it
-sub read_run_test_list ()
+sub record_resources ()
{
- my $line;
- open (LIST, "<run_test.lst")
- || die "Cannot open run_test.lst";
-
- while (<LIST>) {
- next if (/^#/ || /^\s*$/); # ignore comments and blank lines
+ if ($config_list->check_config ('CHECK_RESOURCES')) {
+ if (!defined $ENV{'LOGNAME'}) {
+ $user=`whoami`;
+ }
+ else {
+ $user = $ENV{'LOGNAME'};
+ }
+
+ $start_test_resources=`ipcs | egrep $user`;
+ }
+}
- chomp;
- my @stuff = split ":";
+################################################################################
- if (!/$config/) {
- my $program = shift @stuff;
- $program =~ s/\s*//g; #remove any extra whitepace
- push @tests, $program;
+sub check_resources ()
+{
+ if ($config_list->check_config ('CHECK_RESOURCES')) {
+ $end_test_resources=`ipcs | egrep $user`;
+
+ if ("$start_test_resources" ne "$end_test_resources") {
+ print STDERR "Warning: the ACE tests _may_ have leaked OS ".
+ "resources!\n";
+ print STDERR "Warning: Before: $start_test_resources\n";
+ print STDERR "Warning: After: $end_test_resources\n";
}
}
-
- close (LIST);
}
+################################################################################
+
sub run_program ($)
{
my $program = shift;
- $program_exe = $EXEPREFIX.$program.$EXE_EXT;
-
- unlink "core";
local $log = "log/".$program.".log";
unlink $log;
+ unlink "core";
+
+ my $P = new PerlACE::Process ($program);
### Try to run the program
- if (! -x $program_exe) {
- print STDERR "Error: $program_exe does not exist\n";
+ if (! -x $P->Executable ()) {
+ print STDERR "Error: " . $P->Executable () .
+ " does not exist or is not runnable\n";
return;
}
print STDERR "Running $program\n";
- $P = Process::Create ($program_exe, "");
- $status = $P->TimedWait (300);
+ $status = $P->SpawnWaitKill (300);
+
+ ### Check for problems
if ($status == -1) {
print STDERR "Error: $program FAILED (time out)\n";
- $P->Kill (); $P->TimedWait (1);
- } elsif ($status != 0) {
+ $P->Kill ();
+ $P->TimedWait (1);
+ }
+ elsif ($status != 0) {
print STDERR "Error: $program FAILED with exit status $status\n";
}
- check_log ($log);
+ check_log ($program, $log);
}
-sub check_log ($)
+################################################################################
+
+sub purify_program ($)
{
+ ### @todo
+
+ my $program = shift;
+
+ $program_exe = $program;
+
+ print STDERR "Purifying $program\n";
+
+ system ("purify ".
+ "/run ".
+ "/save-data=purify_results\$program.pfy ".
+ "/save-text-data=purify_results\$program.txt ".
+ "/AllocCallStackLength=20 ".
+ "/ErrorCallStackLength=20 ".
+ "/HandlesInUseAtExit ".
+ "/InUseAtExit ".
+ "/LeaksAtExit ".
+ "$program_exe");
+}
+
+################################################################################
+
+sub check_log ($$)
+{
+ my $program = shift;
my $log = shift;
+
### Check the logs
+
if (-e "core") {
- print STDERR "$program dumped core!!!!\n";
+ print STDERR "Error: $program dumped core\n";
+ unlink "core";
}
+
if (! -e $log ) {
print STDERR "Error: No log file ($log) is present\n";
- } else {
+ }
+ else {
if (open (LOG, "<".$log) == 0) {
print STDERR "Error: Cannot open log file $log\n";
- } else {
+ }
+ else {
my $starting_matched = 0;
my $ending_matched = 0;
-
+
while (<LOG>) {
chomp;
-
+
if (m/Starting/) {
$starting_matched = 1;
}
-
+
if (m/Ending/) {
$ending_matched = 1;
}
-
+
if (/LM\_ERROR\@(.*)$/) {
print STDERR "Error: ($log): $1\n";
- }
+ }
}
close (LOG); # ignore errors
@@ -146,15 +190,16 @@ sub check_log ($)
if ($starting_matched == 0) {
print STDERR "Error ($log): no line with 'starting'\n";
}
-
+
if ($ending_matched == 0) {
print STDERR "Error ($log): no line with 'Ending'\n";
}
-
}
}
}
+################################################################################
+
sub delete_temp_files ()
{
my @files = ('ace_pipe_name', 'pattern');
@@ -167,7 +212,7 @@ sub delete_temp_files ()
foreach $file (readdir (DIR)) {
if ($file =~ /^ace_temp_file/ || $file =~ /^Naming_Test/) {
- push @files, $tmp.$DIR_SEPARATOR.$file;
+ push @files, $tmp . '/' . $file;
}
}
closedir (DIR);
@@ -182,17 +227,62 @@ sub delete_temp_files ()
################################################################################
-if (!$opt_t) {
- read_run_test_list ();
+$config_list->load ("run_test.lst");
+
+if (!getopts ('dht') || $opt_h) {
+ print "run_test.pl [-h] [-t file1 file2 ...]\n";
+ print "\n";
+ print "Runs the tests listed in run_test.lst\n";
+ print "\n";
+ print "Options:\n";
+ print " -d Debug mode (do not run tests)\n";
+ print " -h Display this help\n";
+ print " -t Runs all the tests passed via the cmd line\n";
+ print "\n";
+ print "Pass in configs using \"-Config XXXXX\"\n";
+ print "\n";
+ print "Possible Configs: CHECK_RESOURCES Purify",
+ $config_list->list_configs (), "\n";
+ exit (1);
+}
+
+## since we can't use "our" to get rid of warnings.
+$opt_h = $opt_h if (defined $opt_h);
+$opt_t = $opt_t if (defined $opt_t);
+
+if (!($tmp = $ENV{TMP}) && !($tmp = $ENV{TEMP})) {
+ $tmp="/tmp";
}
-else {
+
+check_for_more_configs ();
+
+@tests = ();
+
+if (defined $opt_t) {
@tests = @ARGV;
}
+else {
+ @tests = $config_list->valid_entries ();
+}
+
+if (defined $opt_d) {
+ $config_list->dump ();
+}
+
+record_resources () if (!defined $opt_d);
foreach $test (@tests) {
- run_program ($test);
+ if (defined $opt_d) {
+ print "Would run test $test now\n";
+ }
+ elsif ($config_list->check_config ('Purify')) {
+ purify_program ($test);
+ }
+ else {
+ run_program ($test);
+ }
}
-delete_temp_files ();
+check_resources () if (!defined $opt_d);
-exit ();
+delete_temp_files ();