IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 5, 2004, 2:45:10 PM (22 years ago)
Author:
evanalst
Message:

Changed scripts to search STDOUT,STDERR capture files for error string
if there are no corresponding files in the verified directory.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/FullUnitTest

    r521 r585  
    1919#  RETURN : integer number of tests which failed
    2020#
    21 #  $Revision: 1.1 $  $Name: not supported by cvs2svn $
    22 #  $Date: 2004-04-27 01:47:20 $
     21#  $Revision: 1.2 $  $Name: not supported by cvs2svn $
     22#  $Date: 2004-05-06 00:45:10 $
    2323#
    2424#  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    131131#     Parameter(s):  base directory to start testing
    132132#
     133#     Return:  None
     134#
    133135################################################################################
    134136
     
    175177#
    176178#      Parameter(s):  base directory where make and test drivers are located
     179#
     180#      Return:  None
    177181#
    178182################################################################################
     
    243247    local(@files,$j);
    244248    local($pwd);
     249    local($exitValue) = 0;
    245250
    246251    # Set variable to pwd to current test directory
     
    276281                    # Display message to user that verified directories do not
    277282                    # exist eventhough TST files have been found
    278                     print("Unable to execute test drivers in $base_dir\n");
     283#                    print("Unable to execute test drivers in $base_dir\n");
    279284                    print("No verified subdirectory present.\n");
    280285                    # Increment test fail count
    281                     $testFailCount++;
     286 #                   $testFailCount++;
    282287                    # Save the file failed
    283                     push(@testsFailed, $pwd . "/" . $files[$j]);
    284                     return;
     288#                    push(@testsFailed, $pwd . "/" . $files[$j]);
     289#                    return;
    285290                }
    286291            }
     
    305310                # Perform difference on STDOUT file collected
    306311                # with verified files
    307                 $diffstdout = `diff verified/$files[$j].stdout temp/$files[$j].stdout.mod`;
    308                 if ( $? != 0 ) {
    309                     # Display test output didn't compare
    310                     print("STDOUT did not compare for $files[$j].\n$diffstdout\n");
     312                $exitValue = &compareStream("verified/$files[$j].stdout");
     313                if ( $exitValue & 2 ) {
     314                    # STDOUT verified doesn't exist. Search STDOUT capture
     315                    # for strings indicating error or failure
     316                    $exitValue |= &errorStrSearch("$files[$j].stdout");
     317                }
     318                if ( ($exitValue & 8) || ($exitValue & 64) ) {
    311319                    # Increment the total number of test failed
    312320                    $testFailCount++;
     
    315323                } else {
    316324                    # Perform difference on STDERR file collection with verified
    317                     $diffstderr = `diff verified/$files[$j].stderr temp/$files[$j].stderr.mod`;
    318                     if ( $? != 0 ) {
    319                         print("STDERR did not compare for $files[$j].\n$diffstderr\n");
     325                    $exitValue = &compareStream("verified/$files[$j].stderr");
     326                    if ( $exitValue & 4 ) {
     327                        # STDERR verified doesn't exist. Search STDERR capture
     328                        # for strings indicating error or failure
     329                        $exitValue |= &errorStrSearch("$files[$j].stderr");
     330                    }
     331                    if ( ($exitValue & 16) || ($exitValue & 128) ) {
     332                        # Increment the total number of tests failed
    320333                        $testFailCount++;
     334                        # Push test on failed list
    321335                        push(@testsFailed, $pwd . "/" . $files[$j]);
    322336                    } else {
     
    332346################################################################################
    333347#
     348#  SUBROUTINE: errorStrSearch
     349#
     350#      Description:  This subroutine will search the file specified in its
     351#                    parameter for error strings and if they do exists
     352#                    the appropriate value will be returned.
     353#
     354#      Parameter(s): fileName - input file to search for strings
     355#
     356#      Return:   0  -  No error strings found
     357#               64  -  Error strings found in STDOUT
     358#              128  -  Error strings found in STDERR
     359#
     360###############################################################################
     361
     362sub errorStrSearch {
     363    local($fileName) = @_;
     364    local($returnVal) = 0;
     365
     366    # Open the captured file
     367    open(CAPT_FILE, "<temp/$fileName");
     368
     369    # Scan through all the lines of the file searching for error strings
     370    while ( <CAPT_FILE> ) {
     371        if ( m/FAIL/i || m/FAULT/i || m/ERROR/i || m/Not Found/i
     372                      || m/SIGNAL/i || m/NO SUCH FILE/i || m/|E|/i
     373                      || m/|A|/i ) {
     374            if ( $fileName =~ m/out/ ) {
     375                print("        Failed - File $fileName contains error strings.\n");
     376                $returnVal = 64;
     377            } elsif ( $fileName =~ m/err/ ) {
     378                print("        Failed - File $fileName contains error strings.\n");
     379                $returnVal = 128;
     380            }
     381            last;
     382        }
     383    }
     384    # Close the capture file
     385    close(CAPT_FILE);
     386    # Return the return value
     387    return($returnVal);
     388}
     389
     390################################################################################
     391#
     392#  SUBROUTINE: compareStream
     393#
     394#      Description:  This subroutine will compare the captured stream file with
     395#                    a file in the verified directory if one exists.
     396#
     397#      Parameter(s): streamFile - input file to compare
     398#
     399#      Return:   0  -  Compare successful
     400#                2  -  STDOUT verified file doesn't exist
     401#                4  -  STDERR verified file doesn't exist
     402#                8  -  STDOUT verified file doesn't compare
     403#               16  -  STDERR verified file doesn't compare
     404#
     405###############################################################################
     406
     407sub compareStream {
     408    local($streamFile) = @_;
     409    local($returnVal) = 0;
     410    local($tempFile) = "";
     411
     412    # Check for existence of verified STD stream files
     413    if ( !( -e $streamFile) ) {
     414
     415        # Display message to user that verified STDOUT file doesn't exist
     416        print("        File $streamFile doesn't exist.\n");
     417
     418        # Set exit value bit 1 to indicate proper failure
     419        if ( $streamFile =~ /out$/ ) {
     420            $returnVal |= 2;
     421        } elsif ( $streamFile =~ /err$/ ) {
     422            $returnVal |= 4;
     423        }
     424    } else {
     425
     426        # Verified STD stream file exists
     427
     428        # Create name of the temp file to compare
     429        $tempFile = $streamFile;
     430        $tempFile =~ s/verified/temp/;
     431        $tempFile = $tempFile . ".mod";
     432
     433        # Perform difference on the STD stream files
     434        $diffstdout = `diff $streamFile $tempFile`;
     435
     436        # Check the return value of the difference
     437        if ( $? != 0 ) {
     438
     439            # Difference of STD stream files failed
     440
     441            # Check for STDOUT in file name to convey appropirate return value
     442            if ( $streamFile =~ /out$/ ) {
     443               # Display message of the failure of difference to user
     444               print("        Failed - STDOUT difference\n$diffstdout\n");
     445
     446               # Exit value to indicate STDOUT did not compare
     447               $returnVal |= 8;
     448            } elsif ( $streamFile =~ /err$/ ) {
     449               # Display message of the failure of difference to user
     450               print("        Failed - STDERR difference\n$diffstdout\n");
     451
     452               # Exit value to indicate STDERR did not compare
     453               $returnVal |= 16;
     454            }
     455        }
     456    }
     457
     458    # Return the result of the compare
     459    return($returnVal);
     460}
     461
     462
     463################################################################################
     464#
    334465#  SUBROUTINE: checkForTempDirectory
    335466#
     
    406537       s/\d+:\d+:\d+/ <DATE> /;
    407538       s/\s+\d+:\d+:\d+\w/ <TIME> /;
    408        s/\|\S+\|/<HOST>| /;
     539       s/\|[\w\.]+\|/<HOST> |/;
    409540       print MODFILE ($_);
    410541   }
     
    422553       s/\d+:\d+:\d+/ <DATE> /;
    423554       s/\s+\d+:\d+:\d+\w/ <TIME> /;
    424        s/\|\S+\|/<HOST>| /;
     555       s/\|[\w\.]+\|/<HOST> |/;
    425556       print MODFILE ($_);
    426557   }
     
    431562}
    432563
    433 
    434 
    435 
    436 
    437     # Check for the existence of a file named UnitTest in current directory
    438 #    if (-e "UnitTest") {
    439 
    440         # Open the UnitTest file
    441 #        open(TESTFILE,"<UnitTest");
    442 
    443         # Loop through the UnitTest file contents line by line
    444 #        while(<TESTFILE>) {
    445 
    446             # Set variable line and remove any newline characters
    447 #            $line = $_;
    448 #            chomp($line);
    449 
    450             # Check if line doesn't have comment character '#' or is empty
    451 #            if ( ! ($line =~ m/^#/) && $line) {
    452 
    453                 # Increment total number of tests drivers executed
    454 #               $totalTests++;
    455 
    456                 # Display line of the test driver being executed
    457                 # if silent option not set
    458 #                print("Testing: '$line'\n") if ( ! $silent);
    459 
    460                 # Execute the test driver and save results
    461 #                $_ = join("\n:: ", split("\n","\n" . `$line`));
    462 
    463                 # Check the output of test driver execution for a return
    464                 # value != 0 or any of the following phrases: FAILED
    465                 # FAULT, ERROR, Not found, SIGNAL
    466 #                if (($? != 0) || m/FAILED/i || m/FAULT/i || m/ERROR/i
    467 #                              || m/Not Found/i || m/SIGNAL/i ) {
    468 
    469                     # Dispaly failed output of test driver
    470 #                    print("$_\n") if ( ! $silent);
    471                     # Display the test driver failed
    472 #                    print("\nTest for '$line' Failed (Return value $?).\n");
    473                     # Increment number of tests failed
    474 #                    $testFailCount++;
    475                     # Push the current working directory ont the list of
    476                     # failed test drivers list
    477 #                    push(@testsFailed, $pwd . ":" . $line);
    478 #                } else {
    479                     # Display results of successful test if verbose
    480 #                    printf("$_\n") if ($verbose);
    481                     # Display success if silent not set
    482 #                    printf("Test successful.\n") if ( ! $silent);
    483 #                }
    484 #            }
    485 #        }
    486 #    }
    487 #}
    488 
Note: See TracChangeset for help on using the changeset viewer.