Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Reduce the size of partial shared malloc tests.
[simgrid.git] / teshsuite / smpi / mpich3-test / runtests
index 03c9b88..1e7ce7c 100755 (executable)
@@ -1,7 +1,7 @@
-#! /usr/bin/perl
+#! /usr/bin/env perl
 # -*- Mode: perl; -*-
 #
-# This script is the beginnings of a script to run a sequence of test 
+# This script is the beginnings of a script to run a sequence of test
 # programs.  See the MPICH document for a description of the test
 # strategy and requirements.
 #
@@ -40,8 +40,8 @@
 use File::Path;
 
 # Global variables
-$MPIMajorVersion = "1";
-$MPIMinorVersion = "1";
+$MPIMajorVersion = "2";
+$MPIMinorVersion = "2";
 $mpiexec = "smpirun";    # Name of mpiexec program (including path, if necessary)
 $testIsStrict = "true";
 $MPIhasMPIX   = "no";
@@ -66,12 +66,15 @@ $verbose = 1;            # Set to true to get more output
 $showProgress = 0;       # Set to true to get a "." with each run program.
 $newline = "\r\n";       # Set to \r\n for Windows-friendly, \n for Unix only
 $batchRun = 0;           # Set to true to batch the execution of the tests
-                         # (i.e., run them together, then test output, 
+                         # (i.e., run them together, then test output,
                          # rather than build/run/check for each test)
 $testCount = 0;          # Used with batchRun to count tests.
 $batrundir = ".";        # Set to the directory into which to run the examples
 
 $execarg="";
+$wrapparg="";
+
+$enabled_privatization = 1; # disable tests that need SMPI privatization to run
 # TAP (Test Anything Protocol) output
 my $tapoutput = 0;
 my $tapfile = '';
@@ -83,7 +86,7 @@ $depth = 0;              # This is used to manage multiple open list files
 
 # Build flags
 $remove_this_pgm = 0;
-$clean_pgms      = 1;
+$clean_pgms      = 0;
 
 my $program_wrapper = '';
 
@@ -91,7 +94,7 @@ my $program_wrapper = '';
 # Get some arguments from the environment
 #   Currently, only the following are understood:
 #   VERBOSE
-#   RUNTESTS_VERBOSE  (an alias for VERBOSE in case you want to 
+#   RUNTESTS_VERBOSE  (an alias for VERBOSE in case you want to
 #                      reserve VERBOSE)
 #   RUNTESTS_SHOWPROGRESS
 #   MPITEST_STOPTEST
