4 # This script is the beginnings of a script to run a sequence of test
5 # programs. See the MPICH document for a description of the test
6 # strategy and requirements.
9 # Tests are controlled by a file listing test programs; if the file is
10 # a directory, then all of the programs in the directory and subdirectories
13 # To run a test, the following steps are executed
14 # Build the executable:
17 # mpiexec -n <np> ./programname >out 2>err
18 # Check the return code (non zero is failure)
19 # Check the stderr output (non empty is failure)
20 # Check the stdout output (No Errors or Test passed are the only valid
22 # Remove executable, out, err files
24 # The format of a list file is
25 # programname number-of-processes
26 # If number-of-processes is missing, $np_default is used (this is 2 but can
27 # be overridden with -np=new-value)
30 # Because these tests can take a long time to run, there is an
31 # option to cause the tests to stop is a "stopfile" is found.
32 # The stopfile can be created by a separate, watchdog process, to ensure that
33 # tests end at a certain time.
34 # The name of this file is (by default) .stoptest
35 # in the top-level run directory. The environment variable
37 # can specify a different file name.
39 # Import the mkpath command
43 $MPIMajorVersion = "1";
44 $MPIMinorVersion = "1";
45 $mpiexec = "smpirun"; # Name of mpiexec program (including path, if necessary)
46 $testIsStrict = "true";
48 $np_arg = "-np"; # Name of argument to specify the number of processes
49 $err_count = 0; # Number of programs that failed.
50 $total_run = 0; # Number of programs tested
51 $total_seen = 0; # Number of programs considered for testing
52 $np_default = 2; # Default number of processes to use
53 $np_max = -1; # Maximum number of processes to use (overrides any
54 # value in the test list files. -1 is Infinity
55 $defaultTimeLimit = 180; # default timeout
57 $srcdir = "."; # Used to set the source dir for testlist files
59 $curdir = "."; # used to track the relative current directory
62 $xmloutput = 0; # Set to true to get xml output (also specify file)
63 $closeXMLOutput = 1; # Set to false to leave XML output file open to
64 # accept additional data
65 $verbose = 1; # Set to true to get more output
66 $showProgress = 0; # Set to true to get a "." with each run program.
67 $newline = "\r\n"; # Set to \r\n for Windows-friendly, \n for Unix only
68 $batchRun = 0; # Set to true to batch the execution of the tests
69 # (i.e., run them together, then test output,
70 # rather than build/run/check for each test)
71 $testCount = 0; # Used with batchRun to count tests.
72 $batrundir = "."; # Set to the directory into which to run the examples
75 # TAP (Test Anything Protocol) output
82 $depth = 0; # This is used to manage multiple open list files
88 my $program_wrapper = '';
90 #---------------------------------------------------------------------------
91 # Get some arguments from the environment
92 # Currently, only the following are understood:
94 # RUNTESTS_VERBOSE (an alias for VERBOSE in case you want to
96 # RUNTESTS_SHOWPROGRESS
99 # MPITEST_PROGRAM_WRAPPER (Value is added after -np but before test
100 # executable. Tools like valgrind may be inserted
102 #---------------------------------------------------------------------------
103 if ( defined($ENV{"VERBOSE"}) || defined($ENV{"V"}) || defined($ENV{"RUNTESTS_VERBOSE"}) ) {
106 if ( defined($ENV{"RUNTESTS_SHOWPROGRESS"} ) ) {
109 if (defined($ENV{"MPITEST_STOPTEST"})) {
110 $stopfile = $ENV{"MPITEST_STOPTEST"};
113 $stopfile = `pwd` . "/.stoptest";
114 $stopfile =~ s/\r*\n*//g; # Remove any newlines (from pwd)
117 if (defined($ENV{"MPITEST_TIMEOUT"})) {
118 $defaultTimeLimit = $ENV{"MPITEST_TIMEOUT"};
121 # Define this to leave the XML output file open to receive additional data
122 if (defined($ENV{'NOXMLCLOSE'}) && $ENV{'NOXMLCLOSE'} eq 'YES') {
126 if (defined($ENV{'MPITEST_PROGRAM_WRAPPER'})) {
127 $program_wrapper = $ENV{'MPITEST_PROGRAM_WRAPPER'};
130 if (defined($ENV{'MPITEST_BATCH'})) {
131 if ($ENV{'MPITEST_BATCH'} eq 'YES' || $ENV{'MPITEST_BATCH'} eq 'yes') {
133 } elsif ($ENV{'MPITEST_BATCH'} eq 'NO' || $ENV{'MPITEST_BATCH'} eq 'no') {
137 print STDERR "Unrecognized value for MPITEST_BATCH = $ENV{'MPITEST_BATCH'}\n";
140 if (defined($ENV{'MPITEST_BATCHDIR'})) {
141 $batrundir = $ENV{'MPITEST_BATCHDIR'};
144 #---------------------------------------------------------------------------
145 # Process arguments and override any defaults
146 #---------------------------------------------------------------------------
148 if (/--?mpiexec=(.*)/) {
149 # Use mpiexec as given - it may be in the path, and
150 # we don't want to bother to try and find it.
153 elsif (/--?np=(.*)/) { $np_default = $1; }
154 elsif (/--?maxnp=(.*)/) { $np_max = $1; }
155 elsif (/--?tests=(.*)/) { $listfiles = $1; }
156 elsif (/--?srcdir=(.*)/) { $srcdir = $1;
157 $mpiexec="$mpiexec -platform ${srcdir}/../../../../examples/platforms/small_platform_with_routers.xml -hostfile ${srcdir}/../../hostfile_coll --log=root.thr:critical --cfg=smpi/running_power:1e9 --cfg=smpi/async_small_thres:65536"; }
158 elsif (/--?verbose/) { $verbose = 1; }
159 elsif (/--?showprogress/) { $showProgress = 1; }
160 elsif (/--?debug/) { $debug = 1; }
161 elsif (/--?batch/) { $batchRun = 1; }
162 elsif (/--?batchdir=(.*)/) { $batrundir = $1; }
163 elsif (/--?timeoutarg=(.*)/) { $timeoutArgPattern = $1; }
164 elsif (/--?execarg=(.*)/) { $execarg = "$execarg $1"; }
165 elsif (/--?xmlfile=(.*)/) {
167 if (! ($xmlfile =~ /^\//)) {
170 $xmlfullfile = $thisdir . "/" . $xmlfile ;
173 $xmlfullfile = $xmlfile;
176 open( XMLOUT, ">$xmlfile" ) || die "Cannot open $xmlfile\n";
177 my $date = `date "+%Y-%m-%d-%H-%M"`;
179 # MPISOURCE can be used to describe the source of MPI for this
181 print XMLOUT "<?xml version='1.0' ?>$newline";
182 print XMLOUT "<?xml-stylesheet href=\"TestResults.xsl\" type=\"text/xsl\" ?>$newline";
183 print XMLOUT "<MPITESTRESULTS>$newline";
184 print XMLOUT "<DATE>$date</DATE>$newline";
185 print XMLOUT "<MPISOURCE></MPISOURCE>$newline";
187 elsif (/--?noxmlclose/) {
190 elsif (/--?tapfile=(.*)/) {
192 if ($tapfile !~ m|^/|) {
195 $tapfullfile = $thisdir . "/" . $tapfile ;
198 $tapfullfile = $tapfile;
201 open( TAPOUT, ">$tapfile" ) || die "Cannot open $tapfile\n";
202 my $date = `date "+%Y-%m-%d-%H-%M"`;
204 print TAPOUT "TAP version 13\n";
205 print TAPOUT "# MPICH test suite results (TAP format)\n";
206 print TAPOUT "# date ${date}\n";
207 # we do not know at this point how many tests will be run, so do
208 # not print a test plan line like "1..450" until the very end
211 print STDERR "Unrecognized argument $_\n";
212 print STDERR "runtests [-tests=testfile] [-np=nprocesses] \
213 [-maxnp=max-nprocesses] [-srcdir=location-of-tests] \
214 [-xmlfile=filename ] [-noxmlclose] \
215 [-verbose] [-showprogress] [-debug] [-batch]\n";
220 # Perform any post argument processing
222 if (! -d $batrundir) {
223 mkpath $batrundir || die "Could not create $batrundir\n";
225 open( BATOUT, ">$batrundir/runtests.batch" ) || die "Could not open $batrundir/runtests.batch\n";
228 # We must have mpiexec
229 if ("$mpiexec" eq "") {
230 print STDERR "No mpiexec found!\n";
237 if ($listfiles eq "") {
239 print STDERR "An implicit list of tests is not permitted in batch mode\n";
243 &ProcessImplicitList;
246 elsif (-d $listfiles) {
247 print STDERR "Testing by directories not yet supported\n";
250 &RunList( $listfiles );
253 if ($xmloutput && $closeXMLOutput) {
254 print XMLOUT "</MPITESTRESULTS>$newline";
259 print TAPOUT "1..$total_seen\n";
265 print "Programs created along with a runtest.batch file in $batrundir\n";
266 print "Run that script and then use checktests to summarize the results\n";
270 print "$err_count tests failed out of $total_run\n";
272 print "Details in $xmlfullfile\n";
276 print " All $total_run tests passed!\n";
279 print "TAP formatted results in $tapfullfile\n";
283 # ---------------------------------------------------------------------------
286 # Enter a new directory and process a list file.
287 # ProcessDir( directory-name, list-file-name )
289 my $dir = $_[0]; $dir =~ s/\/$//;
290 my $listfile = $_[1];
292 my $savecurdir = $curdir;
293 my $savesrcdir = $srcdir;
296 if (substr($srcdir,0,3) eq "../") {
297 $srcdir = "../$srcdir";
300 print "Processing directory $dir\n" if ($verbose || $debug);
303 print STDERR "only direct subdirectories allowed in list files";
307 &RunList( $listfile );
308 print "\n" if $showProgress; # Terminate line from progress output
310 $curdir = $savecurdir;
311 $srcdir = $savesrcdir;
313 # ---------------------------------------------------------------------------
314 # Run the programs listed in the file given as the argument.
315 # This file describes the tests in the format
316 # programname number-of-processes [ key=value ... ]
317 # If the second value is not given, the default value is used.
320 my $LIST = "LIST$depth"; $depth++;
321 my $listfile = $_[0];
324 my $listfileSource = $listfile;
326 print "Looking in $curdir/$listfile\n" if $debug;
327 if (! -s "$listfile" && -s "$srcdir/$curdir/$listfile" ) {
328 $listfileSource = "$srcdir/$curdir/$listfile";
330 open( $LIST, "<$listfileSource" ) ||
331 die "Could not open $listfileSource\n";
333 # Check for stop file
335 # Exit because we found a stopfile
336 print STDERR "Terminating test because stopfile $stopfile found\n";
341 # Remove any trailing newlines/returns
343 # Remove any leading whitespace
345 # Some tests require that support routines are built first
346 # This is specified with !<dir>:<target>
347 if (/^\s*\!([^:]*):(.*)/) {
348 # Hack: just execute in a subshell. This discards any
353 # List file entries have the form:
354 # program [ np [ name=value ... ] ]
355 # See files errhan/testlist, init/testlist, and spawn/testlist
356 # for examples of using the key=value form
357 my @args = split(/\s+/,$_);
358 my $programname = $args[0];
364 my $mpiexecArgs = "$execarg";
365 my $requiresStrict = "";
366 my $requiresMPIX = "";
370 if ($#args >= 1) { $np = $args[1]; }
371 # Process the key=value arguments
372 for (my $i=2; $i <= $#args; $i++) {
373 if ($args[$i] =~ /([^=]+)=(.*)/) {
376 if ($key eq "resultTest") {
377 $ResultTest = $value;
379 elsif ($key eq "init") {
380 $InitForRun = $value;
382 elsif ($key eq "timeLimit") {
385 elsif ($key eq "arg") {
386 $progArgs = "$progArgs $value";
388 elsif ($key eq "mpiexecarg") {
389 $mpiexecArgs = "$mpiexecArgs $value";
391 elsif ($key eq "env") {
392 $progEnv = "$progEnv $value";
394 elsif ($key eq "mpiversion") {
395 $mpiVersion = $value;
397 elsif ($key eq "strict") {
398 $requiresStrict = $value
400 elsif ($key eq "mpix") {
401 $requiresMPIX = $value
403 elsif ($key eq "xfail") {
405 print STDERR "\"xfail=\" requires an argument\n";
410 print STDERR "Unrecognized key $key in $listfileSource\n";
416 if ($programname eq "") { next; }
418 if ($np eq "") { $np = $np_default; }
419 if ($np_max > 0 && $np > $np_max) { $np = $np_max; }
421 # allows us to accurately output TAP test numbers without disturbing the
422 # original totals that have traditionally been reported
424 # These "unless" blocks are ugly, but permit us to honor skipping
425 # criteria for directories as well without counting directories as tests
426 # in our XML/TAP output.
427 unless (-d $programname) {
431 # If a minimum MPI version is specified, check against the
432 # available MPI. If the version is unknown, we ignore this
433 # test (thus, all tests will be run).
434 if ($mpiVersion ne "" && $MPIMajorVersion ne "unknown" &&
435 $MPIMinorVersion ne "unknown") {
436 my ($majorReq,$minorReq) = split(/\./,$mpiVersion);
437 if ($majorReq > $MPIMajorVersion or
438 ($majorReq == $MPIMajorVersion && $minorReq > $MPIMinorVersion))
440 unless (-d $programname) {
441 SkippedTest($programname, $np, $workdir, "requires MPI version $mpiVersion");
446 # Check whether strict is required by MPI but not by the
447 # test (use strict=false for tests that use non-standard extensions)
448 if (lc($requiresStrict) eq "false" && lc($testIsStrict) eq "true") {
449 unless (-d $programname) {
450 SkippedTest($programname, $np, $workdir, "non-strict test, strict MPI mode requested");
455 if (lc($testIsStrict) eq "true") {
456 # Strict MPI testing was requested, so assume that a non-MPICH MPI
457 # implementation is being tested and the "xfail" implementation
458 # assumptions do not hold.
462 if (lc($requiresMPIX) eq "true" && lc($MPIHasMPIX) eq "no") {
463 unless (-d $programname) {
464 SkippedTest($programname, $np, $workdir, "tests MPIX extensions, MPIX testing disabled");
469 if (-d $programname) {
470 # If a directory, go into the that directory and
471 # look for a new list file
472 &ProcessDir( $programname, $listfile );
476 if (&BuildMPIProgram( $programname, $xfail ) == 0) {
477 if ($batchRun == 1) {
478 &AddMPIProgram( $programname, $np, $ResultTest,
479 $InitForRun, $timeLimit, $progArgs,
480 $progEnv, $mpiexecArgs, $xfail );
483 &RunMPIProgram( $programname, $np, $ResultTest,
484 $InitForRun, $timeLimit, $progArgs,
485 $progEnv, $mpiexecArgs, $xfail );
488 elsif ($xfail ne '') {
489 # We expected to run this program, so failure to build
494 if ($batchRun == 0) {
495 &CleanUpAfterRun( $programname );
502 # This routine tries to run all of the files in the current
504 sub ProcessImplicitList {
505 # The default is to run every file in the current directory.
506 # If there are no built programs, build and run every file
507 # WARNING: This assumes that anything executable should be run as
511 open (PGMS, "ls -1 |" ) || die "Cannot list directory\n";
515 if (-d $programname) { next; } # Ignore directories
516 if ($programname eq "runtests") { next; } # Ignore self
517 if ($programname eq "checktests") { next; } # Ignore helper
518 if ($programname eq "configure") { next; } # Ignore configure script
519 if ($programname eq "config.status") { next; } # Ignore configure helper
520 if (-x $programname) { $found_exec++; }
521 if ($programname =~ /\.[cf]$/) { $found_src++; }
526 print "Found executables\n" if $debug;
527 open (PGMS, "ls -1 |" ) || die "Cannot list programs\n";
529 # Check for stop file
531 # Exit because we found a stopfile
532 print STDERR "Terminating test because stopfile $stopfile found\n";
537 if (-d $programname) { next; } # Ignore directories
538 if ($programname eq "runtests") { next; } # Ignore self
539 if (-x $programname) {
541 &RunMPIProgram( $programname, $np_default, "", "", "", "", "", "", "" );
547 print "Found source files\n" if $debug;
548 open (PGMS, "ls -1 *.c |" ) || die "Cannot list programs\n";
551 # Exit because we found a stopfile
552 print STDERR "Terminating test because stopfile $stopfile found\n";
557 # Skip messages from ls about no files
558 if (! -s $programname) { next; }
559 $programname =~ s/\.c//;
561 if (&BuildMPIProgram( $programname, "") == 0) {
562 &RunMPIProgram( $programname, $np_default, "", "", "", "", "", "", "" );
565 # We expected to run this program, so failure to build
570 &CleanUpAfterRun( $programname );
576 # ToDo: Add a way to limit the time that any particular program may run.
578 # name of program, number of processes, name of routine to check results
579 # init for testing, timelimit, and any additional program arguments
580 # If the 3rd arg is not present, the a default that simply checks that the
581 # return status is 0 and that the output is " No Errors" is used.
583 my ($programname,$np,$ResultTest,$InitForTest,$timeLimit,$progArgs,$progEnv,$mpiexecArgs,$xfail) = @_;
585 my $found_noerror = 0;
588 &RunPreMsg( $programname, $np, $curdir );
592 # Set a default timeout on tests (3 minutes for now)
593 my $timeout = $defaultTimeLimit;
594 if (defined($timeLimit) && $timeLimit =~ /^\d+$/) {
595 $timeout = $timeLimit;
597 $ENV{"MPIEXEC_TIMEOUT"} = $timeout;
599 # Run the optional setup routine. For example, the timeout tests could
600 # be set to a shorter timeout.
601 if ($InitForTest ne "") {
604 print STDOUT "Env includes $progEnv\n" if $verbose;
605 print STDOUT "$mpiexec $mpiexecArgs $np_arg $np $program_wrapper ./$programname $progArgs\n" if $verbose;
606 print STDOUT "." if $showProgress;
607 # Save and restore the environment if necessary before running mpiexec.
608 if ($progEnv ne "") {
610 foreach $val (split(/\s+/, $progEnv)) {
611 if ($val =~ /([^=]+)=(.*)/) {
615 print STDERR "Environment variable/value $val not in a=b form\n";
619 open ( MPIOUT, "$mpiexec $np_arg $np $mpiexecArgs $program_wrapper ./$programname $progArgs 2>&1 |" ) ||
620 die "Could not run ./$programname\n";
621 if ($progEnv ne "") {
624 if ($ResultTest ne "") {
625 # Read and process the output
626 ($found_error, $inline) = &$ResultTest( MPIOUT, $programname );
630 $inline = "$mpiexec $np_arg $np $program_wrapper ./$programname\n";
636 print STDOUT $_ if $verbose;
638 if (/FORTRAN STOP/) { next; }
640 if (/^\s*No [Ee]rrors\s*$/ && $found_noerror == 0) {
643 if (! /^\s*No [Ee]rrors\s*$/ && !/^\s*Test Passed\s*$/) {
644 print STDERR "Unexpected output in $programname: $_";
651 if ($found_noerror == 0) {
652 print STDERR "Program $programname exited without No Errors\n";
658 $rc = close ( MPIOUT );
660 # Only generate a message if we think that the program
664 $signal_num = $run_status & 127;
665 if ($run_status > 255) { $run_status >>= 8; }
666 print STDERR "Program $programname exited with non-zero status $run_status\n";
667 if ($signal_num != 0) {
668 print STDERR "Program $programname exited with signal $signal_num\n";
676 &RunTestFailed( $programname, $np, $curdir, $inline, $xfail );
679 &RunTestPassed( $programname, $np, $curdir, $xfail );
681 &RunPostMsg( $programname, $np, $curdir );
684 # This version simply writes the mpiexec command out, with the output going
685 # into a file, and recording the output status of the run.
687 my ($programname,$np,$ResultTest,$InitForTest,$timeLimit,$progArgs,$progEnv,$mpiexecArgs, $xfail) = @_;
689 if (! -x $programname) {
690 print STDERR "Could not find $programname!";
694 if ($ResultTest ne "") {
695 # This test really needs to be run manually, with this test
696 # Eventually, we can update this to include handleing in checktests.
697 print STDERR "Run $curdir/$programname with $np processes and use $ResultTest to check the results\n";
701 # Set a default timeout on tests (3 minutes for now)
702 my $timeout = $defaultTimeLimit;
703 if (defined($timeLimit) && $timeLimit =~ /^\d+$/) {
704 # On some systems, there is no effective time limit on
705 # individual mpi program runs. In that case, we may
706 # want to treat these also as "run manually".
707 $timeout = $timeLimit;
709 print BATOUT "export MPIEXEC_TIMEOUT=$timeout\n";
711 # Run the optional setup routine. For example, the timeout tests could
712 # be set to a shorter timeout.
713 if ($InitForTest ne "") {
717 # For non-MPICH versions of mpiexec, a timeout may require a different
718 # environment variable or command line option (e.g., for Cray aprun,
719 # the option -t <sec> must be given, there is no environment variable
720 # to set the timeout.
722 if (defined($timeoutArgPattern) && $timeoutArgPattern ne "") {
723 my $timeArg = $timeoutArgPattern;
724 $timeoutArg =~ s/<SEC>/$timeout/;
725 $extraArgs .= $timeoutArg
728 print STDOUT "Env includes $progEnv\n" if $verbose;
729 print STDOUT "$mpiexec $np_arg $np $extraArgs $program_wrapper ./$programname $progArgs\n" if $verbose;
730 print STDOUT "." if $showProgress;
731 # Save and restore the environment if necessary before running mpiexec.
732 if ($progEnv ne "") {
734 # save_NAME_is_set=is old name set
736 # export NAME=newvalue
738 # export NAME=oldValue (if set!)
739 print STDERR "Batch output does not permit changes to environment\n";
741 # The approach here is to move the test codes to a single directory from
742 # which they can be run; this avoids complex code to change directories
743 # and ensure that the output goes "into the right place".
745 rename $programname, "$batrundir/$programname";
746 print BATOUT "echo \"# $mpiexec $np_arg $np $extraArgs $mpiexecArgs $program_wrapper $curdir/$programname $progArgs\" > runtests.$testCount.out\n";
747 # Some programs expect to run in the same directory as the executable
748 print BATOUT "$mpiexec $np_arg $np $extraArgs $mpiexecArgs $program_wrapper ./$programname $progArgs >> runtests.$testCount.out 2>&1\n";
749 print BATOUT "echo \$? > runtests.$testCount.status\n";
753 # Return value is 0 on success, non zero on failure
754 sub BuildMPIProgram {
755 my $programname = shift;
756 if (! -x $programname) {
757 die "Could not find $programname. Aborting.\n";
760 # THE FOLLOWING IS DISABLED.
763 if ($verbose) { print STDERR "making $programname\n"; }
764 if (! -x $programname) { $remove_this_pgm = 1; }
765 else { $remove_this_pgm = 0; }
766 my $output = `make $programname 2>&1`;
768 if ($rc > 255) { $rc >>= 8; }
769 if (! -x $programname) {
770 print STDERR "Failed to build $programname; $output\n";
774 # Add a line to the summary file describing the failure
775 # This will ensure that failures to build will end up
776 # in the summary file (which is otherwise written by the
777 # RunMPIProgram step)
778 &RunPreMsg( $programname, $np, $curdir );
779 &RunTestFailed( $programname, $np, $curdir, "Failed to build $programname; $output", $xfail );
780 &RunPostMsg( $programname, $np, $curdir );
785 sub CleanUpAfterRun {
786 my $programname = $_[0];
788 # Check for that this program has exited. If it is still running,
789 # issue a warning and leave the application. Of course, this
790 # check is complicated by the lack of a standard access to the
791 # running processes for this user in Unix.
792 @stillRunning = &FindRunning( $programname );
794 if ($#stillRunning > -1) {
795 print STDERR "Some programs ($programname) may still be running:\npids = ";
796 for (my $i=0; $i <= $#stillRunning; $i++ ) {
797 print STDERR $stillRunning[$i] . " ";
800 # Remind the user that the executable remains; we leave it around
801 # to allow the programmer to debug the running program, for which
802 # the executable is needed.
803 print STDERR "The executable ($programname) will not be removed.\n";
806 if ($remove_this_pgm && $clean_pgms) {
807 unlink $programname, "$programname.o";
809 $remove_this_pgm = 0;
812 # ----------------------------------------------------------------------------
814 my $programname = $_[0];
817 my $logname = $ENV{'USER'};
819 my $rc = open PSFD, "ps auxw -U $logname 2>&1 |";
822 $rc = open PSFD, "ps -fu $logname 2>&1 |";
825 print STDERR "Could not execute ps command\n";
830 if (/$programname/) {
831 @fields = split(/\s+/);
832 my $pid = $fields[$pidloc];
833 # Check that we've found a numeric pid
834 if ($pid =~ /^\d+$/) {
835 $pids[$#pids + 1] = $pid;
843 # ----------------------------------------------------------------------------
845 # TestStatus is a special test that reports success *only* when the
846 # status return is NONZERO
849 my $programname = $_[1];
854 #print STDOUT $_ if $verbose;
856 if (/FORTRAN STOP/) { next; }
858 # ANY output is an error. We have the following output
859 # exception for the Hydra process manager.
862 print STDERR "Unexpected output in $programname: $_";
869 $rc = close ( MPIOUT );
872 $signal_num = $run_status & 127;
873 if ($run_status > 255) { $run_status >>= 8; }
876 # This test *requires* non-zero return codes
881 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
883 return ($found_error,$inline);
886 # TestTimeout is a special test that reports success *only* when the
887 # status return is NONZERO and there are no processes left over.
888 # This test currently checks only for the return status.
891 my $programname = $_[1];
896 #print STDOUT $_ if $verbose;
898 if (/FORTRAN STOP/) { next; }
900 if (/[Tt]imeout/) { next; }
901 # Allow 'signaled with Interrupt' (see gforker mpiexec)
902 if (/signaled with Interrupt/) { next; }
903 # Allow 'job ending due to env var MPIEXEC_TIMEOUT' (mpd)
904 if (/job ending due to env var MPIEXEC_TIMEOUT/) { next; }
905 # Allow 'APPLICATION TIMED OUT' (hydra)
906 if (/\[mpiexec@.*\] APPLICATION TIMED OUT/) { last; }
907 # ANY output is an error (other than timeout)
909 print STDERR "Unexpected output in $programname: $_";
916 $rc = close ( MPIOUT );
919 $signal_num = $run_status & 127;
920 if ($run_status > 255) { $run_status >>= 8; }
923 # This test *requires* non-zero return codes
928 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
931 # Here should go a check of the processes
932 # open( PFD, "ps -fu $LOGNAME | grep -v grep | grep $programname |" );
937 return ($found_error,$inline);
940 # TestErrFatal is a special test that reports success *only* when the
941 # status return is NONZERO; it ignores error messages
944 my $programname = $_[1];
949 #print STDOUT $_ if $verbose;
951 if (/FORTRAN STOP/) { next; }
953 # ALL output is allowed.
955 $rc = close ( MPIOUT );
958 $signal_num = $run_status & 127;
959 if ($run_status > 255) { $run_status >>= 8; }
962 # This test *requires* non-zero return codes
967 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
969 return ($found_error,$inline);
972 # ----------------------------------------------------------------------------
974 # RunPreMsg( programname, np, workdir ) - Call before running a program
975 # RunTestFailed, RunTestPassed - Call after test
976 # RunPostMsg - Call at end of each test
979 my ($programname,$np,$workdir) = @_;
981 print XMLOUT "<MPITEST>$newline<NAME>$programname</NAME>$newline";
982 print XMLOUT "<NP>$np</NP>$newline";
983 print XMLOUT "<WORKDIR>$workdir</WORKDIR>$newline";
987 my ($programname, $np, $workdir) = @_;
989 print XMLOUT "</MPITEST>$newline";
993 my ($programname, $np, $workdir, $xfail) = @_;
995 print XMLOUT "<STATUS>pass</STATUS>$newline";
1000 $xfailstr = " # TODO $xfail";
1002 print TAPOUT "ok ${total_run} - $workdir/$programname ${np}${xfailstr}\n";
1006 my $programname = shift;
1008 my $workdir = shift;
1014 # basic escapes that wreck the XML output
1015 $xout =~ s/</\*AMP\*lt;/g;
1016 $xout =~ s/>/\*AMP\*gt;/g;
1017 $xout =~ s/&/\*AMP\*amp;/g;
1018 $xout =~ s/\*AMP\*/&/g;
1019 # TODO: Also capture any non-printing characters (XML doesn't like them
1021 print XMLOUT "<STATUS>fail</STATUS>$newline";
1022 print XMLOUT "<TESTDIFF>$newline$xout</TESTDIFF>$newline";
1028 $xfailstr = " # TODO $xfail";
1030 print TAPOUT "not ok ${total_run} - $workdir/$programname ${np}${xfailstr}\n";
1031 print TAPOUT " ---\n";
1032 print TAPOUT " Directory: $workdir\n";
1033 print TAPOUT " File: $programname\n";
1034 print TAPOUT " Num-procs: $np\n";
1035 print TAPOUT " Date: \"" . localtime . "\"\n";
1037 # The following would be nice, but it leads to unfortunate formatting in
1038 # the Jenkins web output for now. Using comment lines instead, since
1039 # they are easier to read/find in a browser.
1040 ## print TAPOUT " Output: |\n";
1041 ## # using block literal format, requires that all chars are printable
1042 ## # UTF-8 (or UTF-16, but we won't encounter that)
1043 ## foreach my $line (split m/\r?\n/, $output) {
1045 ## # 4 spaces, 2 for TAP indent, 2 more for YAML block indent
1046 ## print TAPOUT " $line\n";
1049 print TAPOUT " ...\n";
1051 # Alternative to the "Output:" YAML block literal above. Do not put any
1052 # spaces before the '#', this causes some TAP parsers (including Perl's
1053 # TAP::Parser) to treat the line as "unknown" instead of a proper
1055 print TAPOUT "## Test output (expected 'No Errors'):\n";
1056 foreach my $line (split m/\r?\n/, $output) {
1058 print TAPOUT "## $line\n";
1064 my $programname = shift;
1066 my $workdir = shift;
1069 # simply omit from the XML output
1072 print TAPOUT "ok ${total_seen} - $workdir/$programname $np # SKIP $reason\n";
1076 # ----------------------------------------------------------------------------
1077 # Alternate init routines
1078 sub InitQuickTimeout {
1079 $ENV{"MPIEXEC_TIMEOUT"} = 10;