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
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_coll --log=root.thr:critical --cfg=smpi/running-power: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 (/VALGRIND_COMMAND=(.*)/) {
173 elsif (/VALGRIND_OPTIONS=(.*)/) {
174 $wrapparg = "-wrapper \"$valgrind $1\""; }
175 elsif (/--?xmlfile=(.*)/) {
177 if (! ($xmlfile =~ /^\//)) {
180 $xmlfullfile = $thisdir . "/" . $xmlfile ;
183 $xmlfullfile = $xmlfile;
186 open( XMLOUT, ">$xmlfile" ) || die "Cannot open $xmlfile\n";
187 my $date = `date "+%Y-%m-%d-%H-%M"`;
189 # MPISOURCE can be used to describe the source of MPI for this
191 print XMLOUT "<?xml version='1.0' ?>$newline";
192 print XMLOUT "<?xml-stylesheet href=\"TestResults.xsl\" type=\"text/xsl\" ?>$newline";
193 print XMLOUT "<MPITESTRESULTS>$newline";
194 print XMLOUT "<DATE>$date</DATE>$newline";
195 print XMLOUT "<MPISOURCE></MPISOURCE>$newline";
197 elsif (/--?noxmlclose/) {
200 elsif (/--?tapfile=(.*)/) {
202 if ($tapfile !~ m|^/|) {
205 $tapfullfile = $thisdir . "/" . $tapfile ;
208 $tapfullfile = $tapfile;
211 open( TAPOUT, ">$tapfile" ) || die "Cannot open $tapfile\n";
212 my $date = `date "+%Y-%m-%d-%H-%M"`;
214 print TAPOUT "TAP version 13\n";
215 print TAPOUT "# MPICH test suite results (TAP format)\n";
216 print TAPOUT "# date ${date}\n";
217 # we do not know at this point how many tests will be run, so do
218 # not print a test plan line like "1..450" until the very end
222 # Perform any post argument processing
224 if (! -d $batrundir) {
225 mkpath $batrundir || die "Could not create $batrundir\n";
227 open( BATOUT, ">$batrundir/runtests.batch" ) || die "Could not open $batrundir/runtests.batch\n";
230 # We must have mpiexec
231 if ("$mpiexec" eq "") {
232 print STDERR "No mpiexec found!\n";
239 if ($listfiles eq "") {
241 print STDERR "An implicit list of tests is not permitted in batch mode\n";
245 &ProcessImplicitList;
248 elsif (-d $listfiles) {
249 print STDERR "Testing by directories not yet supported\n";
252 &RunList( $listfiles );
255 if ($xmloutput && $closeXMLOutput) {
256 print XMLOUT "</MPITESTRESULTS>$newline";
261 print TAPOUT "1..$total_seen\n";
267 print "Programs created along with a runtest.batch file in $batrundir\n";
268 print "Run that script and then use checktests to summarize the results\n";
272 print "$err_count tests failed out of $total_run\n";
274 print "Details in $xmlfullfile\n";
278 print " All $total_run tests passed!\n";
281 print "TAP formatted results in $tapfullfile\n";
285 # ---------------------------------------------------------------------------
288 # Enter a new directory and process a list file.
289 # ProcessDir( directory-name, list-file-name )
291 my $dir = $_[0]; $dir =~ s/\/$//;
292 my $listfile = $_[1];
294 my $savecurdir = $curdir;
295 my $savesrcdir = $srcdir;
298 if (substr($srcdir,0,3) eq "../") {
299 $srcdir = "../$srcdir";
302 print "Processing directory $dir\n" if ($verbose || $debug);
305 print STDERR "only direct subdirectories allowed in list files";
309 &RunList( $listfile );
310 print "\n" if $showProgress; # Terminate line from progress output
312 $curdir = $savecurdir;
313 $srcdir = $savesrcdir;
315 # ---------------------------------------------------------------------------
316 # Run the programs listed in the file given as the argument.
317 # This file describes the tests in the format
318 # programname number-of-processes [ key=value ... ]
319 # If the second value is not given, the default value is used.
322 my $LIST = "LIST$depth"; $depth++;
323 my $listfile = $_[0];
326 my $listfileSource = $listfile;
328 print "Looking in $curdir/$listfile\n" if $debug;
329 if (! -s "$listfile" && -s "$srcdir/$curdir/$listfile" ) {
330 $listfileSource = "$srcdir/$curdir/$listfile";
332 open( $LIST, "<$listfileSource" ) ||
333 die "Could not open $listfileSource\n";
335 # Check for stop file
337 # Exit because we found a stopfile
338 print STDERR "Terminating test because stopfile $stopfile found\n";
343 # Remove any trailing newlines/returns
345 # Remove any leading whitespace
347 # Some tests require that support routines are built first
348 # This is specified with !<dir>:<target>
349 if (/^\s*\!([^:]*):(.*)/) {
350 # Hack: just execute in a subshell. This discards any
355 # List file entries have the form:
356 # program [ np [ name=value ... ] ]
357 # See files errhan/testlist, init/testlist, and spawn/testlist
358 # for examples of using the key=value form
359 my @args = split(/\s+/,$_);
360 my $programname = $args[0];
366 my $mpiexecArgs = "$execarg";
367 my $requiresStrict = "";
368 my $requiresMPIX = "";
371 my $needs_privatization = 0;
373 if ($#args >= 1) { $np = $args[1]; }
374 # Process the key=value arguments
375 for (my $i=2; $i <= $#args; $i++) {
376 if ($args[$i] =~ /([^=]+)=(.*)/) {
379 if ($key eq "resultTest") {
380 $ResultTest = $value;
382 elsif ($key eq "init") {
383 $InitForRun = $value;
385 elsif ($key eq "timeLimit") {
388 elsif ($key eq "arg") {
389 $progArgs = "$progArgs $value";
391 elsif ($key eq "mpiexecarg") {
392 $mpiexecArgs = "$mpiexecArgs $value";
394 elsif ($key eq "env") {
395 $progEnv = "$progEnv $value";
397 elsif ($key eq "mpiversion") {
398 $mpiVersion = $value;
400 elsif ($key eq "needs_privatization") {
401 $needs_privatization = $value;
403 elsif ($key eq "strict") {
404 $requiresStrict = $value
406 elsif ($key eq "mpix") {
407 $requiresMPIX = $value
409 elsif ($key eq "xfail") {
411 print STDERR "\"xfail=\" requires an argument\n";
416 print STDERR "Unrecognized key $key in $listfileSource\n";
422 if ($programname eq "") { next; }
424 #if privatization is disabled, and if the test needs it, ignore it
425 if ($needs_privatization == 1 &&
426 $enabled_privatization != 1) {
427 SkippedTest($programname, $np, $workdir, "requires SMPI privatization");
431 if ($np eq "") { $np = $np_default; }
432 if ($np_max > 0 && $np > $np_max) { $np = $np_max; }
434 # allows us to accurately output TAP test numbers without disturbing the
435 # original totals that have traditionally been reported
437 # These "unless" blocks are ugly, but permit us to honor skipping
438 # criteria for directories as well without counting directories as tests
439 # in our XML/TAP output.
440 unless (-d $programname) {
444 # If a minimum MPI version is specified, check against the
445 # available MPI. If the version is unknown, we ignore this
446 # test (thus, all tests will be run).
447 if ($mpiVersion ne "" && $MPIMajorVersion ne "unknown" &&
448 $MPIMinorVersion ne "unknown") {
449 my ($majorReq,$minorReq) = split(/\./,$mpiVersion);
450 if ($majorReq > $MPIMajorVersion or
451 ($majorReq == $MPIMajorVersion && $minorReq > $MPIMinorVersion))
453 unless (-d $programname) {
454 SkippedTest($programname, $np, $workdir, "requires MPI version $mpiVersion");
459 # Check whether strict is required by MPI but not by the
460 # test (use strict=false for tests that use non-standard extensions)
461 if (lc($requiresStrict) eq "false" && lc($testIsStrict) eq "true") {
462 unless (-d $programname) {
463 SkippedTest($programname, $np, $workdir, "non-strict test, strict MPI mode requested");
468 if (lc($testIsStrict) eq "true") {
469 # Strict MPI testing was requested, so assume that a non-MPICH MPI
470 # implementation is being tested and the "xfail" implementation
471 # assumptions do not hold.
475 if (lc($requiresMPIX) eq "true" && lc($MPIHasMPIX) eq "no") {
476 unless (-d $programname) {
477 SkippedTest($programname, $np, $workdir, "tests MPIX extensions, MPIX testing disabled");
482 if (-d $programname) {
483 # If a directory, go into the that directory and
484 # look for a new list file
485 &ProcessDir( $programname, $listfile );
489 if (&BuildMPIProgram( $programname, $xfail ) == 0) {
490 if ($batchRun == 1) {
491 &AddMPIProgram( $programname, $np, $ResultTest,
492 $InitForRun, $timeLimit, $progArgs,
493 $progEnv, $mpiexecArgs, $xfail );
496 &RunMPIProgram( $programname, $np, $ResultTest,
497 $InitForRun, $timeLimit, $progArgs,
498 $progEnv, $mpiexecArgs, $xfail );
501 elsif ($xfail ne '') {
502 # We expected to run this program, so failure to build
507 if ($batchRun == 0) {
508 &CleanUpAfterRun( $programname );
515 # This routine tries to run all of the files in the current
517 sub ProcessImplicitList {
518 # The default is to run every file in the current directory.
519 # If there are no built programs, build and run every file
520 # WARNING: This assumes that anything executable should be run as
524 open (PGMS, "ls -1 |" ) || die "Cannot list directory\n";
528 if (-d $programname) { next; } # Ignore directories
529 if ($programname eq "runtests") { next; } # Ignore self
530 if ($programname eq "checktests") { next; } # Ignore helper
531 if ($programname eq "configure") { next; } # Ignore configure script
532 if ($programname eq "config.status") { next; } # Ignore configure helper
533 if (-x $programname) { $found_exec++; }
534 if ($programname =~ /\.[cf]$/) { $found_src++; }
539 print "Found executables\n" if $debug;
540 open (PGMS, "ls -1 |" ) || die "Cannot list programs\n";
542 # Check for stop file
544 # Exit because we found a stopfile
545 print STDERR "Terminating test because stopfile $stopfile found\n";
550 if (-d $programname) { next; } # Ignore directories
551 if ($programname eq "runtests") { next; } # Ignore self
552 if (-x $programname) {
554 &RunMPIProgram( $programname, $np_default, "", "", "", "", "", "", "" );
560 print "Found source files\n" if $debug;
561 open (PGMS, "ls -1 *.c |" ) || die "Cannot list programs\n";
564 # Exit because we found a stopfile
565 print STDERR "Terminating test because stopfile $stopfile found\n";
570 # Skip messages from ls about no files
571 if (! -s $programname) { next; }
572 $programname =~ s/\.c//;
574 if (&BuildMPIProgram( $programname, "") == 0) {
575 &RunMPIProgram( $programname, $np_default, "", "", "", "", "", "", "" );
578 # We expected to run this program, so failure to build
583 &CleanUpAfterRun( $programname );
589 # ToDo: Add a way to limit the time that any particular program may run.
591 # name of program, number of processes, name of routine to check results
592 # init for testing, timelimit, and any additional program arguments
593 # If the 3rd arg is not present, the a default that simply checks that the
594 # return status is 0 and that the output is " No Errors" is used.
596 my ($programname,$np,$ResultTest,$InitForTest,$timeLimit,$progArgs,$progEnv,$mpiexecArgs,$xfail) = @_;
598 my $found_noerror = 0;
601 &RunPreMsg( $programname, $np, $curdir );
605 # Set a default timeout on tests (3 minutes for now)
606 my $timeout = $defaultTimeLimit;
607 if (defined($timeLimit) && $timeLimit =~ /^\d+$/) {
608 $timeout = $timeLimit;
610 $ENV{"MPIEXEC_TIMEOUT"} = $timeout;
612 # Run the optional setup routine. For example, the timeout tests could
613 # be set to a shorter timeout.
614 if ($InitForTest ne "") {
617 print STDOUT "Env includes $progEnv\n" if $verbose;
618 print STDOUT "$mpiexec $wrapparg $mpiexecArgs $np_arg $np $program_wrapper ./$programname $progArgs\n" if $verbose;
619 print STDOUT "." if $showProgress;
620 # Save and restore the environment if necessary before running mpiexec.
621 if ($progEnv ne "") {
623 foreach $val (split(/\s+/, $progEnv)) {
624 if ($val =~ /([^=]+)=(.*)/) {
628 print STDERR "Environment variable/value $val not in a=b form\n";
632 open ( MPIOUT, "$mpiexec $wrapparg $np_arg $np $mpiexecArgs $program_wrapper ./$programname $progArgs 2>&1 |" ) ||
633 die "Could not run ./$programname\n";
634 if ($progEnv ne "") {
637 if ($ResultTest ne "") {
638 # Read and process the output
639 ($found_error, $inline) = &$ResultTest( MPIOUT, $programname );
643 $inline = "$mpiexec $wrapparg $np_arg $np $program_wrapper ./$programname\n";
649 print STDOUT $_ if $verbose;
651 if (/FORTRAN STOP/) { next; }
653 if (/^\s*No [Ee]rrors\s*$/ && $found_noerror == 0) {
656 if (! /^\s*No [Ee]rrors\s*$/ && !/^\s*Test Passed\s*$/) {
657 print STDERR "Unexpected output in $programname: $_";
664 if ($found_noerror == 0) {
665 print STDERR "Program $programname exited without No Errors\n";
671 $rc = close ( MPIOUT );
673 # Only generate a message if we think that the program
677 $signal_num = $run_status & 127;
678 if ($run_status > 255) { $run_status >>= 8; }
679 print STDERR "Program $programname exited with non-zero status $run_status\n";
680 if ($signal_num != 0) {
681 print STDERR "Program $programname exited with signal $signal_num\n";
689 &RunTestFailed( $programname, $np, $curdir, $inline, $xfail );
692 &RunTestPassed( $programname, $np, $curdir, $xfail );
694 &RunPostMsg( $programname, $np, $curdir );
697 # This version simply writes the mpiexec command out, with the output going
698 # into a file, and recording the output status of the run.
700 my ($programname,$np,$ResultTest,$InitForTest,$timeLimit,$progArgs,$progEnv,$mpiexecArgs, $xfail) = @_;
702 if (! -x $programname) {
703 print STDERR "Could not find $programname!";
707 if ($ResultTest ne "") {
708 # This test really needs to be run manually, with this test
709 # Eventually, we can update this to include handleing in checktests.
710 print STDERR "Run $curdir/$programname with $np processes and use $ResultTest to check the results\n";
714 # Set a default timeout on tests (3 minutes for now)
715 my $timeout = $defaultTimeLimit;
716 if (defined($timeLimit) && $timeLimit =~ /^\d+$/) {
717 # On some systems, there is no effective time limit on
718 # individual mpi program runs. In that case, we may
719 # want to treat these also as "run manually".
720 $timeout = $timeLimit;
722 print BATOUT "export MPIEXEC_TIMEOUT=$timeout\n";
724 # Run the optional setup routine. For example, the timeout tests could
725 # be set to a shorter timeout.
726 if ($InitForTest ne "") {
730 # For non-MPICH versions of mpiexec, a timeout may require a different
731 # environment variable or command line option (e.g., for Cray aprun,
732 # the option -t <sec> must be given, there is no environment variable
733 # to set the timeout.
735 if (defined($timeoutArgPattern) && $timeoutArgPattern ne "") {
736 my $timeArg = $timeoutArgPattern;
737 $timeoutArg =~ s/<SEC>/$timeout/;
738 $extraArgs .= $timeoutArg
741 print STDOUT "Env includes $progEnv\n" if $verbose;
742 print STDOUT "$mpiexec $np_arg $np $extraArgs $program_wrapper ./$programname $progArgs\n" if $verbose;
743 print STDOUT "." if $showProgress;
744 # Save and restore the environment if necessary before running mpiexec.
745 if ($progEnv ne "") {
747 # save_NAME_is_set=is old name set
749 # export NAME=newvalue
751 # export NAME=oldValue (if set!)
752 print STDERR "Batch output does not permit changes to environment\n";
754 # The approach here is to move the test codes to a single directory from
755 # which they can be run; this avoids complex code to change directories
756 # and ensure that the output goes "into the right place".
758 rename $programname, "$batrundir/$programname";
759 print BATOUT "echo \"# $mpiexec $np_arg $np $extraArgs $mpiexecArgs $program_wrapper $curdir/$programname $progArgs\" > runtests.$testCount.out\n";
760 # Some programs expect to run in the same directory as the executable
761 print BATOUT "$mpiexec $np_arg $np $extraArgs $mpiexecArgs $program_wrapper ./$programname $progArgs >> runtests.$testCount.out 2>&1\n";
762 print BATOUT "echo \$? > runtests.$testCount.status\n";
766 # Return value is 0 on success, non zero on failure
767 sub BuildMPIProgram {
768 my $programname = shift;
769 if (! -x $programname) {
770 die "Could not find $programname. Aborting.\n";
773 # THE FOLLOWING IS DISABLED.
776 if ($verbose) { print STDERR "making $programname\n"; }
777 if (! -x $programname) { $remove_this_pgm = 1; }
778 else { $remove_this_pgm = 0; }
779 my $output = `make $programname 2>&1`;
781 if ($rc > 255) { $rc >>= 8; }
782 if (! -x $programname) {
783 print STDERR "Failed to build $programname; $output\n";
787 # Add a line to the summary file describing the failure
788 # This will ensure that failures to build will end up
789 # in the summary file (which is otherwise written by the
790 # RunMPIProgram step)
791 &RunPreMsg( $programname, $np, $curdir );
792 &RunTestFailed( $programname, $np, $curdir, "Failed to build $programname; $output", $xfail );
793 &RunPostMsg( $programname, $np, $curdir );
798 sub CleanUpAfterRun {
799 my $programname = $_[0];
801 # Check for that this program has exited. If it is still running,
802 # issue a warning and leave the application. Of course, this
803 # check is complicated by the lack of a standard access to the
804 # running processes for this user in Unix.
805 @stillRunning = &FindRunning( $programname );
807 if ($#stillRunning > -1) {
808 print STDERR "Some programs ($programname) may still be running:\npids = ";
809 for (my $i=0; $i <= $#stillRunning; $i++ ) {
810 print STDERR $stillRunning[$i] . " ";
813 # Remind the user that the executable remains; we leave it around
814 # to allow the programmer to debug the running program, for which
815 # the executable is needed.
816 print STDERR "The executable ($programname) will not be removed.\n";
819 if ($remove_this_pgm && $clean_pgms) {
820 unlink $programname, "$programname.o";
822 $remove_this_pgm = 0;
825 # ----------------------------------------------------------------------------
827 my $programname = $_[0];
830 my $logname = $ENV{'USER'};
832 my $rc = open PSFD, "ps auxw -U $logname 2>&1 |";
835 $rc = open PSFD, "ps -fu $logname 2>&1 |";
838 print STDERR "Could not execute ps command\n";
843 if (/$programname/) {
844 @fields = split(/\s+/);
845 my $pid = $fields[$pidloc];
846 # Check that we've found a numeric pid
847 if ($pid =~ /^\d+$/) {
848 $pids[$#pids + 1] = $pid;
856 # ----------------------------------------------------------------------------
858 # TestStatus is a special test that reports success *only* when the
859 # status return is NONZERO
862 my $programname = $_[1];
867 #print STDOUT $_ if $verbose;
869 if (/FORTRAN STOP/) { next; }
871 # ANY output is an error. We have the following output
872 # exception for the Hydra process manager.
875 print STDERR "Unexpected output in $programname: $_";
882 $rc = close ( MPIOUT );
885 $signal_num = $run_status & 127;
886 if ($run_status > 255) { $run_status >>= 8; }
889 # This test *requires* non-zero return codes
894 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
896 return ($found_error,$inline);
899 # TestTimeout is a special test that reports success *only* when the
900 # status return is NONZERO and there are no processes left over.
901 # This test currently checks only for the return status.
904 my $programname = $_[1];
909 #print STDOUT $_ if $verbose;
911 if (/FORTRAN STOP/) { next; }
913 if (/[Tt]imeout/) { next; }
914 # Allow 'signaled with Interrupt' (see gforker mpiexec)
915 if (/signaled with Interrupt/) { next; }
916 # Allow 'job ending due to env var MPIEXEC_TIMEOUT' (mpd)
917 if (/job ending due to env var MPIEXEC_TIMEOUT/) { next; }
918 # Allow 'APPLICATION TIMED OUT' (hydra)
919 if (/\[mpiexec@.*\] APPLICATION TIMED OUT/) { last; }
920 # ANY output is an error (other than timeout)
922 print STDERR "Unexpected output in $programname: $_";
929 $rc = close ( MPIOUT );
932 $signal_num = $run_status & 127;
933 if ($run_status > 255) { $run_status >>= 8; }
936 # This test *requires* non-zero return codes
941 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
944 # Here should go a check of the processes
945 # open( PFD, "ps -fu $LOGNAME | grep -v grep | grep $programname |" );
950 return ($found_error,$inline);
953 # TestErrFatal is a special test that reports success *only* when the
954 # status return is NONZERO; it ignores error messages
957 my $programname = $_[1];
962 #print STDOUT $_ if $verbose;
964 if (/FORTRAN STOP/) { next; }
966 # ALL output is allowed.
968 $rc = close ( MPIOUT );
971 $signal_num = $run_status & 127;
972 if ($run_status > 255) { $run_status >>= 8; }
975 # This test *requires* non-zero return codes
980 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
982 return ($found_error,$inline);
985 # ----------------------------------------------------------------------------
987 # RunPreMsg( programname, np, workdir ) - Call before running a program
988 # RunTestFailed, RunTestPassed - Call after test
989 # RunPostMsg - Call at end of each test
992 my ($programname,$np,$workdir) = @_;
994 print XMLOUT "<MPITEST>$newline<NAME>$programname</NAME>$newline";
995 print XMLOUT "<NP>$np</NP>$newline";
996 print XMLOUT "<WORKDIR>$workdir</WORKDIR>$newline";
1000 my ($programname, $np, $workdir) = @_;
1002 print XMLOUT "</MPITEST>$newline";
1006 my ($programname, $np, $workdir, $xfail) = @_;
1008 print XMLOUT "<STATUS>pass</STATUS>$newline";
1013 $xfailstr = " # TODO $xfail";
1015 print TAPOUT "ok ${total_run} - $workdir/$programname ${np}${xfailstr}\n";
1019 my $programname = shift;
1021 my $workdir = shift;
1027 # basic escapes that wreck the XML output
1028 $xout =~ s/</\*AMP\*lt;/g;
1029 $xout =~ s/>/\*AMP\*gt;/g;
1030 $xout =~ s/&/\*AMP\*amp;/g;
1031 $xout =~ s/\*AMP\*/&/g;
1032 # TODO: Also capture any non-printing characters (XML doesn't like them
1034 print XMLOUT "<STATUS>fail</STATUS>$newline";
1035 print XMLOUT "<TESTDIFF>$newline$xout</TESTDIFF>$newline";
1041 $xfailstr = " # TODO $xfail";
1043 print TAPOUT "not ok ${total_run} - $workdir/$programname ${np}${xfailstr}\n";
1044 print TAPOUT " ---\n";
1045 print TAPOUT " Directory: $workdir\n";
1046 print TAPOUT " File: $programname\n";
1047 print TAPOUT " Num-procs: $np\n";
1048 print TAPOUT " Date: \"" . localtime . "\"\n";
1050 # The following would be nice, but it leads to unfortunate formatting in
1051 # the Jenkins web output for now. Using comment lines instead, since
1052 # they are easier to read/find in a browser.
1053 ## print TAPOUT " Output: |\n";
1054 ## # using block literal format, requires that all chars are printable
1055 ## # UTF-8 (or UTF-16, but we won't encounter that)
1056 ## foreach my $line (split m/\r?\n/, $output) {
1058 ## # 4 spaces, 2 for TAP indent, 2 more for YAML block indent
1059 ## print TAPOUT " $line\n";
1062 print TAPOUT " ...\n";
1064 # Alternative to the "Output:" YAML block literal above. Do not put any
1065 # spaces before the '#', this causes some TAP parsers (including Perl's
1066 # TAP::Parser) to treat the line as "unknown" instead of a proper
1068 print TAPOUT "## Test output (expected 'No Errors'):\n";
1069 foreach my $line (split m/\r?\n/, $output) {
1071 print TAPOUT "## $line\n";
1077 my $programname = shift;
1079 my $workdir = shift;
1082 # simply omit from the XML output
1085 print TAPOUT "ok ${total_seen} - $workdir/$programname $np # SKIP $reason\n";
1089 # ----------------------------------------------------------------------------
1090 # Alternate init routines
1091 sub InitQuickTimeout {
1092 $ENV{"MPIEXEC_TIMEOUT"} = 10;