@@ -104,7 +107,7 @@ if ( defined($ENV{"VERBOSE"}) || defined($ENV{"V"}) || defined($ENV{"RUNTESTS_VE
     $verbose = 1;
 }
 if ( defined($ENV{"RUNTESTS_SHOWPROGRESS"} ) ) {
-    $showProgress = 1;       
+    $showProgress = 1;
 }
 if (defined($ENV{"MPITEST_STOPTEST"})) {
     $stopfile = $ENV{"MPITEST_STOPTEST"};
@@ -117,7 +120,7 @@ else {
 if (defined($ENV{"MPITEST_TIMEOUT"})) {
     $defaultTimeLimit = $ENV{"MPITEST_TIMEOUT"};
 }
+
 # Define this to leave the XML output file open to receive additional data
 if (defined($ENV{'NOXMLCLOSE'}) && $ENV{'NOXMLCLOSE'} eq 'YES') {
     $closeXMLOutput = 0;
@@ -145,16 +148,16 @@ if (defined($ENV{'MPITEST_BATCHDIR'})) {
 # Process arguments and override any defaults
 #---------------------------------------------------------------------------
 foreach $_ (@ARGV) {
-    if (/--?mpiexec=(.*)/) { 
-       # Use mpiexec as given - it may be in the path, and 
+    if (/--?mpiexec=(.*)/) {
+       # Use mpiexec as given - it may be in the path, and
        # we don't want to bother to try and find it.
-       $mpiexec = $1; 
+       $mpiexec = $1;
     }
     elsif (/--?np=(.*)/)   { $np_default = $1; }
     elsif (/--?maxnp=(.*)/) { $np_max = $1; }
     elsif (/--?tests=(.*)/) { $listfiles = $1; }
     elsif (/--?srcdir=(.*)/) { $srcdir = $1;
-       $mpiexec="$mpiexec  -platform ${srcdir}/../../../../examples/msg/small_platform_with_routers.xml -hostfile ${srcdir}/../hostfile --log=root.thr:critical"; }
+       $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"; }
     elsif (/--?verbose/) { $verbose = 1; }
     elsif (/--?showprogress/) { $showProgress = 1; }
     elsif (/--?debug/) { $debug = 1; }
@@ -162,6 +165,13 @@ foreach $_ (@ARGV) {
     elsif (/--?batchdir=(.*)/) { $batrundir = $1; }
     elsif (/--?timeoutarg=(.*)/) { $timeoutArgPattern = $1; }
     elsif (/--?execarg=(.*)/) { $execarg = "$execarg $1"; }
+    elsif (/--?privatization=(.*)/) { 
+print STDERR "privatization called\n";
+$enabled_privatization = $1; }
+    elsif (/VALGRIND_COMMAND=(.*)/) { 
+        $valgrind = $1; }
+    elsif (/VALGRIND_OPTIONS=(.*)/) {
+         $wrapparg = "-wrapper \"$valgrind $1\""; }
     elsif (/--?xmlfile=(.*)/) {
        $xmlfile   = $1;
        if (! ($xmlfile =~ /^\//)) {
@@ -207,14 +217,6 @@ foreach $_ (@ARGV) {
         # we do not know at this point how many tests will be run, so do
         # not print a test plan line like "1..450" until the very end
     }
-    else {
-       print STDERR "Unrecognized argument $_\n";
-       print STDERR "runtests [-tests=testfile] [-np=nprocesses] \
-        [-maxnp=max-nprocesses] [-srcdir=location-of-tests] \
-        [-xmlfile=filename ] [-noxmlclose] \
-        [-verbose] [-showprogress] [-debug] [-batch]\n";
-       exit(1);
-    }
 }
 
 # Perform any post argument processing
@@ -238,21 +240,21 @@ if ($listfiles eq "") {
     if ($batchRun) {
        print STDERR "An implicit list of tests is not permitted in batch mode\n";
        exit(1);
-    } 
+    }
     else {
        &ProcessImplicitList;
     }
 }
-elsif (-d $listfiles) { 
+elsif (-d $listfiles) {
     print STDERR "Testing by directories not yet supported\n";
 }
 else {
     &RunList( $listfiles );
 }
 
-if ($xmloutput && $closeXMLOutput) { 
+if ($xmloutput && $closeXMLOutput) {
     print XMLOUT "</MPITESTRESULTS>$newline";
-    close XMLOUT; 
+    close XMLOUT;
 }
 
 if ($tapoutput) {
@@ -268,6 +270,7 @@ if ($batchRun) {
 else {
     if ($err_count) {
        print "$err_count tests failed out of $total_run\n";
+       print "Failing tests : $failed_tests\n";
        if ($xmloutput) {
            print "Details in $xmlfullfile\n";
        }
@@ -282,8 +285,8 @@ else {
 #\f
 # ---------------------------------------------------------------------------
 # Routines
-# 
-# Enter a new directory and process a list file.  
+#
+# Enter a new directory and process a list file.
 #  ProcessDir( directory-name, list-file-name )
 sub ProcessDir {
     my $dir = $_[0]; $dir =~ s/\/$//;
@@ -311,12 +314,12 @@ sub ProcessDir {
     $srcdir = $savesrcdir;
 }
 # ---------------------------------------------------------------------------
-# Run the programs listed in the file given as the argument. 
+# Run the programs listed in the file given as the argument.
 # This file describes the tests in the format
 #  programname number-of-processes [ key=value ... ]
 # If the second value is not given, the default value is used.
-# 
-sub RunList { 
+#
+sub RunList {
     my $LIST = "LIST$depth"; $depth++;
     my $listfile = $_[0];
     my $ResultTest = "";
@@ -327,7 +330,7 @@ sub RunList {
     if (! -s "$listfile" && -s "$srcdir/$curdir/$listfile" ) {
        $listfileSource = "$srcdir/$curdir/$listfile";
     }
-    open( $LIST, "<$listfileSource" ) || 
+    open( $LIST, "<$listfileSource" ) ||
        die "Could not open $listfileSource\n";
     while (<$LIST>) {
        # Check for stop file
@@ -345,7 +348,7 @@ sub RunList {
        # Some tests require that support routines are built first
        # This is specified with !<dir>:<target>
        if (/^\s*\!([^:]*):(.*)/) {
-           # Hack: just execute in a subshell.  This discards any 
+           # Hack: just execute in a subshell.  This discards any
            # output.
            `cd $1 && make $2`;
            next;
@@ -366,6 +369,7 @@ sub RunList {
        my $requiresMPIX   = "";
        my $progEnv    = "";
        my $mpiVersion = "";
+        my $needs_privatization = 0;
         my $xfail = "";
        if ($#args >= 1) { $np = $args[1]; }
        # Process the key=value arguments
@@ -394,6 +398,9 @@ sub RunList {
                elsif ($key eq "mpiversion") {
                    $mpiVersion = $value;
                }
+               elsif ($key eq "needs_privatization") {
+                   $needs_privatization = $value;
+               }
                elsif ($key eq "strict") {
                    $requiresStrict = $value
                }
@@ -415,6 +422,13 @@ sub RunList {
        # skip empty lines
        if ($programname eq "") { next; }
 
+       #if privatization is disabled, and if the test needs it, ignore it
+       if ($needs_privatization == 1 &&
+               $enabled_privatization != 1) {
+                SkippedTest($programname, $np, $workdir, "requires SMPI privatization");
+               next; 
+       }
+
        if ($np eq "") { $np = $np_default; }
        if ($np_max > 0 && $np > $np_max) { $np = $np_max; }
 
@@ -430,7 +444,7 @@ sub RunList {
 
        # If a minimum MPI version is specified, check against the
        # available MPI.  If the version is unknown, we ignore this
-       # test (thus, all tests will be run).  
+       # test (thus, all tests will be run).
        if ($mpiVersion ne "" && $MPIMajorVersion ne "unknown" &&
            $MPIMinorVersion ne "unknown") {
            my ($majorReq,$minorReq) = split(/\./,$mpiVersion);
@@ -467,7 +481,7 @@ sub RunList {
         }
 
        if (-d $programname) {
-           # If a directory, go into the that directory and 
+           # If a directory, go into the that directory and
            # look for a new list file
            &ProcessDir( $programname, $listfile );
        }
@@ -475,13 +489,13 @@ sub RunList {
            $total_run++;
            if (&BuildMPIProgram( $programname, $xfail ) == 0) {
                if ($batchRun == 1) {
-                   &AddMPIProgram( $programname, $np, $ResultTest, 
+                   &AddMPIProgram( $programname, $np, $ResultTest,
                                    $InitForRun, $timeLimit, $progArgs,
                                    $progEnv, $mpiexecArgs, $xfail );
                }
                else {
-                   &RunMPIProgram( $programname, $np, $ResultTest, 
-                                   $InitForRun, $timeLimit, $progArgs, 
+                   &RunMPIProgram( $programname, $np, $ResultTest,
+                                   $InitForRun, $timeLimit, $progArgs,
                                    $progEnv, $mpiexecArgs, $xfail );
                }
            }
@@ -518,10 +532,10 @@ sub ProcessImplicitList {
        if ($programname eq "configure") { next; } # Ignore configure script
        if ($programname eq "config.status") { next; } # Ignore configure helper
        if (-x $programname) { $found_exec++; }
-       if ($programname =~ /\.[cf]$/) { $found_src++; } 
+       if ($programname =~ /\.[cf]$/) { $found_src++; }
     }
     close PGMS;
-    
+
     if ($found_exec) {
        print "Found executables\n" if $debug;
        open (PGMS, "ls -1 |" ) || die "Cannot list programs\n";
@@ -543,7 +557,7 @@ sub ProcessImplicitList {
        }
        close PGMS;
     }
-    elsif ($found_src) { 
+    elsif ($found_src) {
        print "Found source files\n" if $debug;
        open (PGMS, "ls -1 *.c |" ) || die "Cannot list programs\n";
        while (<PGMS>) {
@@ -572,7 +586,7 @@ sub ProcessImplicitList {
        close PGMS;
     }
 }
-# Run the program.  
+# Run the program.
 # ToDo: Add a way to limit the time that any particular program may run.
 # The arguments are
 #    name of program, number of processes, name of routine to check results
@@ -595,14 +609,14 @@ sub RunMPIProgram {
        $timeout = $timeLimit;
     }
     $ENV{"MPIEXEC_TIMEOUT"} = $timeout;
-    
+
     # Run the optional setup routine. For example, the timeout tests could
     # be set to a shorter timeout.
     if ($InitForTest ne "") {
        &$InitForTest();
     }
     print STDOUT "Env includes $progEnv\n" if $verbose;
-    print STDOUT "$mpiexec $mpiexecArgs $np_arg $np $program_wrapper ./$programname $progArgs\n" if $verbose;
+    print STDOUT "$mpiexec $wrapparg $mpiexecArgs $np_arg $np $program_wrapper ./$programname $progArgs\n" if $verbose;
     print STDOUT "." if $showProgress;
     # Save and restore the environment if necessary before running mpiexec.
     if ($progEnv ne "") {
@@ -616,7 +630,7 @@ sub RunMPIProgram {
            }
        }
     }
-    open ( MPIOUT, "$mpiexec $np_arg $np $mpiexecArgs $program_wrapper ./$programname $progArgs 2>&1 |" ) ||
+    open ( MPIOUT, "$mpiexec $wrapparg $np_arg $np $mpiexecArgs $program_wrapper ./$programname $progArgs 2>&1 |" ) ||
        die "Could not run ./$programname\n";
     if ($progEnv ne "") {
        %ENV = %saveEnv;
@@ -627,7 +641,7 @@ sub RunMPIProgram {
     }
     else {
        if ($verbose) {
-           $inline = "$mpiexec $np_arg $np $program_wrapper ./$programname\n";
+           $inline = "$mpiexec $wrapparg $np_arg $np $program_wrapper ./$programname\n";
        }
        else {
            $inline = "";
@@ -644,6 +658,8 @@ sub RunMPIProgram {
                print STDERR "Unexpected output in $programname: $_";
                if (!$found_error) {
                    $found_error = 1;
+                   $failed_tests .= $programname;
+                   $failed_tests .= " ";
                    $err_count ++;
                }
            }
@@ -652,6 +668,8 @@ sub RunMPIProgram {
            print STDERR "Program $programname exited without No Errors\n";
            if (!$found_error) {
                $found_error = 1;
+               $failed_tests .= $programname;
+               $failed_tests .= " ";
                $err_count ++;
            }
        }
@@ -667,6 +685,8 @@ sub RunMPIProgram {
                if ($signal_num != 0) {
                    print STDERR "Program $programname exited with signal $signal_num\n";
                }
+               $failed_tests .= $programname;
+               $failed_tests .= " ";
                $found_error = 1;
                $err_count ++;
            }
@@ -675,7 +695,7 @@ sub RunMPIProgram {
     if ($found_error) {
        &RunTestFailed( $programname, $np, $curdir, $inline, $xfail );
     }
-    else { 
+    else {
        &RunTestPassed( $programname, $np, $curdir, $xfail );
     }
     &RunPostMsg( $programname, $np, $curdir );
@@ -701,13 +721,13 @@ sub AddMPIProgram {
     # Set a default timeout on tests (3 minutes for now)
     my $timeout = $defaultTimeLimit;
     if (defined($timeLimit) && $timeLimit =~ /^\d+$/) {
-       # On some systems, there is no effective time limit on 
+       # On some systems, there is no effective time limit on
        # individual mpi program runs.  In that case, we may
        # want to treat these also as "run manually".
        $timeout = $timeLimit;
     }
     print BATOUT "export MPIEXEC_TIMEOUT=$timeout\n";
-    
+
     # Run the optional setup routine. For example, the timeout tests could
     # be set to a shorter timeout.
     if ($InitForTest ne "") {
@@ -715,8 +735,8 @@ sub AddMPIProgram {
     }
 
     # For non-MPICH versions of mpiexec, a timeout may require a different
-    # environment variable or command line option (e.g., for Cray aprun, 
-    # the option -t <sec> must be given, there is no environment variable 
+    # environment variable or command line option (e.g., for Cray aprun,
+    # the option -t <sec> must be given, there is no environment variable
     # to set the timeout.
     $extraArgs = "";
     if (defined($timeoutArgPattern) && $timeoutArgPattern ne "") {
@@ -730,11 +750,11 @@ sub AddMPIProgram {
     print STDOUT "." if $showProgress;
     # Save and restore the environment if necessary before running mpiexec.
     if ($progEnv ne "") {
-       # Need to fix: 
+       # Need to fix:
        # save_NAME_is_set=is old name set
        # save_NAME=oldValue
        # export NAME=newvalue
-       # (run) 
+       # (run)
        # export NAME=oldValue (if set!)
        print STDERR "Batch output does not permit changes to environment\n";
     }
@@ -749,10 +769,15 @@ sub AddMPIProgram {
     print BATOUT "echo \$? > runtests.$testCount.status\n";
 }
 
-# 
+#
 # Return value is 0 on success, non zero on failure
 sub BuildMPIProgram {
     my $programname = shift;
+    if (! -x $programname) {
+        die "Could not find $programname. Aborting.\n";
+    }
+    return 0;
+    # THE FOLLOWING IS DISABLED.
     my $xfail = shift;
     my $rc = 0;
     if ($verbose) { print STDERR "making $programname\n"; }
@@ -767,7 +792,7 @@ sub BuildMPIProgram {
            $rc = 1;
        }
        # Add a line to the summary file describing the failure
-       # This will ensure that failures to build will end up 
+       # This will ensure that failures to build will end up
        # in the summary file (which is otherwise written by the
        # RunMPIProgram step)
        &RunPreMsg( $programname, $np, $curdir );
@@ -779,10 +804,10 @@ sub BuildMPIProgram {
 
 sub CleanUpAfterRun {
     my $programname = $_[0];
-    
+
     # Check for that this program has exited.  If it is still running,
     # issue a warning and leave the application.  Of course, this
-    # check is complicated by the lack of a standard access to the 
+    # check is complicated by the lack of a standard access to the
     # running processes for this user in Unix.
     @stillRunning = &FindRunning( $programname );
 
@@ -805,7 +830,7 @@ sub CleanUpAfterRun {
     }
 }
 # ----------------------------------------------------------------------------
-sub FindRunning { 
+sub FindRunning {
     my $programname = $_[0];
     my @pids = ();
 
@@ -813,7 +838,7 @@ sub FindRunning {
     my $pidloc = 1;
     my $rc = open PSFD, "ps auxw -U $logname 2>&1 |";
 
-    if ($rc == 0) { 
+    if ($rc == 0) {
        $rc = open PSFD, "ps -fu $logname 2>&1 |";
     }
     if ($rc == 0) {
@@ -837,7 +862,7 @@ sub FindRunning {
 }
 # ----------------------------------------------------------------------------
 #
-# TestStatus is a special test that reports success *only* when the 
+# TestStatus is a special test that reports success *only* when the
 # status return is NONZERO
 sub TestStatus {
     my $MPIOUT = $_[0];
@@ -878,7 +903,7 @@ sub TestStatus {
     return ($found_error,$inline);
 }
 #
-# TestTimeout is a special test that reports success *only* when the 
+# TestTimeout is a special test that reports success *only* when the
 # status return is NONZERO and there are no processes left over.
 # This test currently checks only for the return status.
 sub TestTimeout {
@@ -899,7 +924,7 @@ sub TestTimeout {
        if (/job ending due to env var MPIEXEC_TIMEOUT/) { next; }
        # Allow 'APPLICATION TIMED OUT' (hydra)
        if (/\[mpiexec@.*\] APPLICATION TIMED OUT/) { last; }
-       # ANY output is an error (other than timeout) 
+       # ANY output is an error (other than timeout)
        if (! /^\s*$/) {
            print STDERR "Unexpected output in $programname: $_";
            if (!$found_error) {
@@ -926,13 +951,13 @@ sub TestTimeout {
     # Here should go a check of the processes
     # open( PFD, "ps -fu $LOGNAME | grep -v grep | grep $programname |" );
     # while (<PFD>) {
-    #     
+    #
     # }
     # close PFD;
     return ($found_error,$inline);
 }
 #
-# TestErrFatal is a special test that reports success *only* when the 
+# TestErrFatal is a special test that reports success *only* when the
 # status return is NONZERO; it ignores error messages
 sub TestErrFatal {
     my $MPIOUT = $_[0];