IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 1, 2005, 10:11:19 AM (21 years ago)
Author:
desonia
Message:

updated the testing platform to match psLib, enabling the use of 'make check'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/test/runTest

    r2140 r3623  
    1818#                 0    Test run successfull and all tests passed
    1919#                 1    Verified directory did not exist
    20 #                 2    Verified STDOUT file did not exist
    21 #                 4    Verified STDERR file did not exist
    2220#                 8    STDOUT files did not compare
    2321#                16    STDERR files did not compare
    2422#                32    Test driver doesn't exist or is not executable
    25 #                64    STDOUT captured contains error strings
    26 #               128    STDERR captured contains error strings
    27 #               256    Test driver did not return zero
     23#                64    Test driver did not return zero
    2824#
    2925#  SYNOSIS:  runTest testDriverName
    3026#
    3127#  $Revison:  $  $Name: not supported by cvs2svn $
    32 #  $Date: 2004-10-14 23:58:56 $
     28#  $Date: 2005-04-01 20:11:19 $
    3329#
    3430#  Copyright 2004 Maui High Performance Computering Center, University of Hawaii
     
    3632################################################################################
    3733
    38 # Provides functions for handling long command line options
     34# Provides functions for handling psS64 command line options
    3935use Getopt::Long;
     36
     37$verifiedDir = "verified";
    4038
    4139# Assign variables based on the presence of command line options to the script
     
    4442    "resetStderr!" => \$resetStderr,
    4543    "resetStdout!" => \$resetStdout,
     44    "verified=s"   => \$verifiedDir,
    4645    "help!"        => \$help
    4746);
    4847
    49 if ($help) {
     48if ($help || $#ARGV < 0) {
    5049    print
    5150"Usage: runTest [--reset] [--resetStderr] [--resetStdout] testfile(s)\n\n";
     
    6261
    6362# Set up the PSLIB_ROOT environment variable if the user doesn't have it set
    64 if ( !$ENV{'PSLIB_ROOT'} ) {
    65 
    66     # Use the directory directly above test
    67     $PSLIB_ROOT = `cd ..;pwd`;
    68 
    69     # Remove newline for the end of path returned
    70     chomp($PSLIB_ROOT);
    71 
    72     # Set the environment variable
    73     $ENV{'PSLIB_ROOT'} = $PSLIB_ROOT;
    74 
    75     # Display message that PSLIB_ROOT not found and set to
    76     print("PSLIB_ROOT not found: set to $PSLIB_ROOT\n");
    77 }
    78 
    79 # Add PSLIB_ROOT/lib to LD_LIBRARY_PATH and DYLD_LIBRARY_PATH environment vars
    80 $ENV{'LD_LIBRARY_PATH'}   = "$ENV{'PSLIB_ROOT'}/lib:$ENV{'LD_LIBRARY_PATH'}";
    81 $ENV{'DYLD_LIBRARY_PATH'} = "$ENV{'PSLIB_ROOT'}/lib:$ENV{'DYLD_LIBRARY_PATH'}";
     63if ( $ENV{'PSLIB_ROOT'} ) {
     64
     65        # Add PSLIB_ROOT/lib to LD_LIBRARY_PATH and DYLD_LIBRARY_PATH environment vars
     66        $ENV{'LD_LIBRARY_PATH'}   = "$ENV{'PSLIB_ROOT'}/src/.libs:$ENV{'LD_LIBRARY_PATH'}";
     67        $ENV{'DYLD_LIBRARY_PATH'} = "$ENV{'PSLIB_ROOT'}/src/.libs:$ENV{'DYLD_LIBRARY_PATH'}";
     68}
    8269
    8370# Loop through the arguements passed to the script
     
    9784
    9885    # Check if a verified directory exists in the current work directory
    99     if ( !( -e "verified" ) ) {
     86    if ( !( -e $verifiedDir ) ) {
    10087
    10188        # Display message that verified subdirectory doesn't exist
     
    125112            # Display failure message with return value to user
    126113            if ( $? != 0 && ( $testFile !~ /^A/i ) ) {
    127                 print(
    128 "        Failed - Test Driver expected 0 return value (Return value $?)\n"
    129                 );
     114                print("Failed - Test Driver returned $?, expected 0.\n");
    130115            }
    131116            elsif ( $? == 0 && ( $testFile =~ /^A/i ) ) {
    132                 print(
    133 "        Failed - Test Driver expected abort (Return value $?)\n"
    134                 );
    135             }
    136             $exitValue |= 256;
    137         }
    138         else {
    139 
    140             # Test driver succeeded.
    141 
    142             # Create filtered version of stdout and stderr
    143 
    144             # Open the STDOUT file for reading
    145             open( OUTFILE, "< temp/$testFile.stdout" );
    146 
    147             # Open mod file to place filtered STDOUT
    148             open( MODFILE,  "> temp/$testFile.stdout.mod" );
    149             open( MODFILE2, "> verified/$testFile.stdout" ) if $resetStdout;
    150 
    151            # Replace the variable date, time and host information with constants
    152             $hostname = `hostname`;
    153             chop $hostname;
    154             while (<OUTFILE>) {
    155                 s/\s+\d+:\d+:\d+\w/<TIME>/g;
    156                 s/\d+:\d+:\d+/<DATE>/g;
    157                 s/$hostname\s*/<HOST>/g;
    158                 s/: Line \d+/: Line <LINENO>/g;
    159                 s/\:\d+/\:<LINENO>/g;
    160                 s/allocate \d+ bytes at/allocate <N> bytes at/g;
    161 
    162               # Filter lines with malloc.  This is an artifact of memory testing
    163               # with the Mac testbed
    164                 if ( !m/\*\*\*\smalloc/ ) {
    165                     print MODFILE ($_);
    166                     print MODFILE2 ($_) if $resetStdout;
    167                 }
    168             }
    169 
    170             # Close mod file
    171             close(MODFILE);
    172             close(MODFILE2) if $resetStdout;
    173 
    174             # Close STDERR file
    175             close(OUTFILE);
    176 
    177             # Open the STDERR file for reading
    178             open( OUTFILE, "< temp/$testFile.stderr" );
    179 
    180             # Open mod file to place filtered STDERR
    181             open( MODFILE,  "> temp/$testFile.stderr.mod" );
    182             open( MODFILE2, "> verified/$testFile.stderr" ) if $resetStderr;
    183 
    184            # Replace the variable date, time and host information with constants
    185             while (<OUTFILE>) {
    186                 s/\s+\d+:\d+:\d+\w/<TIME>/g;
    187                 s/\d+:\d+:\d+/<DATE>/g;
    188                 s/$hostname\s*/<HOST>/g;
    189                 s/: Line \d+/: Line <LINENO>/g;
    190                 s/\:\d+/\:<LINENO>/g;
    191                 s/allocate \d+ bytes at/allocate <N> bytes at/g;
    192 
    193               # Filter lines with malloc.  This is an artifact of memory testing
    194               # with the Mac testbed
    195                 if ( !m/\*\*\*\smalloc/ ) {
    196                     print MODFILE ($_);
    197                     print MODFILE2 ($_) if $resetStderr;
    198                 }
    199             }
    200 
    201             # Close mod file
    202             close(MODFILE);
    203             close(MODFILE2) if $resetStderr;
    204 
    205             # Close STDERR file
    206             close(OUTFILE);
    207 
    208             # Compare STDOUT capture with verified file
    209             $exitValue |= &compareStream("verified/$testFile.stdout");
    210 
    211             # Check exit value to determine if verified file doesn't exist
    212             if ( $exitValue & 2 ) {
    213 
    214                 # STDOUT verified doesn't exist.  Search STDOUT capture
    215                 # for strings indicating error or failure
    216                 $exitValue |= &errorStrSearch("$testFile.stdout");
    217             }
    218 
    219             # Compare STDERR capture with verified file
    220             $exitValue |= &compareStream("verified/$testFile.stderr");
    221 
    222             # Check exit value to determine if verified file doesn't exist
    223             if ( $exitValue & 4 ) {
    224 
    225                 # STDERR verified doesn't exist.  Search STDERR capture
    226                 # for strings indicating error or failure
    227                 $exitValue |= &errorStrSearch("$testFile.stderr");
    228             }
    229         }
    230     }
     117                print("Failed - Test Driver returned $?, expected abort.\n");
     118            }
     119            $exitValue |= 64;
     120        }
     121
     122        # Test driver succeeded.
     123
     124        # Create filtered version of stdout and stderr
     125
     126        # Open the STDOUT file for reading
     127        open( OUTFILE, "< temp/$testFile.stdout" );
     128
     129        # Open mod file to place filtered STDOUT
     130        open( MODFILE,  "> temp/$testFile.stdout.mod" );
     131        open( MODFILE2, "> $verifiedDir/$testFile.stdout" ) if $resetStdout;
     132
     133        # Replace the variable date, time and host information with constants
     134        $hostname = `hostname`;
     135        chop $hostname;
     136        while (<OUTFILE>) {
     137            s/\s+\d+:\d+:\d+\w/<TIME>/g;
     138            s/\d+:\d+:\d+/<DATE>/g;
     139            s/$hostname\s*/<HOST>/g;
     140            s/: Line \d+/: Line <LINENO>/g;
     141            s/\(.*\:\d+\)/\(FILE\:LINENO\)/g;
     142            s/\s+[\_\-\/\.\w]+\:\d+/ FILE\:LINENO/g;
     143            s/allocate \d+ bytes at/allocate <N> bytes at/g;
     144            s/v\d+.\d+.\d+/vX.X.X/g;
     145
     146            # Filter lines with malloc.  This is an artifact of memory testing
     147            # with the Mac testbed
     148            if ( !m/\*\*\*\smalloc/ ) {
     149                print MODFILE ($_);
     150                print MODFILE2 ($_) if $resetStdout;
     151            }
     152        }
     153
     154        # Close mod file
     155        close(MODFILE);
     156        close(MODFILE2) if $resetStdout;
     157
     158        # Close STDERR file
     159        close(OUTFILE);
     160
     161        # Open the STDERR file for reading
     162        open( OUTFILE, "< temp/$testFile.stderr" );
     163
     164        # Open mod file to place filtered STDERR
     165        open( MODFILE,  "> temp/$testFile.stderr.mod" );
     166        open( MODFILE2, "> $verifiedDir/$testFile.stderr" ) if $resetStderr;
     167
     168        # Replace the variable date, time and host information with constants
     169        while (<OUTFILE>) {
     170            s/\s+\d+:\d+:\d+\w/<TIME>/g;
     171            s/\d+:\d+:\d+/<DATE>/g;
     172            s/$hostname\s*/<HOST>/g;
     173            s/: Line \d+/: Line <LINENO>/g;
     174            s/\(.*\:\d+\)/\(FILE\:LINENO\)/g;
     175            s/\s+[\_\-\/\.\w]+\:\d+/ FILE\:LINENO/g;
     176            s/allocate \d+ bytes at/allocate <N> bytes at/g;
     177            s/v\d+.\d+.\d+/vX.X.X/g;
     178
     179            # Filter lines with malloc.  This is an artifact of memory testing
     180            # with the Mac testbed
     181            if ( !m/\*\*\*\smalloc/ ) {
     182                print MODFILE ($_);
     183                print MODFILE2 ($_) if $resetStderr;
     184            }
     185        }
     186
     187        # Close mod file
     188        close(MODFILE);
     189        close(MODFILE2) if $resetStderr;
     190
     191        # Close STDERR file
     192        close(OUTFILE);
     193
     194        # Compare STDOUT capture with verified file
     195        $exitValue |= &compareStream("$verifiedDir/$testFile.stdout");
     196
     197        # Check exit value to determine if verified file doesn't exist
     198        if ( $exitValue & 2 ) {
     199
     200            # STDOUT verified doesn't exist.  Search STDOUT capture
     201            # for strings indicating error or failure
     202            $exitValue |= &errorStrSearch("$testFile.stdout");
     203        }
     204
     205        # Compare STDERR capture with verified file
     206        $exitValue |= &compareStream("$verifiedDir/$testFile.stderr");
     207
     208        # Check exit value to determine if verified file doesn't exist
     209        if ( $exitValue & 4 ) {
     210
     211            # STDERR verified doesn't exist.  Search STDERR capture
     212            # for strings indicating error or failure
     213            $exitValue |= &errorStrSearch("$testFile.stderr");
     214        }
     215   }
    231216    else {
    232217
     
    320305#
    321306#      Return:   0  -  Compare successful
    322 #                2  -  STDOUT verified file doesn't exist
    323 #                4  -  STDERR verified file doesn't exist
    324307#                8  -  STDOUT verified file doesn't compare
    325308#               16  -  STDERR verified file doesn't compare
     
    333316
    334317    # Check for existence of verified STD stream files
    335     if ( !( -e $streamFile ) ) {
    336 
    337         # Display message to user that verified STDOUT file doesn't exist
    338         print("        File $streamFile doesn't exist.\n");
    339 
    340         # Set exit value bit 1 to indicate proper failure
    341         if ( $streamFile =~ /out$/ ) {
    342             $returnVal |= 2;
    343         }
    344         elsif ( $streamFile =~ /err$/ ) {
    345             $returnVal |= 4;
    346         }
    347     }
    348     else {
     318    if ( -e $streamFile ) {
    349319
    350320        # Verified STD stream file exists
     
    352322        # Create name of the temp file to compare
    353323        $tempFile = $streamFile;
    354         $tempFile =~ s/verified/temp/;
     324        $tempFile =~ s/$verifiedDir/temp/;
    355325        $tempFile = $tempFile . ".mod";
    356326
Note: See TracChangeset for help on using the changeset viewer.