Blame maint/checkbuilds.in

Packit Service c5cf8c
#! /usr/bin/env perl
Packit Service c5cf8c
# -*- Mode: perl; -*-
Packit Service c5cf8c
# @configure_input@
Packit Service c5cf8c
#
Packit Service c5cf8c
# Configure and build mpich with some of the options
Packit Service c5cf8c
#
Packit Service c5cf8c
# Set default values
Packit Service c5cf8c
$projects_dir = "/home/MPI/testing/tsuites";
Packit Service c5cf8c
# alt is for systems that have /homes instead of /home
Packit Service c5cf8c
$altprojects_dir = "/homes/MPI/testing/tsuites";
Packit Service c5cf8c
if (! -d $projects_dir && -d $altprojects_dir ) {
Packit Service c5cf8c
    $projects_dir = $altprojects_dir;
Packit Service c5cf8c
}
Packit Service c5cf8c
$srcdir  = "/home/MPI/testing/mpich2/mpich2";
Packit Service c5cf8c
$logname = $ENV{"LOGNAME"};
Packit Service c5cf8c
$tmpdir = "/sandbox/$logname";
Packit Service c5cf8c
# rundir is the directory in which to run the tests.
Packit Service c5cf8c
$rundir = "";
Packit Service c5cf8c
Packit Service c5cf8c
# By default, use random arguments for the tests
Packit Service c5cf8c
$use_rand_args = 1;
Packit Service c5cf8c
#
Packit Service c5cf8c
$is_xml = 0;
Packit Service c5cf8c
# Set the default compilers.  These can be overridden by setting the CC
Packit Service c5cf8c
# and FC environment variables.
Packit Service c5cf8c
$ccname = "gcc";
Packit Service c5cf8c
$fcname = "f77";
Packit Service c5cf8c
#
Packit Service c5cf8c
# Set whether the C++ and Fortran bindings have been built.  
Packit Service c5cf8c
$has_f77 = 1;
Packit Service c5cf8c
$has_cxx = 1;
Packit Service c5cf8c
Packit Service c5cf8c
# Set this for the make option to enable the execution of multiple job
Packit Service c5cf8c
# steps at once.  Do not use this if the archive step (ar) is not setup
Packit Service c5cf8c
# to avoid concurrent, conflicting updates to the same archive.
Packit Service c5cf8c
$parallelBuild = "-j 8";
Packit Service c5cf8c
#$parallelBuild = "";
Packit Service c5cf8c
#
Packit Service c5cf8c
# Some process managers require separate startup and rundown steps.  The 
Packit Service c5cf8c
# following variables are used to handle this
Packit Service c5cf8c
$StartDemon = "";     # Name of routine to start demons
Packit Service c5cf8c
$StopDemon  = "";     # Name of routine to stop demons
Packit Service c5cf8c
$hasDemon   = 0;
Packit Service c5cf8c
Packit Service c5cf8c
#
Packit Service c5cf8c
# Set available options.  For enable and with, the values are
Packit Service c5cf8c
# {with,enable}-name[;possiblevalues]*
Packit Service c5cf8c
# We need a way to keep these consistent with the arguments recognized by
Packit Service c5cf8c
# configure
Packit Service c5cf8c
@enable_array = ( 
Packit Service c5cf8c
		  'error-checking;no;runtime;all', 
Packit Service c5cf8c
		  'error-messages;all;generic;class;none',
Packit Service c5cf8c
		  'timer-type;linux86_cycle;gethrtime;clock_gettime;gettimeofday',
Packit Service c5cf8c
		  'timing;none;all;runtime;log;log_detailed',
Packit Service c5cf8c
		  'g;none;all;handle;dbg;log;meminit;handlealloc;instr;mem;mutex;mutexnesting;memarena',
Packit Service c5cf8c
		  'fast;nochkmsg;notiming;ndebug;all',
Packit Service c5cf8c
		  'f77',
Packit Service c5cf8c
		  'fc',
Packit Service c5cf8c
		  'cxx',
Packit Service c5cf8c
		  'romio',
Packit Service c5cf8c
		  'coverage',
Packit Service c5cf8c
                  'check-compiler-flags',
Packit Service c5cf8c
                  'smpcoll',
Packit Service c5cf8c
		  'strict;c99;posix',    #;posix
Packit Service c5cf8c
		  'debuginfo', # Message queues
Packit Service c5cf8c
		  'weak-symbols;no;yes',
Packit Service c5cf8c
                  'threads;single;multiple;runtime',
Packit Service c5cf8c
                  'thread-cs;global;per-object;lock-free',
Packit Service c5cf8c
                  'refcount;lock;lock-free;none',
Packit Service c5cf8c
                  'mutex-timing',
Packit Service c5cf8c
                  'multi-aliases',
Packit Service c5cf8c
                  'wrapper-rpath',
Packit Service c5cf8c
                  'predefined-refcount',
Packit Service c5cf8c
                  'alloca',
Packit Service c5cf8c
                  'yield;sched_yield;yield;select;usleep;sleep',
Packit Service c5cf8c
                  'checkpointing',
Packit Service c5cf8c
		  'runtimevalues',   # Fortran true/false
Packit Service c5cf8c
);
Packit Service c5cf8c
%chosenEnable = ();
Packit Service c5cf8c
@with_array = (
Packit Service c5cf8c
	       'logging;none;rlog',
Packit Service c5cf8c
	       'pmi;simple',    #; uni no longer supported
Packit Service c5cf8c
	       'pm;gforker', #;remshell
Packit Service c5cf8c
	       'namepublisher;no;file', #;ldap:ldapserver',
Packit Service c5cf8c
	       'device;ch3;ch3:sock',
Packit Service c5cf8c
);
Packit Service c5cf8c
%chosenWith = ();
Packit Service c5cf8c
@env_array = (
Packit Service c5cf8c
#	      'CC;gcc;cc;pgcc;ecc;xlc',
Packit Service c5cf8c
#	      'FC;f77;pgf77;efc;xlf',
Packit Service c5cf8c
#	      'CXX;gcc;CC;pgCC;ecc;xlC',
Packit Service c5cf8c
#             'CFLAGS;-g;-O',
Packit Service c5cf8c
);	      
Packit Service c5cf8c
Packit Service c5cf8c
# Also cross;sample-cross-files, but we need the files first
Packit Service c5cf8c
# Also missing are levels of thread support.
Packit Service c5cf8c
Packit Service c5cf8c
$n_enable  = $#enable_array + 1;
Packit Service c5cf8c
$n_with    = $#with_array + 1;
Packit Service c5cf8c
$n_env     = $#env_array + 1;
Packit Service c5cf8c
$show      = 0;
Packit Service c5cf8c
$debug     = 0;
Packit Service c5cf8c
$echoSteps = 0;         # Set to one to echo each run program to stdout
Packit Service c5cf8c
$report_signals = 1;    # Set to one to generate a message about signals
Packit Service c5cf8c
                        # received by a program
