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
76 # TAP (Test Anything Protocol) output
83 $depth = 0; # This is used to manage multiple open list files
89 my $program_wrapper = '';
91 #---------------------------------------------------------------------------
92 # Get some arguments from the environment
93 # Currently, only the following are understood:
95 # RUNTESTS_VERBOSE (an alias for VERBOSE in case you want to
97 # RUNTESTS_SHOWPROGRESS
100 # MPITEST_PROGRAM_WRAPPER (Value is added after -np but before test
101 # executable. Tools like valgrind may be inserted
103 #---------------------------------------------------------------------------
104 if ( defined($ENV{"VERBOSE"}) || defined($ENV{"V"}) || defined($ENV{"RUNTESTS_VERBOSE"}) ) {
107 if ( defined($ENV{"RUNTESTS_SHOWPROGRESS"} ) ) {
110 if (defined($ENV{"MPITEST_STOPTEST"})) {
111 $stopfile = $ENV{"MPITEST_STOPTEST"};
114 $stopfile = `pwd` . "/.stoptest";
115 $stopfile =~ s/\r*\n*//g; # Remove any newlines (from pwd)
118 if (defined($ENV{"MPITEST_TIMEOUT"})) {
119 $defaultTimeLimit = $ENV{"MPITEST_TIMEOUT"};
122 # Define this to leave the XML output file open to receive additional data
123 if (defined($ENV{'NOXMLCLOSE'}) && $ENV{'NOXMLCLOSE'} eq 'YES') {
127 if (defined($ENV{'MPITEST_PROGRAM_WRAPPER'})) {
128 $program_wrapper = $ENV{'MPITEST_PROGRAM_WRAPPER'};
131 if (defined($ENV{'MPITEST_BATCH'})) {
132 if ($ENV{'MPITEST_BATCH'} eq 'YES' || $ENV{'MPITEST_BATCH'} eq 'yes') {
134 } elsif ($ENV{'MPITEST_BATCH'} eq 'NO' || $ENV{'MPITEST_BATCH'} eq 'no') {
138 print STDERR "Unrecognized value for MPITEST_BATCH = $ENV{'MPITEST_BATCH'}\n";
141 if (defined($ENV{'MPITEST_BATCHDIR'})) {
142 $batrundir = $ENV{'MPITEST_BATCHDIR'};
145 #---------------------------------------------------------------------------
146 # Process arguments and override any defaults
147 #---------------------------------------------------------------------------
149 if (/--?mpiexec=(.*)/) {
150 # Use mpiexec as given - it may be in the path, and
151 # we don't want to bother to try and find it.
154 elsif (/--?np=(.*)/) { $np_default = $1; }
155 elsif (/--?maxnp=(.*)/) { $np_max = $1; }
156 elsif (/--?tests=(.*)/) { $listfiles = $1; }
157 elsif (/--?srcdir=(.*)/) { $srcdir = $1;
158 $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"; }
159 elsif (/--?verbose/) { $verbose = 1; }
160 elsif (/--?showprogress/) { $showProgress = 1; }
161 elsif (/--?debug/) { $debug = 1; }
162 elsif (/--?batch/) { $batchRun = 1; }
163 elsif (/--?batchdir=(.*)/) { $batrundir = $1; }
164 elsif (/--?timeoutarg=(.*)/) { $timeoutArgPattern = $1; }
165 elsif (/--?execarg=(.*)/) { $execarg = "$execarg $1"; }
166 elsif (/--?setenv/) { }
167 elsif (/VALGRIND_COMMAND=(.*)/) {
169 elsif (/VALGRIND_OPTIONS=(.*)/) {
170 $wrapparg = "-wrapper \"$valgrind $1\""; }
171 elsif (/--?xmlfile=(.*)/) {
173 if (! ($xmlfile =~ /^\//)) {
176 $xmlfullfile = $thisdir . "/" . $xmlfile ;
179 $xmlfullfile = $xmlfile;
182 open( XMLOUT, ">$xmlfile" ) || die "Cannot open $xmlfile\n";
183 my $date = `date "+%Y-%m-%d-%H-%M"`;
185 # MPISOURCE can be used to describe the source of MPI for this
187 print XMLOUT "<?xml version='1.0' ?>$newline";
188 print XMLOUT "<?xml-stylesheet href=\"TestResults.xsl\" type=\"text/xsl\" ?>$newline";
189 print XMLOUT "<MPITESTRESULTS>$newline";
190 print XMLOUT "<DATE>$date</DATE>$newline";
191 print XMLOUT "<MPISOURCE></MPISOURCE>$newline";
193 elsif (/--?noxmlclose/) {
196 elsif (/--?tapfile=(.*)/) {
198 if ($tapfile !~ m|^/|) {
201 $tapfullfile = $thisdir . "/" . $tapfile ;
204 $tapfullfile = $tapfile;
207 open( TAPOUT, ">$tapfile" ) || die "Cannot open $tapfile\n";
208 my $date = `date "+%Y-%m-%d-%H-%M"`;
210 print TAPOUT "TAP version 13\n";
211 print TAPOUT "# MPICH test suite results (TAP format)\n";
212 print TAPOUT "# date ${date}\n";
213 # we do not know at this point how many tests will be run, so do
214 # not print a test plan line like "1..450" until the very end
217 print STDERR "Unrecognized argument $_\n";
218 print STDERR "runtests [-tests=testfile] [-np=nprocesses] \
219 [-maxnp=max-nprocesses] [-srcdir=location-of-tests] \
220 [-xmlfile=filename ] [-noxmlclose] \
221 [-verbose] [-showprogress] [-debug] [-batch]\n";
226 # Perform any post argument processing
228 if (! -d $batrundir) {
229 mkpath $batrundir || die "Could not create $batrundir\n";
231 open( BATOUT, ">$batrundir/runtests.batch" ) || die "Could not open $batrundir/runtests.batch\n";
234 # We must have mpiexec
235 if ("$mpiexec" eq "") {
236 print STDERR "No mpiexec found!\n";
243 if ($listfiles eq "") {
245 print STDERR "An implicit list of tests is not permitted in batch mode\n";
249 &ProcessImplicitList;
252 elsif (-d $listfiles) {
253 print STDERR "Testing by directories not yet supported\n";
256 &RunList( $listfiles );
259 if ($xmloutput && $closeXMLOutput) {
260 print XMLOUT "</MPITESTRESULTS>$newline";
265 print TAPOUT "1..$total_seen\n";
271 print "Programs created along with a runtest.batch file in $batrundir\n";
272 print "Run that script and then use checktests to summarize the results\n";
276 print "$err_count tests failed out of $total_run\n";
278 print "Details in $xmlfullfile\n";
282 print " All $total_run tests passed!\n";
285 print "TAP formatted results in $tapfullfile\n";
289 # ---------------------------------------------------------------------------
292 # Enter a new directory and process a list file.
293 # ProcessDir( directory-name, list-file-name )
295 my $dir = $_[0]; $dir =~ s/\/$//;
296 my $listfile = $_[1];
298 my $savecurdir = $curdir;
299 my $savesrcdir = $srcdir;
302 if (substr($srcdir,0,3) eq "../") {
303 $srcdir = "../$srcdir";
306 print "Processing directory $dir\n" if ($verbose || $debug);
309 print STDERR "only direct subdirectories allowed in list files";
313 &RunList( $listfile );
314 print "\n" if $showProgress; # Terminate line from progress output
316 $curdir = $savecurdir;
317 $srcdir = $savesrcdir;
319 # ---------------------------------------------------------------------------
320 # Run the programs listed in the file given as the argument.
321 # This file describes the tests in the format
322 # programname number-of-processes [ key=value ... ]
323 # If the second value is not given, the default value is used.
326 my $LIST = "LIST$depth"; $depth++;
327 my $listfile = $_[0];
330 my $listfileSource = $listfile;
332 print "Looking in $curdir/$listfile\n" if $debug;
333 if (! -s "$listfile" && -s "$srcdir/$curdir/$listfile" ) {
334 $listfileSource = "$srcdir/$curdir/$listfile";
336 open( $LIST, "<$listfileSource" ) ||
337 die "Could not open $listfileSource\n";
339 # Check for stop file
341 # Exit because we found a stopfile
342 print STDERR "Terminating test because stopfile $stopfile found\n";
347 # Remove any trailing newlines/returns
349 # Remove any leading whitespace
351 # Some tests require that support routines are built first
352 # This is specified with !<dir>:<target>
353 if (/^\s*\!([^:]*):(.*)/) {
354 # Hack: just execute in a subshell. This discards any
359 # List file entries have the form:
360 # program [ np [ name=value ... ] ]
361 # See files errhan/testlist, init/testlist, and spawn/testlist
362 # for examples of using the key=value form
363 my @args = split(/\s+/,$_);
364 my $programname = $args[0];
370 my $mpiexecArgs = "$execarg";
371 my $requiresStrict = "";
372 my $requiresMPIX = "";
376 if ($#args >= 1) { $np = $args[1]; }
377 # Process the key=value arguments
378 for (my $i=2; $i <= $#args; $i++) {
379 if ($args[$i] =~ /([^=]+)=(.*)/) {
382 if ($key eq "resultTest") {
383 $ResultTest = $value;
385 elsif ($key eq "init") {
386 $InitForRun = $value;
388 elsif ($key eq "timeLimit") {
391 elsif ($key eq "arg") {
392 $progArgs = "$progArgs $value";
394 elsif ($key eq "mpiexecarg") {
395 $mpiexecArgs = "$mpiexecArgs $value";
397 elsif ($key eq "env") {
398 $progEnv = "$progEnv $value";
400 elsif ($key eq "mpiversion") {
401 $mpiVersion = $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 ($np eq "") { $np = $np_default; }
425 if ($np_max > 0 && $np > $np_max) { $np = $np_max; }
427 # allows us to accurately output TAP test numbers without disturbing the
428 # original totals that have traditionally been reported
430 # These "unless" blocks are ugly, but permit us to honor skipping
431 # criteria for directories as well without counting directories as tests
432 # in our XML/TAP output.
433 unless (-d $programname) {
437 # If a minimum MPI version is specified, check against the
438 # available MPI. If the version is unknown, we ignore this
439 # test (thus, all tests will be run).
440 if ($mpiVersion ne "" && $MPIMajorVersion ne "unknown" &&
441 $MPIMinorVersion ne "unknown") {
442 my ($majorReq,$minorReq) = split(/\./,$mpiVersion);
443 if ($majorReq > $MPIMajorVersion or
444 ($majorReq == $MPIMajorVersion && $minorReq > $MPIMinorVersion))
446 unless (-d $programname) {
447 SkippedTest($programname, $np, $workdir, "requires MPI version $mpiVersion");
452 # Check whether strict is required by MPI but not by the
453 # test (use strict=false for tests that use non-standard extensions)
454 if (lc($requiresStrict) eq "false" && lc($testIsStrict) eq "true") {
455 unless (-d $programname) {
456 SkippedTest($programname, $np, $workdir, "non-strict test, strict MPI mode requested");
461 if (lc($testIsStrict) eq "true") {
462 # Strict MPI testing was requested, so assume that a non-MPICH MPI
463 # implementation is being tested and the "xfail" implementation
464 # assumptions do not hold.
468 if (lc($requiresMPIX) eq "true" && lc($MPIHasMPIX) eq "no") {
469 unless (-d $programname) {
470 SkippedTest($programname, $np, $workdir, "tests MPIX extensions, MPIX testing disabled");
475 if (-d $programname) {
476 # If a directory, go into the that directory and
477 # look for a new list file
478 &ProcessDir( $programname, $listfile );
482 if (&BuildMPIProgram( $programname, $xfail ) == 0) {
483 if ($batchRun == 1) {
484 &AddMPIProgram( $programname, $np, $ResultTest,
485 $InitForRun, $timeLimit, $progArgs,
486 $progEnv, $mpiexecArgs, $xfail );
489 &RunMPIProgram( $programname, $np, $ResultTest,
490 $InitForRun, $timeLimit, $progArgs,
491 $progEnv, $mpiexecArgs, $xfail );
494 elsif ($xfail ne '') {
495 # We expected to run this program, so failure to build
500 if ($batchRun == 0) {
501 &CleanUpAfterRun( $programname );
508 # This routine tries to run all of the files in the current
510 sub ProcessImplicitList {
511 # The default is to run every file in the current directory.
512 # If there are no built programs, build and run every file
513 # WARNING: This assumes that anything executable should be run as
517 open (PGMS, "ls -1 |" ) || die "Cannot list directory\n";
521 if (-d $programname) { next; } # Ignore directories
522 if ($programname eq "runtests") { next; } # Ignore self
523 if ($programname eq "checktests") { next; } # Ignore helper
524 if ($programname eq "configure") { next; } # Ignore configure script
525 if ($programname eq "config.status") { next; } # Ignore configure helper
526 if (-x $programname) { $found_exec++; }
527 if ($programname =~ /\.[cf]$/) { $found_src++; }
532 print "Found executables\n" if $debug;
533 open (PGMS, "ls -1 |" ) || die "Cannot list programs\n";
535 # Check for stop file
537 # Exit because we found a stopfile
538 print STDERR "Terminating test because stopfile $stopfile found\n";
543 if (-d $programname) { next; } # Ignore directories
544 if ($programname eq "runtests") { next; } # Ignore self
545 if (-x $programname) {
547 &RunMPIProgram( $programname, $np_default, "", "", "", "", "", "", "" );
553 print "Found source files\n" if $debug;
554 open (PGMS, "ls -1 *.c |" ) || die "Cannot list programs\n";
557 # Exit because we found a stopfile
558 print STDERR "Terminating test because stopfile $stopfile found\n";
563 # Skip messages from ls about no files
564 if (! -s $programname) { next; }
565 $programname =~ s/\.c//;
567 if (&BuildMPIProgram( $programname, "") == 0) {
568 &RunMPIProgram( $programname, $np_default, "", "", "", "", "", "", "" );
571 # We expected to run this program, so failure to build
576 &CleanUpAfterRun( $programname );
582 # ToDo: Add a way to limit the time that any particular program may run.
584 # name of program, number of processes, name of routine to check results
585 # init for testing, timelimit, and any additional program arguments
586 # If the 3rd arg is not present, the a default that simply checks that the
587 # return status is 0 and that the output is " No Errors" is used.
589 my ($programname,$np,$ResultTest,$InitForTest,$timeLimit,$progArgs,$progEnv,$mpiexecArgs,$xfail) = @_;
591 my $found_noerror = 0;
594 &RunPreMsg( $programname, $np, $curdir );
598 # Set a default timeout on tests (3 minutes for now)
599 my $timeout = $defaultTimeLimit;
600 if (defined($timeLimit) && $timeLimit =~ /^\d+$/) {
601 $timeout = $timeLimit;
603 $ENV{"MPIEXEC_TIMEOUT"} = $timeout;
605 # Run the optional setup routine. For example, the timeout tests could
606 # be set to a shorter timeout.
607 if ($InitForTest ne "") {
610 print STDOUT "Env includes $progEnv\n" if $verbose;
611 print STDOUT "$mpiexec $wrapparg $mpiexecArgs $np_arg $np $program_wrapper ./$programname $progArgs\n" if $verbose;
612 print STDOUT "." if $showProgress;
613 # Save and restore the environment if necessary before running mpiexec.
614 if ($progEnv ne "") {
616 foreach $val (split(/\s+/, $progEnv)) {
617 if ($val =~ /([^=]+)=(.*)/) {
621 print STDERR "Environment variable/value $val not in a=b form\n";
625 open ( MPIOUT, "$mpiexec $wrapparg $np_arg $np $mpiexecArgs $program_wrapper ./$programname $progArgs 2>&1 |" ) ||
626 die "Could not run ./$programname\n";
627 if ($progEnv ne "") {
630 if ($ResultTest ne "") {
631 # Read and process the output
632 ($found_error, $inline) = &$ResultTest( MPIOUT, $programname );
636 $inline = "$mpiexec $wrapparg $np_arg $np $program_wrapper ./$programname\n";
642 print STDOUT $_ if $verbose;
644 if (/FORTRAN STOP/) { next; }
646 if (/^\s*No [Ee]rrors\s*$/ && $found_noerror == 0) {
649 if (! /^\s*No [Ee]rrors\s*$/ && !/^\s*Test Passed\s*$/) {
650 print STDERR "Unexpected output in $programname: $_";
657 if ($found_noerror == 0) {
658 print STDERR "Program $programname exited without No Errors\n";
664 $rc = close ( MPIOUT );
666 # Only generate a message if we think that the program
670 $signal_num = $run_status & 127;
671 if ($run_status > 255) { $run_status >>= 8; }
672 print STDERR "Program $programname exited with non-zero status $run_status\n";
673 if ($signal_num != 0) {
674 print STDERR "Program $programname exited with signal $signal_num\n";
682 &RunTestFailed( $programname, $np, $curdir, $inline, $xfail );
685 &RunTestPassed( $programname, $np, $curdir, $xfail );
687 &RunPostMsg( $programname, $np, $curdir );
690 # This version simply writes the mpiexec command out, with the output going
691 # into a file, and recording the output status of the run.
693 my ($programname,$np,$ResultTest,$InitForTest,$timeLimit,$progArgs,$progEnv,$mpiexecArgs, $xfail) = @_;
695 if (! -x $programname) {
696 print STDERR "Could not find $programname!";
700 if ($ResultTest ne "") {
701 # This test really needs to be run manually, with this test
702 # Eventually, we can update this to include handleing in checktests.
703 print STDERR "Run $curdir/$programname with $np processes and use $ResultTest to check the results\n";
707 # Set a default timeout on tests (3 minutes for now)
708 my $timeout = $defaultTimeLimit;
709 if (defined($timeLimit) && $timeLimit =~ /^\d+$/) {
710 # On some systems, there is no effective time limit on
711 # individual mpi program runs. In that case, we may
712 # want to treat these also as "run manually".
713 $timeout = $timeLimit;
715 print BATOUT "export MPIEXEC_TIMEOUT=$timeout\n";
717 # Run the optional setup routine. For example, the timeout tests could
718 # be set to a shorter timeout.
719 if ($InitForTest ne "") {
723 # For non-MPICH versions of mpiexec, a timeout may require a different
724 # environment variable or command line option (e.g., for Cray aprun,
725 # the option -t <sec> must be given, there is no environment variable
726 # to set the timeout.
728 if (defined($timeoutArgPattern) && $timeoutArgPattern ne "") {
729 my $timeArg = $timeoutArgPattern;
730 $timeoutArg =~ s/<SEC>/$timeout/;
731 $extraArgs .= $timeoutArg
734 print STDOUT "Env includes $progEnv\n" if $verbose;
735 print STDOUT "$mpiexec $np_arg $np $extraArgs $program_wrapper ./$programname $progArgs\n" if $verbose;
736 print STDOUT "." if $showProgress;
737 # Save and restore the environment if necessary before running mpiexec.
738 if ($progEnv ne "") {
740 # save_NAME_is_set=is old name set
742 # export NAME=newvalue
744 # export NAME=oldValue (if set!)
745 print STDERR "Batch output does not permit changes to environment\n";
747 # The approach here is to move the test codes to a single directory from
748 # which they can be run; this avoids complex code to change directories
749 # and ensure that the output goes "into the right place".
751 rename $programname, "$batrundir/$programname";
752 print BATOUT "echo \"# $mpiexec $np_arg $np $extraArgs $mpiexecArgs $program_wrapper $curdir/$programname $progArgs\" > runtests.$testCount.out\n";
753 # Some programs expect to run in the same directory as the executable
754 print BATOUT "$mpiexec $np_arg $np $extraArgs $mpiexecArgs $program_wrapper ./$programname $progArgs >> runtests.$testCount.out 2>&1\n";
755 print BATOUT "echo \$? > runtests.$testCount.status\n";
759 # Return value is 0 on success, non zero on failure
760 sub BuildMPIProgram {
761 my $programname = shift;
762 if (! -x $programname) {
763 die "Could not find $programname. Aborting.\n";
766 # THE FOLLOWING IS DISABLED.
769 if ($verbose) { print STDERR "making $programname\n"; }
770 if (! -x $programname) { $remove_this_pgm = 1; }
771 else { $remove_this_pgm = 0; }
772 my $output = `make $programname 2>&1`;
774 if ($rc > 255) { $rc >>= 8; }
775 if (! -x $programname) {
776 print STDERR "Failed to build $programname; $output\n";
780 # Add a line to the summary file describing the failure
781 # This will ensure that failures to build will end up
782 # in the summary file (which is otherwise written by the
783 # RunMPIProgram step)
784 &RunPreMsg( $programname, $np, $curdir );
785 &RunTestFailed( $programname, $np, $curdir, "Failed to build $programname; $output", $xfail );
786 &RunPostMsg( $programname, $np, $curdir );
791 sub CleanUpAfterRun {
792 my $programname = $_[0];
794 # Check for that this program has exited. If it is still running,
795 # issue a warning and leave the application. Of course, this
796 # check is complicated by the lack of a standard access to the
797 # running processes for this user in Unix.
798 @stillRunning = &FindRunning( $programname );
800 if ($#stillRunning > -1) {
801 print STDERR "Some programs ($programname) may still be running:\npids = ";
802 for (my $i=0; $i <= $#stillRunning; $i++ ) {
803 print STDERR $stillRunning[$i] . " ";
806 # Remind the user that the executable remains; we leave it around
807 # to allow the programmer to debug the running program, for which
808 # the executable is needed.
809 print STDERR "The executable ($programname) will not be removed.\n";
812 if ($remove_this_pgm && $clean_pgms) {
813 unlink $programname, "$programname.o";
815 $remove_this_pgm = 0;
818 # ----------------------------------------------------------------------------
820 my $programname = $_[0];
823 my $logname = $ENV{'USER'};
825 my $rc = open PSFD, "ps auxw -U $logname 2>&1 |";
828 $rc = open PSFD, "ps -fu $logname 2>&1 |";
831 print STDERR "Could not execute ps command\n";
836 if (/$programname/) {
837 @fields = split(/\s+/);
838 my $pid = $fields[$pidloc];
839 # Check that we've found a numeric pid
840 if ($pid =~ /^\d+$/) {
841 $pids[$#pids + 1] = $pid;
849 # ----------------------------------------------------------------------------
851 # TestStatus is a special test that reports success *only* when the
852 # status return is NONZERO
855 my $programname = $_[1];
860 #print STDOUT $_ if $verbose;
862 if (/FORTRAN STOP/) { next; }
864 # ANY output is an error. We have the following output
865 # exception for the Hydra process manager.
868 print STDERR "Unexpected output in $programname: $_";
875 $rc = close ( MPIOUT );
878 $signal_num = $run_status & 127;
879 if ($run_status > 255) { $run_status >>= 8; }
882 # This test *requires* non-zero return codes
887 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
889 return ($found_error,$inline);
892 # TestTimeout is a special test that reports success *only* when the
893 # status return is NONZERO and there are no processes left over.
894 # This test currently checks only for the return status.
897 my $programname = $_[1];
902 #print STDOUT $_ if $verbose;
904 if (/FORTRAN STOP/) { next; }
906 if (/[Tt]imeout/) { next; }
907 # Allow 'signaled with Interrupt' (see gforker mpiexec)
908 if (/signaled with Interrupt/) { next; }
909 # Allow 'job ending due to env var MPIEXEC_TIMEOUT' (mpd)
910 if (/job ending due to env var MPIEXEC_TIMEOUT/) { next; }
911 # Allow 'APPLICATION TIMED OUT' (hydra)
912 if (/\[mpiexec@.*\] APPLICATION TIMED OUT/) { last; }
913 # ANY output is an error (other than timeout)
915 print STDERR "Unexpected output in $programname: $_";
922 $rc = close ( MPIOUT );
925 $signal_num = $run_status & 127;
926 if ($run_status > 255) { $run_status >>= 8; }
929 # This test *requires* non-zero return codes
934 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
937 # Here should go a check of the processes
938 # open( PFD, "ps -fu $LOGNAME | grep -v grep | grep $programname |" );
943 return ($found_error,$inline);
946 # TestErrFatal is a special test that reports success *only* when the
947 # status return is NONZERO; it ignores error messages
950 my $programname = $_[1];
955 #print STDOUT $_ if $verbose;
957 if (/FORTRAN STOP/) { next; }
959 # ALL output is allowed.
961 $rc = close ( MPIOUT );
964 $signal_num = $run_status & 127;
965 if ($run_status > 255) { $run_status >>= 8; }
968 # This test *requires* non-zero return codes
973 $inline .= "$mpiexec returned a zero status but the program returned a nonzero status\n";
975 return ($found_error,$inline);
978 # ----------------------------------------------------------------------------
980 # RunPreMsg( programname, np, workdir ) - Call before running a program
981 # RunTestFailed, RunTestPassed - Call after test
982 # RunPostMsg - Call at end of each test
985 my ($programname,$np,$workdir) = @_;
987 print XMLOUT "<MPITEST>$newline<NAME>$programname</NAME>$newline";
988 print XMLOUT "<NP>$np</NP>$newline";
989 print XMLOUT "<WORKDIR>$workdir</WORKDIR>$newline";
993 my ($programname, $np, $workdir) = @_;
995 print XMLOUT "</MPITEST>$newline";
999 my ($programname, $np, $workdir, $xfail) = @_;
1001 print XMLOUT "<STATUS>pass</STATUS>$newline";
1006 $xfailstr = " # TODO $xfail";
1008 print TAPOUT "ok ${total_run} - $workdir/$programname ${np}${xfailstr}\n";
1012 my $programname = shift;
1014 my $workdir = shift;
1020 # basic escapes that wreck the XML output
1021 $xout =~ s/</\*AMP\*lt;/g;
1022 $xout =~ s/>/\*AMP\*gt;/g;
1023 $xout =~ s/&/\*AMP\*amp;/g;
1024 $xout =~ s/\*AMP\*/&/g;
1025 # TODO: Also capture any non-printing characters (XML doesn't like them
1027 print XMLOUT "<STATUS>fail</STATUS>$newline";
1028 print XMLOUT "<TESTDIFF>$newline$xout</TESTDIFF>$newline";
1034 $xfailstr = " # TODO $xfail";
1036 print TAPOUT "not ok ${total_run} - $workdir/$programname ${np}${xfailstr}\n";
1037 print TAPOUT " ---\n";
1038 print TAPOUT " Directory: $workdir\n";
1039 print TAPOUT " File: $programname\n";
1040 print TAPOUT " Num-procs: $np\n";
1041 print TAPOUT " Date: \"" . localtime . "\"\n";
1043 # The following would be nice, but it leads to unfortunate formatting in
1044 # the Jenkins web output for now. Using comment lines instead, since
1045 # they are easier to read/find in a browser.
1046 ## print TAPOUT " Output: |\n";
1047 ## # using block literal format, requires that all chars are printable
1048 ## # UTF-8 (or UTF-16, but we won't encounter that)
1049 ## foreach my $line (split m/\r?\n/, $output) {
1051 ## # 4 spaces, 2 for TAP indent, 2 more for YAML block indent
1052 ## print TAPOUT " $line\n";
1055 print TAPOUT " ...\n";
1057 # Alternative to the "Output:" YAML block literal above. Do not put any
1058 # spaces before the '#', this causes some TAP parsers (including Perl's
1059 # TAP::Parser) to treat the line as "unknown" instead of a proper
1061 print TAPOUT "## Test output (expected 'No Errors'):\n";
1062 foreach my $line (split m/\r?\n/, $output) {
1064 print TAPOUT "## $line\n";
1070 my $programname = shift;
1072 my $workdir = shift;
1075 # simply omit from the XML output
1078 print TAPOUT "ok ${total_seen} - $workdir/$programname $np # SKIP $reason\n";
1082 # ----------------------------------------------------------------------------
1083 # Alternate init routines
1084 sub InitQuickTimeout {
1085 $ENV{"MPIEXEC_TIMEOUT"} = 10;