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 = "3";
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
77 $enabled_privatization = 1; # disable tests that need SMPI privatization to run
78 # TAP (Test Anything Protocol) output
85 $depth = 0; # This is used to manage multiple open list files
91 my $program_wrapper = '';
93 #---------------------------------------------------------------------------
94 # Get some arguments from the environment
95 # Currently, only the following are understood:
97 # RUNTESTS_VERBOSE (an alias for VERBOSE in case you want to
99 # RUNTESTS_SHOWPROGRESS
102 # MPITEST_PROGRAM_WRAPPER (Value is added after -np but before test
103 # executable. Tools like valgrind may be inserted
105 #---------------------------------------------------------------------------
106 if ( defined($ENV{"VERBOSE"}) || defined($ENV{"V"}) || defined($ENV{"RUNTESTS_VERBOSE"}) ) {
109 if ( defined($ENV{"RUNTESTS_SHOWPROGRESS"} ) ) {
112 if (defined($ENV{"MPITEST_STOPTEST"})) {
113 $stopfile = $ENV{"MPITEST_STOPTEST"};
116 $stopfile = `pwd` . "/.stoptest";
117 $stopfile =~ s/\r*\n*//g; # Remove any newlines (from pwd)
120 if (defined($ENV{"MPITEST_TIMEOUT"})) {
121 $defaultTimeLimit = $ENV{"MPITEST_TIMEOUT"};
124 # Define this to leave the XML output file open to receive additional data
125 if (defined($ENV{'NOXMLCLOSE'}) && $ENV{'NOXMLCLOSE'} eq 'YES') {
129 if (defined($ENV{'MPITEST_PROGRAM_WRAPPER'})) {
130 $program_wrapper = $ENV{'MPITEST_PROGRAM_WRAPPER'};
133 if (defined($ENV{'MPITEST_BATCH'})) {
134 if ($ENV{'MPITEST_BATCH'} eq 'YES' || $ENV{'MPITEST_BATCH'} eq 'yes') {
136 } elsif ($ENV{'MPITEST_BATCH'} eq 'NO' || $ENV{'MPITEST_BATCH'} eq 'no') {
140 print STDERR "Unrecognized value for MPITEST_BATCH = $ENV{'MPITEST_BATCH'}\n";
143 if (defined($ENV{'MPITEST_BATCHDIR'})) {
144 $batrundir = $ENV{'MPITEST_BATCHDIR'};
147 #---------------------------------------------------------------------------
148 # Process arguments and override any defaults
149 #---------------------------------------------------------------------------
151 if (/--?mpiexec=(.*)/) {
152 # Use mpiexec as given - it may be in the path, and
153 # we don't want to bother to try and find it.
156 elsif (/--?np=(.*)/) { $np_default = $1; }
157 elsif (/--?maxnp=(.*)/) { $np_max = $1; }
158 elsif (/--?tests=(.*)/) { $listfiles = $1; }
159 elsif (/--?srcdir=(.*)/) { $srcdir = $1;
160 $mpiexec="$mpiexec -platform ${srcdir}/../../../../examples/platforms/small_platform_with_routers.xml -hostfile ${srcdir}/../../hostfile_mpich --log=root.thr:critical --cfg=smpi/host-speed:1e9 --cfg=smpi/async-small-thresh:65536"; }
161 elsif (/--?verbose/) { $verbose = 1; }
162 elsif (/--?showprogress/) { $showProgress = 1; }
163 elsif (/--?debug/) { $debug = 1; }
164 elsif (/--?batch/) { $batchRun = 1; }
165 elsif (/--?batchdir=(.*)/) { $batrundir = $1; }
166 elsif (/--?timeoutarg=(.*)/) { $timeoutArgPattern = $1; }
167 elsif (/--?execarg=(.*)/) { $execarg = "$execarg $1"; }
168 elsif (/--?privatization=(.*)/) {
169 print STDERR "privatization called\n";
170 $enabled_privatization = $1; }
171 elsif (/--?wrapper=(.*)/) {
172 $wrapparg = "-wrapper \"$1\"" if $1 ne "";
174 elsif (/--?xmlfile=(.*)/) {
176 if (! ($xmlfile =~ /^\//)) {
179 $xmlfullfile = $thisdir . "/" . $xmlfile ;
182 $xmlfullfile = $xmlfile;
185 open( XMLOUT, ">$xmlfile" ) || die "Cannot open $xmlfile\n";
186 my $date = `date "+%Y-%m-%d-%H-%M"`;
188 # MPISOURCE can be used to describe the source of MPI for this
190 print XMLOUT "<?xml version='1.0' ?>$newline";
191 print XMLOUT "<?xml-stylesheet href=\"TestResults.xsl\" type=\"text/xsl\" ?>$newline";
192 print XMLOUT "<MPITESTRESULTS>$newline";
193 print XMLOUT "<DATE>$date</DATE>$newline";
194 print XMLOUT "<MPISOURCE></MPISOURCE>$newline";
196 elsif (/--?noxmlclose/) {
199 elsif (/--?tapfile=(.*)/) {
201 if ($tapfile !~ m|^/|) {
204 $tapfullfile = $thisdir . "/" . $tapfile ;
207 $tapfullfile = $tapfile;
210 open( TAPOUT, ">$tapfile" ) || die "Cannot open $tapfile\n";
211 my $date = `date "+%Y-%m-%d-%H-%M"`;
213 print TAPOUT "TAP version 13\n";
214 print TAPOUT "# MPICH test suite results (TAP format)\n";
215 print TAPOUT "# date ${date}\n";
216 # we do not know at this point how many tests will be run, so do
217 # not print a test plan line like "1..450" until the very end
221 # Perform any post argument processing
223 if (! -d $batrundir) {
224 mkpath $batrundir || die "Could not create $batrundir\n";
226 open( BATOUT, ">$batrundir/runtests.batch" ) || die "Could not open $batrundir/runtests.batch\n";
229 # We must have mpiexec
230 if ("$mpiexec" eq "") {
231 print STDERR "No mpiexec found!\n";
238 if ($listfiles eq "") {
240 print STDERR "An implicit list of tests is not permitted in batch mode\n";
244 &ProcessImplicitList;
247 elsif (-d $listfiles) {
248 print STDERR "Testing by directories not yet supported\n";
251 &RunList( $listfiles );
254 if ($xmloutput && $closeXMLOutput) {
255 print XMLOUT "</MPITESTRESULTS>$newline";
260 print TAPOUT "1..$total_seen\n";
266 print "Programs created along with a runtest.batch file in $batrundir\n";
267 print "Run that script and then use checktests to summarize the results\n";
271 print "$err_count tests failed out of $total_run\n";
272 print "Failing tests : $failed_tests\n";
274 print "Details in $xmlfullfile\n";
278 print " All $total_run tests passed!\n";
281 print "TAP formatted results in $tapfullfile\n";
284 exit ($err_count > 0);
286 # ---------------------------------------------------------------------------
289 # Enter a new directory and process a list file.
290 # ProcessDir( directory-name, list-file-name )
292 my $dir = $_[0]; $dir =~ s/\/$//;
293 my $listfile = $_[1];
295 my $savecurdir = $curdir;
296 my $savesrcdir = $srcdir;
299 if (substr($srcdir,0,3) eq "../") {
300 $srcdir = "../$srcdir";
303 print "Processing directory $dir\n" if ($verbose || $debug);
306 print STDERR "only direct subdirectories allowed in list files";
310 &RunList( $listfile );
311 print "\n" if $showProgress; # Terminate line from progress output
313 $curdir = $savecurdir;
314 $srcdir = $savesrcdir;
316 # ---------------------------------------------------------------------------
317 # Run the programs listed in the file given as the argument.
318 # This file describes the tests in the format
319 # programname number-of-processes [ key=value ... ]
320 # If the second value is not given, the default value is used.
323 my $LIST = "LIST$depth"; $depth++;
324 my $listfile = $_[0];
327 my $listfileSource = $listfile;
329 print "Looking in $curdir/$listfile\n" if $debug;
330 if (! -s "$listfile" && -s "$srcdir/$curdir/$listfile" ) {
331 $listfileSource = "$srcdir/$curdir/$listfile";
333 open( $LIST, "<$listfileSource" ) ||
334 die "Could not open $listfileSource\n";
336 # Check for stop file
338 # Exit because we found a stopfile
339 print STDERR "Terminating test because stopfile $stopfile found\n";
344 # Remove any trailing newlines/returns
346 # Remove any leading whitespace
348 # Some tests require that support routines are built first
349 # This is specified with !<dir>:<target>
350 if (/^\s*\!([^:]*):(.*)/) {
351 # Hack: just execute in a subshell. This discards any
356 # List file entries have the form:
357 # program [ np [ name=value ... ] ]
358 # See files errhan/testlist, init/testlist, and spawn/testlist
359 # for examples of using the key=value form
360 my @args = split(/\s+/,$_);
361 my $programname = $args[0];
367 my $mpiexecArgs = "$execarg";
368 my $requiresStrict = "";
369 my $requiresMPIX = "";
372 my $needs_privatization = 0;
374 if ($#args >= 1) { $np = $args[1]; }
375 # Process the key=value arguments
376 for (my $i=2; $i <= $#args; $i++) {
377 if ($args[$i] =~ /([^=]+)=(.*)/) {
380 if ($key eq "resultTest") {
381 $ResultTest = $value;
383 elsif ($key eq "init") {
384 $InitForRun = $value;
386 elsif ($key eq "timeLimit") {
389 elsif ($key eq "arg") {
390 $progArgs = "$progArgs $value";
392 elsif ($key eq "mpiexecarg") {
393 $mpiexecArgs = "$mpiexecArgs $value";
395 elsif ($key eq "env") {
396 $progEnv = "$progEnv $value";
398 elsif ($key eq "mpiversion") {
399 $mpiVersion = $value;
401 elsif ($key eq "needs_privatization") {
402 $needs_privatization = $value;
404 elsif ($key eq "strict") {
405 $requiresStrict = $value
407 elsif ($key eq "mpix") {
408 $requiresMPIX = $value
410 elsif ($key eq "xfail") {
412 print STDERR "\"xfail=\" requires an argument\n";
417 print STDERR "Unrecognized key $key in $listfileSource\n";
423 if ($programname eq "") { next; }
425 # if privatization is disabled, and if the test needs it, ignore it
426 if ($needs_privatization == 1 &&
427 $enabled_privatization != 1) {
428 SkippedTest($programname, $np, $workdir, "requires SMPI privatization");
432 if ($np eq "") { $np = $np_default; }
433 if ($np_max > 0 && $np > $np_max) { $np = $np_max; }
435 # allows us to accurately output TAP test numbers without disturbing the
436 # original totals that have traditionally been reported
438 # These "unless" blocks are ugly, but permit us to honor skipping
439 # criteria for directories as well without counting directories as tests
440 # in our XML/TAP output.
441 unless (-d $programname) {
445 # If a minimum MPI version is specified, check against the
446 # available MPI. If the version is unknown, we ignore this
447 # test (thus, all tests will be run).
448 if ($mpiVersion ne "" && $MPIMajorVersion ne "unknown" &&
449 $MPIMinorVersion ne "unknown") {
450 my ($majorReq,$minorReq) = split(/\./,$mpiVersion);
451 if ($majorReq > $MPIMajorVersion or
452 ($majorReq == $MPIMajorVersion && $minorReq > $MPIMinorVersion))
454 unless (-d $programname) {
455 SkippedTest($programname, $np, $workdir, "requires MPI version $mpiVersion");
460 # Check whether strict is required by MPI but not by the
461 # test (use strict=false for tests that use non-standard extensions)
462 if (lc($requiresStrict) eq "false" && lc($testIsStrict) eq "true") {
463 unless (-d $programname) {
464 SkippedTest($programname, $np, $workdir, "non-strict test, strict MPI mode requested");
469 if (lc($testIsStrict) eq "true") {
470 # Strict MPI testing was requested, so assume that a non-MPICH MPI
471 # implementation is being tested and the "xfail" implementation
472 # assumptions do not hold.
476 if (lc($requiresMPIX) eq "true" && lc($MPIHasMPIX) eq "no") {
477 unless (-d $programname) {
478 SkippedTest($programname, $np, $workdir, "tests MPIX extensions, MPIX testing disabled");
483 if (-d $programname) {
484 # If a directory, go into the that directory and
485 # look for a new list file
486 &ProcessDir( $programname, $listfile );
490 if (&BuildMPIProgram( $programname, $xfail ) == 0) {
491 if ($batchRun == 1) {
492 &AddMPIProgram( $programname, $np, $ResultTest,
493 $InitForRun, $timeLimit, $progArgs,
494 $progEnv, $mpiexecArgs, $xfail );
497 &RunMPIProgram( $programname, $np, $ResultTest,
498 $InitForRun, $timeLimit, $progArgs,
499 $progEnv, $mpiexecArgs, $xfail );
502 elsif ($xfail ne '') {
503 # We expected to run this program, so failure to build
508 if ($batchRun == 0) {
509 &CleanUpAfterRun( $programname );
516 # This routine tries to run all of the files in the current
518 sub ProcessImplicitList {
519 # The default is to run every file in the current directory.
520 # If there are no built programs, build and run every file
521 # WARNING: This assumes that anything executable should be run as
525 open (PGMS, "ls -1 |" ) || die "Cannot list directory\n";
529 if (-d $programname) { next; } # Ignore directories
530 if ($programname eq "runtests") { next; } # Ignore self
531 if ($programname eq "checktests") { next; } # Ignore helper
532 if ($programname eq "configure") { next; } # Ignore configure script
533 if ($programname eq "config.status") { next; } # Ignore configure helper
534 if (-x $programname) { $found_exec++; }
535 if ($programname =~ /\.[cf]$/) { $found_src++; }
540 print "Found executables\n" if $debug;
541 open (PGMS, "ls -1 |" ) || die "Cannot list programs\n";
543 # Check for stop file
545 # Exit because we found a stopfile
546 print STDERR "Terminating test because stopfile $stopfile found\n";
551 if (-d $programname) { next; } # Ignore directories
552 if ($programname eq "runtests") { next; } # Ignore self
553 if (-x $programname) {
555 &RunMPIProgram( $programname, $np_default, "", "", "", "", "", "", "" );
561 print "Found source files\n" if $debug;
562 open (PGMS, "ls -1 *.c |" ) || die "Cannot list programs\n";
565 # Exit because we found a stopfile
566 print STDERR "Terminating test because stopfile $stopfile found\n";
571 # Skip messages from ls about no files
572 if (! -s $programname) { next; }
573 $programname =~ s/\.c//;
575 if (&BuildMPIProgram( $programname, "") == 0) {
576 &RunMPIProgram( $programname, $np_default, "", "", "", "", "", "", "" );
579 # We expected to run this program, so failure to build
584 &CleanUpAfterRun( $programname );
590 # ToDo: Add a way to limit the time that any particular program may run.
592 # name of program, number of processes, name of routine to check results
593 # init for testing, timelimit, and any additional program arguments
594 # If the 3rd arg is not present, the a default that simply checks that the
595 # return status is 0 and that the output is " No Errors" is used.
597 my ($programname,$np,$ResultTest,$InitForTest,$timeLimit,$progArgs,$progEnv,$mpiexecArgs,$xfail) = @_;
599 my $found_noerror = 0;
602 &RunPreMsg( $programname, $np, $curdir );
606 # Set a default timeout on tests (3 minutes for now)
607 my $timeout = $defaultTimeLimit;
608 if (defined($timeLimit) && $timeLimit =~ /^\d+$/) {
609 $timeout = $timeLimit;
611 $ENV{"MPIEXEC_TIMEOUT"} = $timeout;
613 # Run the optional setup routine. For example, the timeout tests could
614 # be set to a shorter timeout.
615 if ($InitForTest ne "") {
618 print STDOUT "Env includes $progEnv\n" if $verbose;
619 print STDOUT "$mpiexec $wrapparg $mpiexecArgs $np_arg $np $program_wrapper ./$programname $progArgs\n" if $verbose;
620 print STDOUT "." if $showProgress;
621 # Save and restore the environment if necessary before running mpiexec.
622 if ($progEnv ne "") {
624 foreach $val (split(/\s+/, $progEnv)) {
625 if ($val =~ /([^=]+)=(.*)/) {
629 print STDERR "Environment variable/value $val not in a=b form\n";
633 open ( MPIOUT, "$mpiexec $wrapparg $np_arg $np $mpiexecArgs $program_wrapper ./$programname $progArgs 2>&1 |" ) ||
634 die "Could not run ./$programname\n";
635 if ($progEnv ne "") {
638 if ($ResultTest ne "") {
639 # Read and process the output
640 ($found_error, $inline) = &$ResultTest( MPIOUT, $programname );
644 $inline = "$mpiexec $wrapparg $np_arg $np $program_wrapper ./$programname\n";
650 print STDOUT $_ if $verbose;
652 if (/FORTRAN STOP/) { next; }
654 if (/^==[0-9]+== ?WARNING: ASan doesn't fully support/) {
657 if (/^\s*No [Ee]rrors\s*$/ && $found_noerror == 0) {
660 if (! /^\s*No [Ee]rrors\s*$/ && !/^\s*Test Passed\s*$/) {
661 print STDERR "Unexpected output in $programname: $_";
664 $failed_tests .= $programname;
665 $failed_tests .= " ";
670 if ($found_noerror == 0) {
671 print STDERR "Program $programname exited without No Errors\n";
674 $failed_tests .= $programname;
675 $failed_tests .= " ";
679 $rc = close ( MPIOUT );
681 # Only generate a message if we think that the program
685 $signal_num = $run_status & 127;
686 if ($run_status > 255) { $run_status >>= 8; }
687 print STDERR "Program $programname exited with non-zero status $run_status\n";
688 if ($signal_num != 0) {
689 print STDERR "Program $programname exited with signal $signal_num\n";
691 $failed_tests .= $programname;
692 $failed_tests .= " ";
699 &RunTestFailed( $programname, $np, $curdir, $inline, $xfail );
702 &RunTestPassed( $programname, $np, $curdir, $xfail );
704 &RunPostMsg( $programname, $np, $curdir );
707 # This version simply writes the mpiexec command out, with the output going
708 # into a file, and recording the output status of the run.
710 my ($programname,$np,$ResultTest,$InitForTest,$timeLimit,$progArgs,$progEnv,$mpiexecArgs, $xfail) = @_;
712 if (! -x $programname) {
713 print STDERR "Could not find $programname!";
717 if ($ResultTest ne "") {
718 # This test really needs to be run manually, with this test
719 # Eventually, we can update this to include handleing in checktests.
720 print STDERR "Run $curdir/$programname with $np processes and use $ResultTest to check the results\n";
724 # Set a default timeout on tests (3 minutes for now)
725 my $timeout = $defaultTimeLimit;
726 if (defined($timeLimit) && $timeLimit =~ /^\d+$/) {
727 # On some systems, there is no effective time limit on
728 # individual mpi program runs. In that case, we may
729 # want to treat these also as "run manually".
730 $timeout = $timeLimit;
732 print BATOUT "export MPIEXEC_TIMEOUT=$timeout\n";
734 # Run the optional setup routine. For example, the timeout tests could
735 # be set to a shorter timeout.
736 if ($InitForTest ne "") {
740 # For non-MPICH versions of mpiexec, a timeout may require a different
741 # environment variable or command line option (e.g., for Cray aprun,
742 # the option -t <sec> must be given, there is no environment variable
743 # to set the timeout.
745 if (defined($timeoutArgPattern) && $timeoutArgPattern ne "") {
746 my $timeArg = $timeoutArgPattern;
747 $timeoutArg =~ s/<SEC>/$timeout/;
748 $extraArgs .= $timeoutArg
751 print STDOUT "Env includes $progEnv\n" if $verbose;
752 print STDOUT "$mpiexec $np_arg $np $extraArgs $program_wrapper ./$programname $progArgs\n" if $verbose;
753 print STDOUT "." if $showProgress;
754 # Save and restore the environment if necessary before running mpiexec.
755 if ($progEnv ne "") {
757 # save_NAME_is_set=is old name set
759 # export NAME=newvalue
761 # export NAME=oldValue (if set!)
762 print STDERR "Batch output does not permit changes to environment\n";
764 # The approach here is to move the test codes to a single directory from
765 # which they can be run; this avoids complex code to change directories
766 # and ensure that the output goes "into the right place".
768 rename $programname, "$batrundir/$programname";
769 print BATOUT "echo \"# $mpiexec $np_arg $np $extraArgs $mpiexecArgs $program_wrapper $curdir/$programname $progArgs\" > runtests.$testCount.out\n";
770 # Some programs expect to run in the same directory as the executable
771 print BATOUT "$mpiexec $np_arg $np $extraArgs $mpiexecArgs $program_wrapper ./$programname $progArgs >> runtests.$testCount.out 2>&1\n";
772 print BATOUT "echo \$? > runtests.$testCount.status\n";
776 # Return value is 0 on success, non zero on failure
777 sub BuildMPIProgram {
778 my $programname = shift;
779 if (! -x $programname) {
780 die "Could not find $programname. Aborting.\n";
783 # THE FOLLOWING IS DISABLED.
786 if ($verbose) { print STDERR "making $programname\n"; }
787 if (! -x $programname) { $remove_this_pgm = 1; }
788 else { $remove_this_pgm = 0; }
789 my $output = `make $programname 2>&1`;
791 if ($rc > 255) { $rc >>= 8; }
792 if (! -x $programname) {
793 print STDERR "Failed to build $programname; $output\n";
797 # Add a line to the summary file describing the failure
798 # This will ensure that failures to build will end up
799 # in the summary file (which is otherwise written by the
800 # RunMPIProgram step)
801 &RunPreMsg( $programname, $np, $curdir );
802 &RunTestFailed( $programname, $np, $curdir, "Failed to build $programname; $output", $xfail );
803 &RunPostMsg( $programname, $np, $curdir );
808 sub CleanUpAfterRun {
809 my $programname = $_[0];
811 # Check for that this program has exited. If it is still running,
812 # issue a warning and leave the application. Of course, this
813 # check is complicated by the lack of a standard access to the
814 # running processes for this user in Unix.
815 @stillRunning = &FindRunning( $programname );
817 if ($#stillRunning > -1) {
818 print STDERR "Some programs ($programname) may still be running:\npids = ";
819 for (my $i=0; $i <= $#stillRunning; $i++ ) {
820 print STDERR $stillRunning[$i] . " ";
823 # Remind the user that the executable remains; we leave it around
824 # to allow the programmer to debug the running program, for which
825 # the executable is needed.
826 print STDERR "The executable ($programname) will not be removed.\n";
829 if ($remove_this_pgm && $clean_pgms) {
830 unlink $programname, "$programname.o";
832 $remove_this_pgm = 0;
835 # ----------------------------------------------------------------------------
837 my $programname = $_[0];
840 my $logname = $ENV{'USER'};
842 my $rc = open PSFD, "ps auxw -U $logname 2>&1 |";
845 $rc = open PSFD, "ps -fu $logname 2>&1 |";
848 print STDERR "Could not execute ps command\n";
853 if (/$programname/) {
854 @fields = split(/\s+/);
855 my $pid = $fields[$pidloc];
856 # Check that we've found a numeric pid
857 if ($pid =~ /^\d+$/) {
858 $pids[$#pids + 1] = $pid;
866 # ----------------------------------------------------------------------------
868 # TestStatus is a special test that reports success *only* when the
869 # status return is NONZERO
872 my $programname = $_[1];
877 #print STDOUT $_ if $verbose;
879 if (/FORTRAN STOP/) { next; }
881 # ANY output is an error. We have the following output
882 # exception for the Hydra process manager.
885 print STDERR "Unexpected output in $programname: $_";
892 $rc = close ( MPIOUT );
895 $signal_num = $run_status & 127;
896 if ($run_status > 255) { $run_status >>= 8; }
899 # This test *requires* non-zero return codes
904 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
906 return ($found_error,$inline);
909 # TestTimeout is a special test that reports success *only* when the
910 # status return is NONZERO and there are no processes left over.
911 # This test currently checks only for the return status.
914 my $programname = $_[1];
919 #print STDOUT $_ if $verbose;
921 if (/FORTRAN STOP/) { next; }
923 if (/[Tt]imeout/) { next; }
924 # Allow 'signaled with Interrupt' (see gforker mpiexec)
925 if (/signaled with Interrupt/) { next; }
926 # Allow 'job ending due to env var MPIEXEC_TIMEOUT' (mpd)
927 if (/job ending due to env var MPIEXEC_TIMEOUT/) { next; }
928 # Allow 'APPLICATION TIMED OUT' (hydra)
929 if (/\[mpiexec@.*\] APPLICATION TIMED OUT/) { last; }
930 # ANY output is an error (other than timeout)
932 print STDERR "Unexpected output in $programname: $_";
939 $rc = close ( MPIOUT );
942 $signal_num = $run_status & 127;
943 if ($run_status > 255) { $run_status >>= 8; }
946 # This test *requires* non-zero return codes
951 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
954 # Here should go a check of the processes
955 # open( PFD, "ps -fu $LOGNAME | grep -v grep | grep $programname |" );
960 return ($found_error,$inline);
963 # TestErrFatal is a special test that reports success *only* when the
964 # status return is NONZERO; it ignores error messages
967 my $programname = $_[1];
972 #print STDOUT $_ if $verbose;
974 if (/FORTRAN STOP/) { next; }
976 # ALL output is allowed.
978 $rc = close ( MPIOUT );
981 $signal_num = $run_status & 127;
982 if ($run_status > 255) { $run_status >>= 8; }
985 # This test *requires* non-zero return codes
990 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
992 return ($found_error,$inline);
995 # ----------------------------------------------------------------------------
997 # RunPreMsg( programname, np, workdir ) - Call before running a program
998 # RunTestFailed, RunTestPassed - Call after test
999 # RunPostMsg - Call at end of each test
1002 my ($programname,$np,$workdir) = @_;
1004 print XMLOUT "<MPITEST>$newline<NAME>$programname</NAME>$newline";
1005 print XMLOUT "<NP>$np</NP>$newline";
1006 print XMLOUT "<WORKDIR>$workdir</WORKDIR>$newline";
1010 my ($programname, $np, $workdir) = @_;
1012 print XMLOUT "</MPITEST>$newline";
1016 my ($programname, $np, $workdir, $xfail) = @_;
1018 print XMLOUT "<STATUS>pass</STATUS>$newline";
1023 $xfailstr = " # TODO $xfail";
1025 print TAPOUT "ok ${total_run} - $workdir/$programname ${np}${xfailstr}\n";
1029 my $programname = shift;
1031 my $workdir = shift;
1037 # basic escapes that wreck the XML output
1038 $xout =~ s/</\*AMP\*lt;/g;
1039 $xout =~ s/>/\*AMP\*gt;/g;
1040 $xout =~ s/&/\*AMP\*amp;/g;
1041 $xout =~ s/\*AMP\*/&/g;
1042 # TODO: Also capture any non-printing characters (XML doesn't like them
1044 print XMLOUT "<STATUS>fail</STATUS>$newline";
1045 print XMLOUT "<TESTDIFF>$newline$xout</TESTDIFF>$newline";
1051 $xfailstr = " # TODO $xfail";
1053 print TAPOUT "not ok ${total_run} - $workdir/$programname ${np}${xfailstr}\n";
1054 print TAPOUT " ---\n";
1055 print TAPOUT " Directory: $workdir\n";
1056 print TAPOUT " File: $programname\n";
1057 print TAPOUT " Num-procs: $np\n";
1058 print TAPOUT " Date: \"" . localtime . "\"\n";
1060 # The following would be nice, but it leads to unfortunate formatting in
1061 # the Jenkins web output for now. Using comment lines instead, since
1062 # they are easier to read/find in a browser.
1063 ## print TAPOUT " Output: |\n";
1064 ## # using block literal format, requires that all chars are printable
1065 ## # UTF-8 (or UTF-16, but we won't encounter that)
1066 ## foreach my $line (split m/\r?\n/, $output) {
1068 ## # 4 spaces, 2 for TAP indent, 2 more for YAML block indent
1069 ## print TAPOUT " $line\n";
1072 print TAPOUT " ...\n";
1074 # Alternative to the "Output:" YAML block literal above. Do not put any
1075 # spaces before the '#', this causes some TAP parsers (including Perl's
1076 # TAP::Parser) to treat the line as "unknown" instead of a proper
1078 print TAPOUT "## Test output (expected 'No Errors'):\n";
1079 foreach my $line (split m/\r?\n/, $output) {
1081 print TAPOUT "## $line\n";
1087 my $programname = shift;
1089 my $workdir = shift;
1092 # simply omit from the XML output
1095 print TAPOUT "ok ${total_seen} - $workdir/$programname $np # SKIP $reason\n";
1099 # ----------------------------------------------------------------------------
1100 # Alternate init routines
1101 sub InitQuickTimeout {
1102 $ENV{"MPIEXEC_TIMEOUT"} = 10;