Packit Service c5cf8c
$max_count = 5;
Packit Service c5cf8c
$OUTFD     = OUTFD;
Packit Service c5cf8c
#
Packit Service c5cf8c
# The following variable separate the various sections
Packit Service c5cf8c
$TestStart = "-----------------------------------------------------------\n";
Packit Service c5cf8c
$TestEnd   = "-----------------------------------------------------------\n";
Packit Service c5cf8c
$TestDateStart = "Run on ";
Packit Service c5cf8c
$TestDateEnd   = "\n";
Packit Service c5cf8c
$TestHostStart = "Run on host ";
Packit Service c5cf8c
$TestHostEnd   = "\n";
Packit Service c5cf8c
$TestUserStart = "Run by ";
Packit Service c5cf8c
$TestUserEnd   = "\n";
Packit Service c5cf8c
$ConfigStart = " -- Begin Configure Step -- \n";
Packit Service c5cf8c
$ConfigEnd   = " -- End   Configure Step -- \n";
Packit Service c5cf8c
$MakeStart   = " -- Begin Make Step --\n";
Packit Service c5cf8c
$MakeEnd     = " -- End   Make Step --\n";
Packit Service c5cf8c
$GlobNameStart = " -- Begin Check of global names --\n";
Packit Service c5cf8c
$GlobNameEnd   = " -- End   Check of global names --\n";
Packit Service c5cf8c
$UsedNameStart = " -- Begin Check of used names --\n";
Packit Service c5cf8c
$UsedNameEnd   = " -- End   Check of used names --\n";
Packit Service c5cf8c
$MakeInstStart = " -- Begin Make Install Step --\n";
Packit Service c5cf8c
$MakeInstEnd   = " -- End   Make Install Step --\n";
Packit Service c5cf8c
$MakeInstcheckStart = " -- Begin Make Installcheck Step --\n";
Packit Service c5cf8c
$MakeInstcheckEnd   = " -- End   Make Installcheck Step --\n";
Packit Service c5cf8c
$RunTestStart  = " -- Begin Run Test Step --\n";
Packit Service c5cf8c
$RunTestEnd    = " -- End   Run Test Step --\n";
Packit Service c5cf8c
$SumStart = "";
Packit Service c5cf8c
$SumEnd   = "";
Packit Service c5cf8c
$SumConfigStart = "Config status = ";
Packit Service c5cf8c
$SumConfigEnd   = "\n";
Packit Service c5cf8c
$SumMakeStart = "Make status = ";
Packit Service c5cf8c
$SumMakeEnd   = "\n";
Packit Service c5cf8c
$SumGlobStart  = "Global name check status = ";
Packit Service c5cf8c
$SumGlobEnd    = "\n";
Packit Service c5cf8c
$SumInstStart = "Install status = ";
Packit Service c5cf8c
$SumInstEnd   = "\n";
Packit Service c5cf8c
$SumTestRunStart = "Test status = ";
Packit Service c5cf8c
$SumTestRunEnd   = "\n";
Packit Service c5cf8c
Packit Service c5cf8c
# Defaults
Packit Service c5cf8c
$config_args = "";
Packit Service c5cf8c
$with_args   = "";
Packit Service c5cf8c
$enable_args = "";
Packit Service c5cf8c
$env_args    = "";
Packit Service c5cf8c
$outfile     = "";
Packit Service c5cf8c
$builddir    = "";
Packit Service c5cf8c
$instdir     = "";
Packit Service c5cf8c
# Read the arguments
Packit Service c5cf8c
foreach $_ (@ARGV) {
Packit Service c5cf8c
    if (/--?enable-n=(\d*)/) {
Packit Service c5cf8c
	$n_enable = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?with-n=(\d*)/) {
Packit Service c5cf8c
	$n_with = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?show/) {
Packit Service c5cf8c
	$show = 1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?debug/) {
Packit Service c5cf8c
	$debug = 1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?envopt=(.*)/) {
Packit Service c5cf8c
	# Add a list of possible env values
Packit Service c5cf8c
	$env_array[$#env_array+1] = $1;
Packit Service c5cf8c
	$n_env    = $#env_array + 1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?srcdir=(.*)/) {
Packit Service c5cf8c
	$srcdir  = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?instdir=(.*)/) {
Packit Service c5cf8c
	$instdir = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?rundir=(.*)/) {
Packit Service c5cf8c
	$rundir = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?projectsdir=(.*)/) {
Packit Service c5cf8c
	$projects_dir = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?maxcount=(.*)/) {
Packit Service c5cf8c
	# max count.  Set to -1 for infinity
Packit Service c5cf8c
	$max_count = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?maxtime=(.*)/) {
Packit Service c5cf8c
	# max time in seconds
Packit Service c5cf8c
	set_time_left( $1 );
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?tests=(.*)/) {
Packit Service c5cf8c
	$tests = ":" . $1 . ":";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?outfile=(.*)/) {
Packit Service c5cf8c
	$outfile = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?tmpdir=(.*)/) {
Packit Service c5cf8c
	$tmpdir = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?builddir=(.*)/) {
Packit Service c5cf8c
	$builddir = $1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?xml/) {
Packit Service c5cf8c
	&XMLStyle;
Packit Service c5cf8c
	$is_xml = 1;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?norand/) {
Packit Service c5cf8c
	$use_rand_args = 0;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?enable=(.*)/) {
Packit Service c5cf8c
	$use_rand_args = 0;
Packit Service c5cf8c
	$enable_args .= "$1 ";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?with=(.*)/) {
Packit Service c5cf8c
	$use_rand_args = 0;
Packit Service c5cf8c
	$with_args .= "$1 ";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?env=(.*)/) {
Packit Service c5cf8c
	$use_rand_args = 0;
Packit Service c5cf8c
	$envval=$1;
Packit Service c5cf8c
	$envval =~ s/ /<SP>/g;
Packit Service c5cf8c
	$env_args .= "--env-$envval ";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?configarg=(.*)/) {
Packit Service c5cf8c
	# Use this to add a special arg (such as -host) to the 
Packit Service c5cf8c
	# configure call
Packit Service c5cf8c
	$config_args .= "$1 ";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (/--?help/) {
Packit Service c5cf8c
	print STDERR "\
Packit Service c5cf8c
checkbuilds [ -enable-n=d ] [ -with-n=d ] [ -show ] [-envopt=name;value;... ]
Packit Service c5cf8c
            [-srcdir=SRCDIR] [-instdir=INSTALLDIR] [-builddir=BUILDDIR]
Packit Service c5cf8c
            [-maxcount=MAXCNT] [-maxtime=MAXTIME] 
Packit Service c5cf8c
            [-norand ] [-enable=enable-args] [-with=with-args]
Packit Service c5cf8c
            [-tmpdir=dir]
Packit Service c5cf8c
        -enable-n=d sets the number of --enable options to try
Packit Service c5cf8c
        -with=n=d set the number of --with options to try
Packit Service c5cf8c
        -envopt=name;value;... adds an environment variable with possible
Packit Service c5cf8c
                 values (quote the text so that the semicolons do not
Packit Service c5cf8c
                 cause trouble)
Packit Service c5cf8c
Packit Service c5cf8c
        -maxcount sets the number of builds to try
Packit Service c5cf8c
        -maxtime sets the maximum length of time to run
Packit Service c5cf8c
        Example:
Packit Service c5cf8c
        checkbuilds -envopt=\"CC;gcc;pgcc;ecc\"\n";
Packit Service c5cf8c
        exit(0);
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	print STDERR "checkbuilds: Unrecognized argument $_\n";
Packit Service c5cf8c
	exit(1);
Packit Service c5cf8c
    }
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
#
Packit Service c5cf8c
# Set directories that have not been chosen.
Packit Service c5cf8c
if ($instdir eq "") {
Packit Service c5cf8c
    $instdir = "$tmpdir/cb/mpi2-inst";
Packit Service c5cf8c
}
Packit Service c5cf8c
if ($mpich1_dir eq "") {
Packit Service c5cf8c
    $mpich1_dir = "$projects_dir/mpich1test";
Packit Service c5cf8c
}
Packit Service c5cf8c
# Make the builddir compatible with the installation directory
Packit Service c5cf8c
if ($builddir eq "") {
Packit Service c5cf8c
    $builddir = "$tmpdir/cb/mpich2";
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
Packit Service c5cf8c
#
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
# Run one instance of the configuration
Packit Service c5cf8c
sub RunTest {
Packit Service c5cf8c
    my $makepgm;
Packit Service c5cf8c
Packit Service c5cf8c
    $rc = chdir $builddir;
Packit Service c5cf8c
    if (!$rc) {
Packit Service c5cf8c
	print STDERR "Cannot change to $builddir\n";
Packit Service c5cf8c
	return;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    # Clean the installation and build directories
Packit Service c5cf8c
    # Even better would be to remove the installation directory alltogether,
Packit Service c5cf8c
    # but we should only do that if explicitly requested (we could
Packit Service c5cf8c
    # *require* an empty directory for the tests instead)
Packit Service c5cf8c
    if (-d "$instdir/lib") {
Packit Service c5cf8c
	system "rm -f $instdir/lib/libmpi*.* $instdir/lib/libmpifort*.*";
Packit Service c5cf8c
	system "rm -f $instdir/lib/libmpe*.a";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    if (-d "$instdir/bin") {
Packit Service c5cf8c
	system "rm -f $instdir/bin/mpi*";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    if (-d "$builddir/lib") {
Packit Service c5cf8c
	system "rm -f $builddir/lib/libmpi*.* $builddir/lib/libmpifort*.*";
Packit Service c5cf8c
	system "rm -f $builddir/lib/libmpe*.a";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    # 
Packit Service c5cf8c
    # Create the with and enable options
Packit Service c5cf8c
    #$enable_args = "--enable-strict";  # Only if compiler is gcc
Packit Service c5cf8c
    # Chosen *without* replacement.  If an option is chosen twice, 
Packit Service c5cf8c
    # then there will be fewer options
Packit Service c5cf8c
    %chosenWith = ();
Packit Service c5cf8c
    %chosenEnable = ();
Packit Service c5cf8c
    if ($use_rand_args) {
Packit Service c5cf8c
	$enable_args = &RandArgs( $n_enable, "enable_array", "enable", "disable" );
Packit Service c5cf8c
	$with_args   = &RandArgs ( $n_with, "with_array", "with", "without" );
Packit Service c5cf8c
	
Packit Service c5cf8c
	# To set the environment, use the same code to set things up,
Packit Service c5cf8c
	# then process the env array to set the environment
Packit Service c5cf8c
	$env_args    = &RandArgs( $n_env, "env_array", "env" );
Packit Service c5cf8c
    }
Packit Service c5cf8c
    foreach my $en (split(/\s+/,$enable_args)) {
Packit Service c5cf8c
	if ($en =~ /--enable-([-A-Za-z0-9=]*)/) {
Packit Service c5cf8c
	    my $name = $1;
Packit Service c5cf8c
	    if ($name =~ /(.*)=(.*)/) {
Packit Service c5cf8c
		$chosenEnable{$1} = $2;
Packit Service c5cf8c
		$name = $1;
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    else {
Packit Service c5cf8c
		$chosenEnable{$name} = "yes";
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    print STDERR "setting chosen enable of $name to $chosenEnable{$name}\n" if $debug;
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    foreach my $en (split(/\s+/,$with_args)) {
Packit Service c5cf8c
	if ($en =~ /--with-([-A-Za-z0-9=]*)/) {
Packit Service c5cf8c
	    my $name = $1;
Packit Service c5cf8c
	    if ($name =~ /(.*)=(.*)/) {
Packit Service c5cf8c
		$chosenWith{$1} = $2;
Packit Service c5cf8c
		$name = $1;
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    else {
Packit Service c5cf8c
		$chosenWith{$name} = "yes";
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    print STDERR "setting chosen with of $name to $chosenWith{$name}\n" if $debug;
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    $envset = "";
Packit Service c5cf8c
    %saveENV = %ENV;
Packit Service c5cf8c
    foreach $_ (split(/ /,$env_args)) {
Packit Service c5cf8c
	if (/--env-([^=]*)=(.*)/) {
Packit Service c5cf8c
	    $name  = $1;
Packit Service c5cf8c
	    $value = $2;
Packit Service c5cf8c
	    # Replace <SP> with blanks
Packit Service c5cf8c
	    $value =~ s/<SP>/ /g;
Packit Service c5cf8c
	    # Grrr <SP> is a bad choice, since <> are shell metacharacters.
Packit Service c5cf8c
	    # Allow --SP-- as an alternative
Packit Service c5cf8c
	    $value =~ s/--SP--/ /g;
Packit Service c5cf8c
	    print "Env $name = $value\n" if $debug;
Packit Service c5cf8c
	    # Since most of these so far are programs, we should check to 
Packit Service c5cf8c
	    # see if they're available.  Instead, we'll make the user
Packit Service c5cf8c
	    # specify the valid values (see -envopt above)
Packit Service c5cf8c
	    $ENV{$name} = $value;
Packit Service c5cf8c
	    $envset .= "$name = $value; ";
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    # Get the version of make to use
Packit Service c5cf8c
    if (defined($ENV{"MAKE"})) {
Packit Service c5cf8c
	$makepgm = $ENV{"MAKE"};
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$makepgm = "make";
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    # Check configure location
Packit Service c5cf8c
    if ( ! (-x "$srcdir/configure") && (-x "./configure") ) {
Packit Service c5cf8c
	$srcdir = ".";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    $config_status    = "none";
Packit Service c5cf8c
    $make_status      = "none";
Packit Service c5cf8c
    $globcheck_status = "none";
Packit Service c5cf8c
    # usedname is from the old test to check for which routines
Packit Service c5cf8c
    # were loaded for the simplest MPI Hello World program.
Packit Service c5cf8c
    #$usedname_status  = "none";
Packit Service c5cf8c
    $install_status   = "none";
Packit Service c5cf8c
    $installcheck_status = "none";
Packit Service c5cf8c
    $test_status      = "none";
Packit Service c5cf8c
    if ($show) {
Packit Service c5cf8c
	print "Configure: $enable_args $with_args $config_args\n";
Packit Service c5cf8c
	if ($envset ne "") {
Packit Service c5cf8c
	    print "Environment = $envset\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
#	$enable_args .= " --enable-echo";
Packit Service c5cf8c
	print $OUTFD $TestStart;
Packit Service c5cf8c
	my $host = `uname -n`;
Packit Service c5cf8c
	print $OUTFD "$TestHostStart$host$TestHostEnd";
Packit Service c5cf8c
	my $user = $ENV{"LOGNAME"};
Packit Service c5cf8c
	print $OUTFD "$TestUserStart$user$TestUserEnd";
Packit Service c5cf8c
	my $date = `date "+%Y-%m-%d-%H-%M"`;
Packit Service c5cf8c
	print $OUTFD "$TestDateStart$date$TestDateEnd";
Packit Service c5cf8c
	unlink "Makefile";
Packit Service c5cf8c
	print $OUTFD $ConfigStart;
Packit Service c5cf8c
	@config = split( /\s+/, "$srcdir/configure --prefix=$instdir $enable_args $with_args $config_args" );
Packit Service c5cf8c
	print $OUTFD "Configure: " . join(" ", @config) . "\n";
Packit Service c5cf8c
	if ($envset ne "") {
Packit Service c5cf8c
	    print $OUTFD "Environment = $envset\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
	$rc = &RunProgram( @config );
Packit Service c5cf8c
	$config_status = $rc;
Packit Service c5cf8c
	if (! -s "Makefile" && $rc == 0) {
Packit Service c5cf8c
	    $config_status = "No Makefile";
Packit Service c5cf8c
	    $rc = 1;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	print $OUTFD $ConfigEnd;
Packit Service c5cf8c
	# print "rc = $rc\n";
Packit Service c5cf8c
	if ($rc == 0) {
Packit Service c5cf8c
	    print $OUTFD $MakeStart;
Packit Service c5cf8c
	    $rc = &RunProgram( "$makepgm $parallelBuild" );
Packit Service c5cf8c
	    print $OUTFD $MakeEnd;
Packit Service c5cf8c
	    $make_status = $rc;
Packit Service c5cf8c
	    if ($rc == 0) {
Packit Service c5cf8c
		# Only perform these steps if the make succeeded
Packit Service c5cf8c
Packit Service c5cf8c
# FIXME: Restore the tests for nonconforming global systems and for 
Packit Service c5cf8c
# minimum memory and routing footprint
Packit Service c5cf8c
Packit Service c5cf8c
# Deleted this test because it is no longer a design goal for MPICH
Packit Service c5cf8c
# that it have no nonconforming global symbols
Packit Service c5cf8c
Packit Service c5cf8c
# Deleted this test because it is no longer a design goal for MPICH2
Packit Service c5cf8c
# to have a minimum memory and routine footprint.
Packit Service c5cf8c
Packit Service c5cf8c
		# Install the libraries
Packit Service c5cf8c
		print $OUTFD $MakeInstStart;
Packit Service c5cf8c
		# Clean the install directory
Packit Service c5cf8c
		$install_status = &RunProgram( "$makepgm install" );
Packit Service c5cf8c
		if ($install_status) {
Packit Service c5cf8c
		    my $cwd = `pwd`;
Packit Service c5cf8c
		    chomp $cwd;
Packit Service c5cf8c
		    print $OUTFD "Current directory is $cwd\n";
Packit Service c5cf8c
		}
Packit Service c5cf8c
		print $OUTFD $MakeInstEnd;
Packit Service c5cf8c
		if ($install_status == 0) {
Packit Service c5cf8c
		    # Try the install check target
Packit Service c5cf8c
		    print $OUTFD $MakeInstcheckStart;
Packit Service c5cf8c
		    $installcheck_status = &RunProgram( "$makepgm installcheck" );
Packit Service c5cf8c
		    print $OUTFD $MakeInstcheckEnd;
Packit Service c5cf8c
		    # Run the tests
Packit Service c5cf8c
		    $test_status = &RunTestSuites;
Packit Service c5cf8c
		}
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	}
Packit Service c5cf8c
	print $OUTFD $TestEnd;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    %ENV = %saveENV;
Packit Service c5cf8c
Packit Service c5cf8c
    print $OUTFD $SumStart;
Packit Service c5cf8c
    print $OUTFD $SumConfigStart;
Packit Service c5cf8c
    print $OUTFD $config_status;
Packit Service c5cf8c
    print $OUTFD $SumConfigEnd;
Packit Service c5cf8c
    print $OUTFD $SumMakeStart;
Packit Service c5cf8c
    print $OUTFD $make_status;
Packit Service c5cf8c
    print $OUTFD $SumMakeEnd;
Packit Service c5cf8c
    print $OUTFD $SumGlobStart;
Packit Service c5cf8c
    print $OUTFD $globcheck_status;
Packit Service c5cf8c
    print $OUTFD $SumGlobEnd;
Packit Service c5cf8c
    print $OUTFD $SumInstStart;
Packit Service c5cf8c
    print $OUTFD $install_status;
Packit Service c5cf8c
    print $OUTFD $SumInstEnd;
Packit Service c5cf8c
    print $OUTFD $SumTestRunStart;
Packit Service c5cf8c
    print $OUTFD $test_status;
Packit Service c5cf8c
    print $OUTFD $SumTestRunEnd;
Packit Service c5cf8c
    print $OUTFD $SumEnd;
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
# Chosen *without* replacement.  If an option is chosen twice, 
Packit Service c5cf8c
# then there will be fewer options
Packit Service c5cf8c
sub RandArgs { 
Packit Service c5cf8c
    my ($n_choice, $array_name, $optname, $negoptname ) = @_;
Packit Service c5cf8c
    my @chosen = ( );
Packit Service c5cf8c
    my $args = "";
Packit Service c5cf8c
    my $array_len = $#$array_name;
Packit Service c5cf8c
    my $idx;
Packit Service c5cf8c
Packit Service c5cf8c
    print "select $n_choice\n" if $debug;
Packit Service c5cf8c
    for (my $i=0; $i<$n_choice; $i++) {
Packit Service c5cf8c
	$idx = int( rand (1 + $array_len) );
Packit Service c5cf8c
	print "Found $idx\n" if $debug;
Packit Service c5cf8c
	if ($chosen[$idx]) { next; }
Packit Service c5cf8c
	$chosen[$idx] = 1;
Packit Service c5cf8c
	@args = split( /;/, $$array_name[$idx] );
Packit Service c5cf8c
	print "Trying $$array_name[$idx]\n" if $debug;
Packit Service c5cf8c
	$name = $args[0];
Packit Service c5cf8c
	if ($#args == 0) {
Packit Service c5cf8c
	    # Only the name is provided.  Choose one of three
Packit Service c5cf8c
	    # choices:
Packit Service c5cf8c
	    #    No option (skip this one)
Packit Service c5cf8c
	    #    just --$optname-$name
Packit Service c5cf8c
	    #    just --$negoptname-$name (if non-null)
Packit Service c5cf8c
	    $idx = int ( rand ( 3 ) );
Packit Service c5cf8c
	    if ($idx == 0) {
Packit Service c5cf8c
		$args .= " --$optname-$name";
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    elsif ($idx == 1 && $negoptname ne "") {
Packit Service c5cf8c
		$args .= " --$negoptname-$name";
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    else {
Packit Service c5cf8c
		# skip
Packit Service c5cf8c
		;
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	}
Packit Service c5cf8c
	else {
Packit Service c5cf8c
	    $idx = 1 + int( rand $#args );
Packit Service c5cf8c
	    $value = $args[$idx];
Packit Service c5cf8c
	    if ($value ne "") {
Packit Service c5cf8c
		$args .=  " --$optname-$name=$value";
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    else {
Packit Service c5cf8c
		$args .= " --$optname-$name";
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    return $args;
Packit Service c5cf8c
}
Packit Service c5cf8c
    
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
# Timer support.  Time_left returns 1 if time remains, 0 otherwise
Packit Service c5cf8c
$final_time = -1;
Packit Service c5cf8c
sub set_time_left {
Packit Service c5cf8c
    my $delta_time = $_[0];
Packit Service c5cf8c
    $final_time = time + $delta_time;
Packit Service c5cf8c
}
Packit Service c5cf8c
sub time_left {
Packit Service c5cf8c
    if ($final_time eq "" || $final_time == -1) {     return 1; }
Packit Service c5cf8c
    if (time > $final_time) { return 0; }
Packit Service c5cf8c
    else                    { return 1; }
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
# cb for check build
Packit Service c5cf8c
#
Packit Service c5cf8c
# Eventually, we'll need
Packit Service c5cf8c
#   bootstep
Packit Service c5cf8c
#   compiler names
Packit Service c5cf8c
#   unbootstep
Packit Service c5cf8c
# for each test.
Packit Service c5cf8c
#
Packit Service c5cf8c
sub RunTestSuites {
Packit Service c5cf8c
    my $run_status = 0;
Packit Service c5cf8c
    my $r_status = 0;
Packit Service c5cf8c
    # Start by adding "notest" files to any optional tests
Packit Service c5cf8c
    if (!$has_cxx) {
Packit Service c5cf8c
	&SkipCxxTestSuite;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    foreach my $testname (split(':',$tests)) {
Packit Service c5cf8c
	if ($testname eq "") { next; }
Packit Service c5cf8c
	print $OUTFD $RunTestStart;
Packit Service c5cf8c
	if ($is_xml) { 
Packit Service c5cf8c
	    print $OUTFD "<TESTNAME>$testname</TESTNAME>\n";
Packit Service c5cf8c
	    print $OUTFD "<TESTOUT>\n";
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	else {
Packit Service c5cf8c
	    print $OUTFD "Running test $testname...\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
	# Eventually, we should store the test routines in a hash, 
Packit Service c5cf8c
	# with the key the test name and the value the name of the 
Packit Service c5cf8c
	# routine.  
Packit Service c5cf8c
	if ($testname eq "mpich") {
Packit Service c5cf8c
	    &RunMpichTestSuite;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	elsif ($testname eq "intel") {
Packit Service c5cf8c
	    &RunIntelTestSuite;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	elsif ($testname eq "testmpio") {
Packit Service c5cf8c
	    &RunTestMPIOSuite;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	elsif ($testname eq "mpicxx" && $has_cxx) {
Packit Service c5cf8c
	    &RunCxxTestSuite;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	elsif ($testname eq "mpich2") {
Packit Service c5cf8c
	    &RunMPICH2TestSuite;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	else {
Packit Service c5cf8c
	    print $OUTFD "checkbuilds: Unrecognized test $testname\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
	if ($is_xml) { 
Packit Service c5cf8c
	    print $OUTFD "</TESTOUT>\n";
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	print $OUTFD $RunTestEnd;
Packit Service c5cf8c
	if ($run_status != 0) { 
Packit Service c5cf8c
	    # If any test fails, record its status.
Packit Service c5cf8c
	    $r_status = $run_status;
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    return $r_status;
Packit Service c5cf8c
}
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
sub RunMpichTestSuite {
Packit Service c5cf8c
    my $nargs;
Packit Service c5cf8c
    $cwd = `pwd`;
Packit Service c5cf8c
    chomp $cwd;
Packit Service c5cf8c
    my @config;
Packit Service c5cf8c
Packit Service c5cf8c
    if ($mpich_test_dir eq "") {
Packit Service c5cf8c
	$mpich_test_dir = "$tmpdir/cb/mpitest";
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
# Make sure that the tests run past a failure to build an
Packit Service c5cf8c
# executable.  Without this, the summary doesn't include
Packit Service c5cf8c
# any tests in the same directory that completed.
Packit Service c5cf8c
    $ENV{"MPITEST_CONTINUE"} = "always";
Packit Service c5cf8c
Packit Service c5cf8c
    $rc = chdir $mpich_test_dir;
Packit Service c5cf8c
    if (!$rc) {
Packit Service c5cf8c
	#print STDERR "Cannot change to $mpich_test_dir\n";
Packit Service c5cf8c
	return;
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    # A special hack for the io part 
Packit Service c5cf8c
    # If there is no link or io directory, create one and populate it
Packit Service c5cf8c
    if (! -f "io/Mfile.in") {
Packit Service c5cf8c
	if (-s "$mpich1_dir/io/Mfile.in") {
Packit Service c5cf8c
	    if (! -d "io" && ! -l "io") { 
Packit Service c5cf8c
		`mkdir "io"`;
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    `cp $mpich1_dir/io/*.in io`;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	elsif (-s "$srcdir/src/mpi/romio/test/Mfile.in") {
Packit Service c5cf8c
	    if (! -d "io" && ! -l "io") { 
Packit Service c5cf8c
		`mkdir "io"`;
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    `cp $srcdir/src/mpi/romio/test/*.in io`;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	# Else, we can't find the IO tests, so we don't create the io 
Packit Service c5cf8c
	# directory
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    # Create the arguments for the configure step
Packit Service c5cf8c
    $nargs = 0;
Packit Service c5cf8c
    $config[$nargs++] = "$mpich1_dir/configure";
Packit Service c5cf8c
    $config[$nargs++] = "--prefix=$instdir";
Packit Service c5cf8c
    $config[$nargs++] = "-mpilibname=mpich";
Packit Service c5cf8c
    if (defined($chosenEnable{"romio"})) {
Packit Service c5cf8c
	$config[$nargs++] = "--enable-io";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    # f77 is now the default, so we should run with the f77 tests
Packit Service c5cf8c
    # unless we did not build f77
Packit Service c5cf8c
    if (! $has_f77) {  # !defined($chosenEnable{"f77"}) 
Packit Service c5cf8c
	$config[$nargs++] = "--disable-f77";
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
# This isn't right, since these need to use the compilation 
Packit Service c5cf8c
# scripts.  We'll approximate this by trying to use the
Packit Service c5cf8c
# compilation scripts if they're found
Packit Service c5cf8c
    if (defined($ENV{"CC"})) {
Packit Service c5cf8c
	$ccname = $ENV{"CC"};
Packit Service c5cf8c
    }
Packit Service c5cf8c
    if (defined($ENV{"FC"})) {
Packit Service c5cf8c
	$fcname = $ENV{"FC"};
Packit Service c5cf8c
    }
Packit Service c5cf8c
# Note that there are no quotes in the following because
Packit Service c5cf8c
# they are not needed (no shell evaluation here)
Packit Service c5cf8c
    if (-x "$instdir/bin/mpicc" ) {
Packit Service c5cf8c
	$config[$nargs++] = "-cc=$instdir/bin/mpicc";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$config[$nargs++] = "-cc=$ccname -I$instdir/include -L$instdir/lib";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    if (-x "$instdir/bin/mpifort" ) {
Packit Service c5cf8c
	$config[$nargs++] = "-fc=$instdir/bin/mpifort";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$config[$nargs++] = "-fc=$fcname -I$instdir/include -L$instdir/lib";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    # Add $config[$nargs++] = "--enable-coverage"; 
Packit Service c5cf8c
    # if we build mpich2 with the coverage switch.
Packit Service c5cf8c
Packit Service c5cf8c
    if (defined($ENV{"MAKE"})) {
Packit Service c5cf8c
	$makepgm = $ENV{"MAKE"};
Packit Service c5cf8c
	$config[$nargs++] = "-make=$makepgm";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$makepgm = "make";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    #$config[$nargs++] = "--enable-echo";
Packit Service c5cf8c
    %saveENV = %ENV;
Packit Service c5cf8c
    $ENV{MPIRUN} = "$instdir/bin/mpiexec";
Packit Service c5cf8c
    # This timeout needs to be made uniform for all mpiruns
Packit Service c5cf8c
    # 3 minutes is enough for some of our slower machines
Packit Service c5cf8c
    $ENV{MPIEXEC_TIMEOUT} = "180";
Packit Service c5cf8c
    $rc = &RunProgram( @config );
Packit Service c5cf8c
    if ($rc == 0) {
Packit Service c5cf8c
	if ($hasDemon) {
Packit Service c5cf8c
	    &$StartDemon;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	$rc = &RunProgram( "$makepgm testing" );
Packit Service c5cf8c
	$test_status = $rc;
Packit Service c5cf8c
	if ($run_status == 0 && $rc != 0) { $run_status = $rc; }
Packit Service c5cf8c
	if ($hasDemon) {
Packit Service c5cf8c
	    &$StopDemon;
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$run_status = $rc;
Packit Service c5cf8c
	print $OUTFD "Configure step for test failed\n";
Packit Service c5cf8c
	print $OUTFD "Could not execute " . join(" ", @config) . "\n";
Packit Service c5cf8c
	print $OUTFD "Environment was\n";
Packit Service c5cf8c
	foreach $key (keys(%ENV)) {
Packit Service c5cf8c
	    my $line = "$key = $ENV{$key}";
Packit Service c5cf8c
	    if ($is_xml) { $line = &XMLify( $line ); }
Packit Service c5cf8c
	    print $OUTFD "$line\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    %ENV = %saveENV;
Packit Service c5cf8c
    chdir $cwd;
Packit Service c5cf8c
}
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
sub SkipCxxTestSuite {
Packit Service c5cf8c
    if ($mpicxx_test_dir eq "") {
Packit Service c5cf8c
	$mpicxx_test_dir = "$tmpdir/cb/mpicxxtest";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    `date > $mpicxx_test_dir/notest`;
Packit Service c5cf8c
}
Packit Service c5cf8c
sub RunCxxTestSuite {
Packit Service c5cf8c
    my $nargs = 0;
Packit Service c5cf8c
    $cwd = `pwd`;
Packit Service c5cf8c
    chomp $cwd;
Packit Service c5cf8c
    my @config;
Packit Service c5cf8c
Packit Service c5cf8c
    if ($mpicxx_test_dir eq "") {
Packit Service c5cf8c
	$mpicxx_test_dir = "$tmpdir/cb/mpicxxtest";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    #
Packit Service c5cf8c
    # First, check for the mpicxx program
Packit Service c5cf8c
    if (! -x "$instdir/bin/mpicxx" || !defined($chosenEnable{"cxx"})) { 
Packit Service c5cf8c
	# Probably built without C++ support
Packit Service c5cf8c
	$run_status = 0;  
Packit Service c5cf8c
	&SkipCxxTestSuite;
Packit Service c5cf8c
	return;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    $rc = chdir $mpicxx_test_dir;
Packit Service c5cf8c
    if (!$rc) {
Packit Service c5cf8c
	#print STDERR "Cannot change to $mpicxx_test_dir\n";
Packit Service c5cf8c
	return;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    # Remove any "notest" file
Packit Service c5cf8c
    if (-s "notest") { unlink "notest"; }
Packit Service c5cf8c
    $config[$nargs++] = "$projects_dir/mpicxxtest/configure";
Packit Service c5cf8c
    $config[$nargs++] = "--with-mpich=$instdir";
Packit Service c5cf8c
    $config[$nargs++] = "--enable-xml";
Packit Service c5cf8c
    if (defined($ENV{"MAKE"})) {
Packit Service c5cf8c
	$makepgm = $ENV{"MAKE"};
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$makepgm = "make";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    %saveENV = %ENV;
Packit Service c5cf8c
    # This timeout needs to be made uniform for all mpiruns
Packit Service c5cf8c
    # 3 minutes is enough for some of our slower machines
Packit Service c5cf8c
    $ENV{MPIEXEC_TIMEOUT} = "180";
Packit Service c5cf8c
    $rc = &RunProgram( @config );
Packit Service c5cf8c
    if ($rc == 0) {
Packit Service c5cf8c
	if ($hasDemon) {
Packit Service c5cf8c
	    &$StartDemon;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	$rc = &RunProgram( "$makepgm run-tests" );
Packit Service c5cf8c
	$test_status = $rc;
Packit Service c5cf8c
	if ($run_status == 0 && $rc != 0) { $run_status = $rc; }
Packit Service c5cf8c
	# This step converts the summary.xml file into a valid XML file
Packit Service c5cf8c
	# by adding the appropriate header and footer
Packit Service c5cf8c
	$rc = &RunProgram( "$makepgm get-summary" );
Packit Service c5cf8c
	if ($hasDemon) {
Packit Service c5cf8c
	    &$StopDemon;
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$run_status = $rc;
Packit Service c5cf8c
	print $OUTFD "Configure step for test failed\n";
Packit Service c5cf8c
	print $OUTFD "Could not execute " . join(" ", @config) . "\n";
Packit Service c5cf8c
	print $OUTFD "Environment was\n";
Packit Service c5cf8c
	foreach $key (keys(%ENV)) {
Packit Service c5cf8c
	    my $line = "$key = $ENV{$key}";
Packit Service c5cf8c
	    if ($is_xml) { $line = &XMLify( $line ); }
Packit Service c5cf8c
	    print $OUTFD "$line\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    %ENV = %saveENV;
Packit Service c5cf8c
    chdir $cwd;
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
# Run the LLNL IO Test suite
Packit Service c5cf8c
sub RunTestMPIOSuite {
Packit Service c5cf8c
    my $nargs = 0;
Packit Service c5cf8c
    my $testname = "testing";
Packit Service c5cf8c
    $cwd = `pwd`;
Packit Service c5cf8c
    chomp $cwd;
Packit Service c5cf8c
Packit Service c5cf8c
    my @config;
Packit Service c5cf8c
Packit Service c5cf8c
    if ($testmpio_test_dir eq "") {
Packit Service c5cf8c
	$testmpio_test_dir = "$tmpdir/cb/testmpio";
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    $rc = chdir $testmpio_test_dir;
Packit Service c5cf8c
    if (!$rc) {
Packit Service c5cf8c
	print $OUTFD "Cannot change to $testmpio_test_dir\n";
Packit Service c5cf8c
	return;
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    # Switch to using the checked-in version of the Testmpio test
Packit Service c5cf8c
    if (-x "$projects_dir/testmpio/configure") {
Packit Service c5cf8c
        $config[$nargs++] = "$projects_dir/testmpio/configure";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    elsif (-x "$projects_dir/Testmpio/configure") {
Packit Service c5cf8c
        $config[$nargs++] = "$projects_dir/Testmpio/configure";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
        print $OUTFD "Cannot find testmpio source directory!";
Packit Service c5cf8c
        return;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    $config[$nargs++] = "--enable-xml";
Packit Service c5cf8c
    $config[$nargs++] = "CC=$instdir/bin/mpicc";
Packit Service c5cf8c
    $config[$nargs++] = "MPIEXEC=$instdir/bin/mpiexec";
Packit Service c5cf8c
    if (defined($ENV{"MAKE"})) {
Packit Service c5cf8c
	$makepgm = $ENV{"MAKE"};
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$makepgm = "make";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    %saveENV = %ENV;
Packit Service c5cf8c
    # This timeout needs to be made uniform for all mpiruns
Packit Service c5cf8c
    # 3 minutes is enough for some of our slower machines
Packit Service c5cf8c
    $ENV{MPIEXEC_TIMEOUT} = "180";
Packit Service c5cf8c
    $rc = &RunProgram( @config );
Packit Service c5cf8c
    if ($rc == 0) {
Packit Service c5cf8c
	if ($hasDemon) {
Packit Service c5cf8c
	    &$StartDemon;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	$rc = &RunProgram( "$makepgm $testname" );
Packit Service c5cf8c
	$test_status = $rc;
Packit Service c5cf8c
	if ($run_status == 0 && $rc != 0) { $run_status = $rc; }
Packit Service c5cf8c
	if ($hasDemon) {
Packit Service c5cf8c
	    &$StopDemon;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	if ($test_status != 0) {
Packit Service c5cf8c
	    # Try to figure out what went wrong.  
Packit Service c5cf8c
	    if (-s "Test/test.results") { 
Packit Service c5cf8c
		&CopyFileToOutput( "Test/test.results" );
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$run_status = $rc;
Packit Service c5cf8c
	print $OUTFD "Configure step for test failed\n";
Packit Service c5cf8c
	print $OUTFD "Could not execute " . join(" ", @config) . "\n";
Packit Service c5cf8c
	print $OUTFD "Environment was\n";
Packit Service c5cf8c
	foreach $key (keys(%ENV)) {
Packit Service c5cf8c
	    my $line = "$key = $ENV{$key}";
Packit Service c5cf8c
	    if ($is_xml) { $line = &XMLify( $line ); }
Packit Service c5cf8c
	    print $OUTFD "$line\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    %ENV = %saveENV;
Packit Service c5cf8c
    chdir $cwd;
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
Packit Service c5cf8c
sub RunIntelTestSuite {
Packit Service c5cf8c
    my $nargs = 0;
Packit Service c5cf8c
    my $testname = "newtestl";
Packit Service c5cf8c
    $cwd = `pwd`;
Packit Service c5cf8c
    chomp $cwd;
Packit Service c5cf8c
Packit Service c5cf8c
    my @config;
Packit Service c5cf8c
Packit Service c5cf8c
    if ($intel_test_dir eq "") {
Packit Service c5cf8c
	$intel_test_dir = "$tmpdir/cb/MPITEST";
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    $rc = chdir $intel_test_dir;
Packit Service c5cf8c
    if (!$rc) {
Packit Service c5cf8c
	#print STDERR "Cannot change to $intel_test_dir\n";
Packit Service c5cf8c
	return;
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    # Switch to using the checked-in version of the Intel test
Packit Service c5cf8c
    $config[$nargs++] = "$projects_dir/IntelMPITEST/configure";
Packit Service c5cf8c
    $config[$nargs++] = "--with-mpich2=$instdir";
Packit Service c5cf8c
    # The Absoft Fortran compiler fails some tests if MAX_RANKS
Packit Service c5cf8c
    # (used to dimension some arrays) is too large.  Since the 
Packit Service c5cf8c
    # default tests never use more than 6 processes, setting a 
Packit Service c5cf8c
    # maximum of 16 is safe.
Packit Service c5cf8c
    $config[$nargs++] = "--enable-maxprocs=16";
Packit Service c5cf8c
    # f77 is now the default, so we should run with the f77 tests
Packit Service c5cf8c
    # unless we did not build f77
Packit Service c5cf8c
    if (!$has_f77) {       # defined($chosenEnable{"f77"})
Packit Service c5cf8c
	# Only run the C tests if we did not build fortran
Packit Service c5cf8c
	$config[$nargs++] = "--disable-f77";
Packit Service c5cf8c
	$testname = "newtestl_c";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    if (defined($ENV{"MAKE"})) {
Packit Service c5cf8c
	$makepgm = $ENV{"MAKE"};
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$makepgm = "make";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    %saveENV = %ENV;
Packit Service c5cf8c
    # This timeout needs to be made uniform for all mpiruns
Packit Service c5cf8c
    # 3 minutes is enough for some of our slower machines
Packit Service c5cf8c
    $ENV{MPIEXEC_TIMEOUT} = "180";
Packit Service c5cf8c
    $rc = &RunProgram( @config );
Packit Service c5cf8c
    if ($rc == 0) {
Packit Service c5cf8c
	if ($hasDemon) {
Packit Service c5cf8c
	    &$StartDemon;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	$rc = &RunProgram( "$makepgm $testname" );
Packit Service c5cf8c
	$test_status = $rc;
Packit Service c5cf8c
	if ($run_status == 0 && $rc != 0) { $run_status = $rc; }
Packit Service c5cf8c
	if ($hasDemon) {
Packit Service c5cf8c
	    &$StopDemon;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	if ($test_status != 0) {
Packit Service c5cf8c
	    # Try to figure out what went wrong.  
Packit Service c5cf8c
	    if (-s "Test/test.results") { 
Packit Service c5cf8c
		&CopyFileToOutput( "Test/test.results" );
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    if (! -s "lib/libmpitestf_mpich2.a" && 
Packit Service c5cf8c
		-s "lib/makeflib.log") {
Packit Service c5cf8c
		&CopyFileToOutput( "lib/makeflib.log" );
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    if (! -s "lib/libmpitest_mpich2.a" && 
Packit Service c5cf8c
		-s "lib/makeclib.log") {
Packit Service c5cf8c
		&CopyFileToOutput( "lib/makeclib.log" );
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$run_status = $rc;
Packit Service c5cf8c
	print $OUTFD "Configure step for test failed\n";
Packit Service c5cf8c
	print $OUTFD "Could not execute " . join(" ", @config) . "\n";
Packit Service c5cf8c
	print $OUTFD "Environment was\n";
Packit Service c5cf8c
	foreach $key (keys(%ENV)) {
Packit Service c5cf8c
	    my $line = "$key = $ENV{$key}";
Packit Service c5cf8c
	    if ($is_xml) { $line = &XMLify( $line ); }
Packit Service c5cf8c
	    print $OUTFD "$line\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    %ENV = %saveENV;
Packit Service c5cf8c
    chdir $cwd;
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
sub RunMPICH2TestSuite {
Packit Service c5cf8c
    my $nargs = 0;
Packit Service c5cf8c
    my $makepgm;
Packit Service c5cf8c
Packit Service c5cf8c
    $cwd = `pwd`;
Packit Service c5cf8c
    chomp $cwd;
Packit Service c5cf8c
Packit Service c5cf8c
    # This must match the directory into which mpich2 was built for
Packit Service c5cf8c
    # us to use the configure there.
Packit Service c5cf8c
    if ($mpich2_test_dir eq "") {
Packit Service c5cf8c
	$mpich2_test_dir = "$builddir/test/mpi";
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    $rc = chdir $mpich2_test_dir;
Packit Service c5cf8c
    if (!$rc) {
Packit Service c5cf8c
	#print STDERR "Cannot change to $mpich2_test_dir\n";
Packit Service c5cf8c
	return;
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    # MPICH2 tests are already built, so no configure step required
Packit Service c5cf8c
    %saveENV = %ENV;
Packit Service c5cf8c
    #
Packit Service c5cf8c
    # Make sure that there a no leftovers
Packit Service c5cf8c
    # Get the version of make to use
Packit Service c5cf8c
    if (defined($ENV{"MAKE"})) {
Packit Service c5cf8c
	$makepgm = $ENV{"MAKE"};
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	$makepgm = "make";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    &RunProgram( "$makepgm clean" );
Packit Service c5cf8c
Packit Service c5cf8c
    # This timeout needs to be made uniform for all mpiruns
Packit Service c5cf8c
    # 3 minutes is enough for some of our slower machines
Packit Service c5cf8c
    $ENV{MPIEXEC_TIMEOUT} = "180";
Packit Service c5cf8c
    if ($hasDemon) {
Packit Service c5cf8c
	&$StartDemon;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    # The MPICH2 test suite has a program for running the tests
Packit Service c5cf8c
    $rc = &RunProgram( "./runtests -mpiexec=$instdir/bin/mpiexec -srcdir=$srcdir/test/mpi -tests=testlist -xmlfile=summary.xml" );
Packit Service c5cf8c
    $test_status = $rc;
Packit Service c5cf8c
    if ($run_status == 0 && $rc != 0) { $run_status = $rc; }
Packit Service c5cf8c
    if ($hasDemon) {
Packit Service c5cf8c
	&$StopDemon;
Packit Service c5cf8c
    }
Packit Service c5cf8c
    %ENV = %saveENV;
Packit Service c5cf8c
    chdir $cwd;
Packit Service c5cf8c
}
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
# RunProgram LIST
Packit Service c5cf8c
sub RunProgram {
Packit Service c5cf8c
    my $signal_num = 0;
Packit Service c5cf8c
Packit Service c5cf8c
    if ($echoSteps) {
Packit Service c5cf8c
	my $cmd = join(' ',@_);
Packit Service c5cf8c
	my $curdir = `pwd`;
Packit Service c5cf8c
	chomp $curdir;
Packit Service c5cf8c
	print STDOUT "Running $cmd in $curdir\n";
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    # perl does not correctly handle ">>foo 2>&1" redirection in system
Packit Service c5cf8c
    # correctly (some stderr escapes to the prior stderr).  This
Packit Service c5cf8c
    # code attempts to do the correct thing.
Packit Service c5cf8c
    # By reopening stdout and stderr, we can ensure that all of the 
Packit Service c5cf8c
    # output goes to the specified files.  Unfortunately, we can't
Packit Service c5cf8c
    # force perl to correctly flush files without open/close, so
Packit Service c5cf8c
    # we close the output file before the fork.  This guarantees that
Packit Service c5cf8c
    # the data is flushed.  We reopen it after the fork (which is implicit
Packit Service c5cf8c
    # in the open)
Packit Service c5cf8c
    if ($outfile ne "") {
Packit Service c5cf8c
	close $OUTFD;
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    # We now use a different approach that uses a open that creates a 
Packit Service c5cf8c
    # fork and associates file handle (CFD for Child FD).
Packit Service c5cf8c
    @args = @_;
Packit Service c5cf8c
    $pid = open(CFD,"-|");
Packit Service c5cf8c
    if ($pid == 0) {
Packit Service c5cf8c
	# we're the child
Packit Service c5cf8c
        open STDIN, '/dev/null';
Packit Service c5cf8c
	# Do we want to allow an output filter, e.g., to convert the 
Packit Service c5cf8c
	# output into well-formed XML?
Packit Service c5cf8c
        open STDERR, ">>&STDOUT";
Packit Service c5cf8c
        exec @args;
Packit Service c5cf8c
	die "Could not exec program $args[0]\n";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	# Read from the child
Packit Service c5cf8c
	if ($outfile ne "") {
Packit Service c5cf8c
	    open( $OUTFD, ">>$outfile" ) || die "Could not reopen $outfile for appending\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
	while (<CFD>) {
Packit Service c5cf8c
	    if ($is_xml) {
Packit Service c5cf8c
		$_ = &XMLify( $_ );
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    print $OUTFD $_;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	# Closing a pipe implicitly waits for the command on the other
Packit Service c5cf8c
	# end to complete, and puts the exit status into $?
Packit Service c5cf8c
	close CFD;
Packit Service c5cf8c
	# end of read from the child
Packit Service c5cf8c
	# Note that this status is usually shifted right by 8, so
Packit Service c5cf8c
	# we check for that
Packit Service c5cf8c
        $rc = $?;
Packit Service c5cf8c
	$signal_num = $rc & 127;
Packit Service c5cf8c
	if ($rc > 255) { $rc = $rc >> 8; }
Packit Service c5cf8c
	if ($signal_num != 0 && $report_signals) {
Packit Service c5cf8c
	    print OUTFD "Process exited with signal $signal_num\n";
Packit Service c5cf8c
	}
Packit Service c5cf8c
    }
Packit Service c5cf8c
    if ($echoSteps) {
Packit Service c5cf8c
	print STDOUT "Completed command with status $rc\n";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    return $rc;
Packit Service c5cf8c
}
Packit Service c5cf8c
#
Packit Service c5cf8c
# Change output style
Packit Service c5cf8c
sub XMLStyle {
Packit Service c5cf8c
    $TestStart     = "<BUILDTEST>\n";
Packit Service c5cf8c
    $TestEnd       = "</BUILDTEST>\n";
Packit Service c5cf8c
    $TestDateStart = "<DATE>\n";
Packit Service c5cf8c
    $TestDateEnd   = "</DATE>\n";
Packit Service c5cf8c
    $TestHostStart = "<HOST>\n";
Packit Service c5cf8c
    $TestHostEnd   = "</HOST>\n";
Packit Service c5cf8c
    $TestUserStart = "<USER>\n";
Packit Service c5cf8c
    $TestUserEnd   = "</USER>\n";
Packit Service c5cf8c
    $ConfigStart   = "<CONFIG>\n";
Packit Service c5cf8c
    $ConfigEnd     = "</CONFIG>\n";
Packit Service c5cf8c
    $MakeStart     = "<MAKE>\n";
Packit Service c5cf8c
    $MakeEnd       = "</MAKE>\n";
Packit Service c5cf8c
    $GlobNameStart = "<GLOBNAME>\n";
Packit Service c5cf8c
    $GlobNameEnd   = "</GLOBNAME>\n";
Packit Service c5cf8c
    $UsedNameStart = "<USEDNAMES>\n";
Packit Service c5cf8c
    $UsedNameEnd   = "</USEDNAMES>\n";
Packit Service c5cf8c
    $MakeInstStart = "<MAKEINST>\n";
Packit Service c5cf8c
    $MakeInstEnd   = "</MAKEINST>\n";
Packit Service c5cf8c
    $MakeInstcheckStart = "<MAKEINSTCHECK>\n";
Packit Service c5cf8c
    $MakeInstcheckEnd   = "</MAKEINSTCHECK>\n";
Packit Service c5cf8c
    $RunTestStart  = "<RUNTEST>\n";
Packit Service c5cf8c
    $RunTestEnd    = "</RUNTEST>\n";
Packit Service c5cf8c
    $SumStart      = "<SUMMARY>\n";
Packit Service c5cf8c
    $SumEnd        = "</SUMMARY>\n";
Packit Service c5cf8c
    $SumConfigStart = "<STATUS NAME=\"configure\">";
Packit Service c5cf8c
    $SumConfigEnd   = "</STATUS>\n";
Packit Service c5cf8c
    $SumMakeStart  = "<STATUS NAME=\"make\">";
Packit Service c5cf8c
    $SumMakeEnd    = "</STATUS>\n";
Packit Service c5cf8c
    $SumGlobStart  = "<STATUS NAME=\"globname\">";
Packit Service c5cf8c
    $SumGlobEnd    = "</STATUS>\n";
Packit Service c5cf8c
    $SumInstStart  = "<STATUS NAME=\"install\">";
Packit Service c5cf8c
    $SumInstEnd    = "</STATUS>\n";
Packit Service c5cf8c
    $SumTestRunStart = "<STATUS NAME=\"test\">";
Packit Service c5cf8c
    $SumTestRunEnd   = "</STATUS>\n";
Packit Service c5cf8c
}
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
#
Packit Service c5cf8c
# Other options
Packit Service c5cf8c
# --enable-threads={single, multiple}
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
# Here's the real code to execute
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
Packit Service c5cf8c
if ($rundir ne "") { 
Packit Service c5cf8c
    chdir $rundir || die "could not change directory to $rundir\n";
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
# Select the output file
Packit Service c5cf8c
if ($outfile ne "") {
Packit Service c5cf8c
    if (! ($outfile =~ /^\//) ) {
Packit Service c5cf8c
	# Ensure that we have an absolute directory for the output file
Packit Service c5cf8c
	my $curdir = `pwd`;
Packit Service c5cf8c
	chop $curdir;
Packit Service c5cf8c
	$outfile = "$curdir/$outfile";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    open( $OUTFD, ">$outfile" ) || die "Could not open $outfile for writing\n";
Packit Service c5cf8c
    # Setting autoflush is not enough to ensure that output is 
Packit Service c5cf8c
    # correctly ordered when child processes also write to the file.
Packit Service c5cf8c
    # All of the shells get this right but unfortunately perl does not.
Packit Service c5cf8c
    #autoflush $OUTFD 1;
Packit Service c5cf8c
    if ($is_xml) {
Packit Service c5cf8c
	print $OUTFD "\n";
Packit Service c5cf8c
	print $OUTFD "\n";
Packit Service c5cf8c
	print $OUTFD "<MPICH2BUILD>\n";
Packit Service c5cf8c
    }
Packit Service c5cf8c
}
Packit Service c5cf8c
else {
Packit Service c5cf8c
    $OUTFD = STDOUT;
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
# ---------------------------------------------------------------------------
Packit Service c5cf8c
#
Packit Service c5cf8c
# There are several ways to run the tests.  They are
Packit Service c5cf8c
#   For a fixed number of times
Packit Service c5cf8c
#   For a fixed length of time
Packit Service c5cf8c
for ($test_count = 0; 
Packit Service c5cf8c
     ($max_count < 0 || $test_count < $max_count) && &time_left;
Packit Service c5cf8c
     $test_count++) {
Packit Service c5cf8c
    if ($is_xml) {
Packit Service c5cf8c
    }
Packit Service c5cf8c
    else {
Packit Service c5cf8c
	print $OUTFD "\nRunning test $test_count\n\n";
Packit Service c5cf8c
    }
Packit Service c5cf8c
    &RunTest;
Packit Service c5cf8c
}
Packit Service c5cf8c
if ($is_xml) {
Packit Service c5cf8c
    print $OUTFD "</MPICH2BUILD>\n";
Packit Service c5cf8c
}
Packit Service c5cf8c
close $OUTFD;
Packit Service c5cf8c
Packit Service c5cf8c
sub CopyFileToOutput {
Packit Service c5cf8c
    my $filename = $_[0];
Packit Service c5cf8c
    my $linecount = 256;
Packit Service c5cf8c
Packit Service c5cf8c
    if (open( TESTFD, "<$filename" )) {
Packit Service c5cf8c
	print $OUTFD "First $linecount lines of $filename\n";
Packit Service c5cf8c
	while (<TESTFD>) {
Packit Service c5cf8c
	    if ($linecount <= 0) { last; }
Packit Service c5cf8c
	    if ($is_xml) {
Packit Service c5cf8c
		$_ = &XMLify( $_ );
Packit Service c5cf8c
	    }
Packit Service c5cf8c
	    print $OUTFD $_;
Packit Service c5cf8c
	    $linecount --;
Packit Service c5cf8c
	}
Packit Service c5cf8c
	close (TESTFD);
Packit Service c5cf8c
    }
Packit Service c5cf8c
}
Packit Service c5cf8c
Packit Service c5cf8c
sub XMLify {
Packit Service c5cf8c
    my $line = $_[0];
Packit Service c5cf8c
    my $itcount = 0;
Packit Service c5cf8c
    # xml-ify the line by escaping the special characters
Packit Service c5cf8c
    $line =~ s/</\*AMP\*lt;/g;
Packit Service c5cf8c
    $line =~ s/>/\*AMP\*gt;/g;
Packit Service c5cf8c
    $line =~ s/&/\*AMP\*amp;/g;
Packit Service c5cf8c
    $line =~ s/\*AMP\*/&/;;
Packit Service c5cf8c
Packit Service c5cf8c
    # Handle non-printing ascii characters (e.g., ones that emacs would
Packit Service c5cf8c
    # print as \200).  XML may refuse to display non-printing characters
Packit Service c5cf8c
    # BUG IN PERL: The negated POSIX character class does not work!
Packit Service c5cf8c
    # It isn't clear whether ANY of the POSIX character classes work
Packit Service c5cf8c
    # while ($line =~ /^([:print:]*)([:^print:])(.*)/s) {
Packit Service c5cf8c
    # Instead, we use an explicit ASCII range, and include tab characters
Packit Service c5cf8c
    while ($line =~ /^([ -~\t]*)([^ -~\t\n])(.*)/s) {
Packit Service c5cf8c
        # Grr.  This doesn't work either.  The character conversion
Packit Service c5cf8c
	# gets lost.  However, this is still better than including
Packit Service c5cf8c
	# a nonprinting character in the output
Packit Service c5cf8c
        $char = $2;
Packit Service c5cf8c
	$hexversion = sprintf( "\\%03x", $char );
Packit Service c5cf8c
	$line = $1 . $hexversion . $3;
Packit Service c5cf8c
	if ($itcount++ > 100) { last; }
Packit Service c5cf8c
    }
Packit Service c5cf8c
Packit Service c5cf8c
    return $line;
Packit Service c5cf8c
}