Changeset 585 for trunk/psLib/test/runTest
- Timestamp:
- May 5, 2004, 2:45:10 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/runTest (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/runTest
r521 r585 6 6 # deemed a failure. STDOUT and STDERR files will be place in a subdirectory 7 7 # named temp and the files will be compared with verified STDOUT, STDERR files 8 # in a subdirectory named verified. 8 # in a subdirectory named verified. If there are no STDOUT, STDERR files in 9 # the verified directory, the captured STDOUT, STDERR files will be scanned 10 # for words which indicate a failure. 9 11 # 10 12 # Assumptions: A verified subdirectory with STDOUT, STDERR files exists for 11 # the test driver specified in the arguements. 13 # the test driver specified in the arguements if an exact 14 # match of the streams STDOUT, STDERR is necessary. 12 15 # 13 16 # Return values: … … 20 23 # 16 STDERR files did not compare 21 24 # 32 Test driver doesn't exist or is not executable 22 # 25 # 64 STDOUT captured contains error strings 26 # 128 STDERR captured contains error strings 27 # 256 Test driver did not return zero 28 # 23 29 # SYNOSIS: runTest testDriverName 24 30 # 25 31 # $Revison: $ $Name: not supported by cvs2svn $ 26 # $Date: 2004-0 4-27 01:47:20 $32 # $Date: 2004-05-06 00:45:10 $ 27 33 # 28 34 # Copyright 2004 Maui High Performance Computering Center, University of Hawaii … … 63 69 if ( !( -e "verified" )) { 64 70 # Display message that verified subdirectory doesn't exist 65 print(" Verified directory doesn't exist. Need verified STDOUT, STDERR files.\n");71 print(" Verified directory doesn't exist.\n"); 66 72 # Exit script since the test cannot be run with verified files 67 exit(1);73 $exitValue = 1; 68 74 } 69 75 … … 86 92 # Display failure message with return value to user 87 93 if ( $? != 0 && ( $testFile !~ /^A/i) ) { 88 print(" Failed - Test Driver expected 0 return value (Return value $?)\n");94 print(" Failed - Test Driver expected 0 return value (Return value $?)\n"); 89 95 } elsif ( $? == 0 && ( $testFile =~ /^A/i) ) { 90 print("Failed - Test Driver expected abort (Return value $?)\n"); 91 } 96 print(" Failed - Test Driver expected abort (Return value $?)\n"); 97 } 98 $exitValue |= 256; 92 99 } else { 93 100 94 101 # Test driver succeeded. 95 96 # Check for existence of verified STDOUT files97 if ( !( -e "verified/$testFile.stdout") ) {98 99 # Display message to user that verified STDOUT file doesn't exist100 print("Verified file $testFile.stdout doesn't exist. Test stopped.\n");101 102 # Set exit value bit 1 to indicate proper failure103 $exitValue |= 2;104 } else {105 106 # Verified STDOUT file exists107 108 # Open the STDOUT file for reading109 open(OUTFILE, "< temp/$testFile.stdout");110 # Open mod file to place filtered STDOUT111 open(MODFILE, ">temp/$testFile.stdout.mod");112 # Replace the variable date, time and host information with constants113 while( <OUTFILE> ) {114 s/\d+:\d+:\d+/ <DATE> /;115 s/\s+\d+:\d+:\d+\w/ <TIME> /;116 s/\|\S+\|/<HOST>| /;117 print MODFILE ($_);118 }119 # Close mod file120 close(MODFILE);121 # Close STDERR file122 close(OUTFILE);123 124 # Open the STDERR file for reading125 open(OUTFILE, "< temp/$testFile.stderr");126 # Open mod file to place filtered STDERR127 open(MODFILE, "> temp/$testFile.stderr.mod");128 # Replace the variable date, time and host information with constants129 while( <OUTFILE> ) {130 s/\d+:\d+:\d+/ <DATE> /;131 s/\s+\d+:\d+:\d+\w/ <TIME> /;132 s/\|\S+\|/<HOST>| /;133 print MODFILE ($_);134 }135 # Close mod file136 close(MODFILE);137 # Close STDERR file138 close(OUTFILE);139 140 # Perform difference on the STDOUT files141 $diffstdout = `diff verified/$testFile.stdout temp/$testFile.stdout.mod`;142 143 # Check the return value of the difference144 if ( $? != 0 ) {145 146 # Difference of STDOUT files failed147 148 # Display message of the failure of difference to user149 print("Failed - STDOUT difference\n$diffstdout\n");150 102 151 # Exit value to indicate STDOUT did not compare 152 $exitValue |= 8; 153 } else { 154 155 # STDOUT file compared successfully 156 157 # Check for the existence of verified STDERR file 158 if ( !( -e "verified/$testFile.stderr") ) { 159 160 # Display message to user that STDOUT file doesn't exist 161 print("Verified file $testFile.stderr doesn't exist. Test stopped.\n"); 162 163 $exitValue |= 4; 164 } else { 165 166 # Perform difference on the STDERR files 167 $diffstderr = `diff verified/$testFile.stderr temp/$testFile.stderr.mod`; 168 169 # Check the return value of the difference 170 if ( $? != 0 ) { 171 172 # Difference of STDERR files failed 173 174 # Display message of the failure of difference to user 175 print("Failed - STDERR difference\n$diffstderr\n"); 176 177 # Exit value set to indicate STDERR did not compare 178 $exitValue |= 16; 179 } else { 180 181 # Test driver passed, STDOUT, STDERR files compared 182 183 # Display message test was successful 184 print("Test successful\n"); 185 } 186 } 187 } 103 # Create filtered version of stdout and stderr 104 105 # Open the STDOUT file for reading 106 open(OUTFILE, "< temp/$testFile.stdout"); 107 # Open mod file to place filtered STDOUT 108 open(MODFILE, ">temp/$testFile.stdout.mod"); 109 # Replace the variable date, time and host information with constants 110 while( <OUTFILE> ) { 111 s/\d+:\d+:\d+/ <DATE> /; 112 s/\s+\d+:\d+:\d+\w/ <TIME> /; 113 s/\|[\w\.]+\|/<HOST> |/; 114 print MODFILE ($_); 115 } 116 # Close mod file 117 close(MODFILE); 118 # Close STDERR file 119 close(OUTFILE); 120 121 # Open the STDERR file for reading 122 open(OUTFILE, "< temp/$testFile.stderr"); 123 # Open mod file to place filtered STDERR 124 open(MODFILE, "> temp/$testFile.stderr.mod"); 125 # Replace the variable date, time and host information with constants 126 while( <OUTFILE> ) { 127 s/\d+:\d+:\d+/ <DATE> /; 128 s/\s+\d+:\d+:\d+\w/ <TIME> /; 129 s/\|[\w\.]+\|/<HOST> |/; 130 print MODFILE ($_); 131 } 132 # Close mod file 133 close(MODFILE); 134 # Close STDERR file 135 close(OUTFILE); 136 137 # Compare STDOUT capture with verified file 138 $exitValue |= &compareStream("verified/$testFile.stdout"); 139 140 # Check exit value to determine if verified file doesn't exist 141 if ( $exitValue & 2 ) { 142 143 # STDOUT verified doesn't exist. Search STDOUT capture 144 # for strings indicating error or failure 145 $exitValue |= &errorStrSearch("$testFile.stdout"); 146 } 147 148 # Compare STDERR capture with verified file 149 $exitValue |= &compareStream("verified/$testFile.stderr"); 150 151 # Check exit value to determine if verified file doesn't exist 152 if ( $exitValue & 4 ) { 153 154 # STDERR verified doesn't exist. Search STDERR capture 155 # for strings indicating error or failure 156 $exitValue |= &errorStrSearch("$testFile.stderr"); 188 157 } 189 158 } … … 191 160 # Since test driver doesn't exist or is not executable then display 192 161 # message to user. 193 print(" Need to specify an executable test file within directory.\n");162 print(" Need to specify an executable test file within directory.\n"); 194 163 195 164 # Exit value set to indicate test driver doesn't exist or not executable … … 197 166 } 198 167 199 # Exit for the script with exit vale 168 # Exit for the script with exit value 169 # Ignore the first three bit flags in exitValue since there are not indicators 170 # of a failed test 171 if ( ($exitValue >> 3) != 0 ) { 172 print("Test failed - return status = $exitValue\n\n"); 173 } else { 174 print("Test successful\n\n"); 175 } 200 176 exit($exitValue); 201 177 178 ################################################################################ 179 # 180 # SUBROUTINE: errorStrSearch 181 # 182 # Description: This subroutine will search the file specified in its 183 # parameter for error strings and if they do exists 184 # the appropriate value will be returned. 185 # 186 # Parameter(s): fileName - input file to search for strings 187 # 188 # Return: 0 - No error strings found 189 # 64 - Error strings found in STDOUT 190 # 128 - Error strings found in STDERR 191 # 192 ############################################################################### 193 194 sub errorStrSearch { 195 local($fileName) = @_; 196 local($returnVal) = 0; 197 198 # Open the captured file 199 open(CAPT_FILE, "<temp/$fileName"); 200 201 # Scan through all the lines of the file searching for error strings 202 while ( <CAPT_FILE> ) { 203 if ( m/FAIL/i || m/FAULT/i || m/ERROR/i || m/Not Found/i 204 || m/SIGNAL/i || m/NO SUCH FILE/i || m/|E|/i 205 || m/|A|/i ) { 206 if ( $fileName =~ m/out/ ) { 207 print(" Failed - File $fileName contains error strings.\n"); 208 $returnVal = 64; 209 } elsif ( $fileName =~ m/err/ ) { 210 print(" Failed - File $fileName contains error strings.\n"); 211 $returnVal = 128; 212 } 213 last; 214 } 215 } 216 # Close the capture file 217 close(CAPT_FILE); 218 # Return the return value 219 return($returnVal); 220 } 221 222 ################################################################################ 223 # 224 # SUBROUTINE: compareStream 225 # 226 # Description: This subroutine will compare the captured stream file with 227 # a file in the verified directory if one exists. 228 # 229 # Parameter(s): streamFile - input file to compare 230 # 231 # Return: 0 - Compare successful 232 # 2 - STDOUT verified file doesn't exist 233 # 4 - STDERR verified file doesn't exist 234 # 8 - STDOUT verified file doesn't compare 235 # 16 - STDERR verified file doesn't compare 236 # 237 ############################################################################### 238 239 sub compareStream { 240 local($streamFile) = @_; 241 local($returnVal) = 0; 242 local($tempFile) = ""; 243 244 # Check for existence of verified STD stream files 245 if ( !( -e $streamFile) ) { 246 247 # Display message to user that verified STDOUT file doesn't exist 248 print(" File $streamFile doesn't exist.\n"); 249 250 # Set exit value bit 1 to indicate proper failure 251 if ( $streamFile =~ /out$/ ) { 252 $returnVal |= 2; 253 } elsif ( $streamFile =~ /err$/ ) { 254 $returnVal |= 4; 255 } 256 } else { 257 258 # Verified STD stream file exists 259 260 # Create name of the temp file to compare 261 $tempFile = $streamFile; 262 $tempFile =~ s/verified/temp/; 263 $tempFile = $tempFile . ".mod"; 264 265 # Perform difference on the STD stream files 266 $diffstdout = `diff $streamFile $tempFile`; 267 268 # Check the return value of the difference 269 if ( $? != 0 ) { 270 271 # Difference of STD stream files failed 272 273 # Check for STDOUT in file name to convey appropirate return value 274 if ( $streamFile =~ /out$/ ) { 275 # Display message of the failure of difference to user 276 print(" Failed - STDOUT difference\n$diffstdout\n"); 277 278 # Exit value to indicate STDOUT did not compare 279 $returnVal |= 8; 280 } elsif ( $streamFile =~ /err$/ ) { 281 # Display message of the failure of difference to user 282 print(" Failed - STDERR difference\n$diffsdout\n"); 283 284 # Exit value to indicate STDERR did not compare 285 $returnVal |= 16; 286 } 287 } 288 } 289 290 # Return the result of the compare 291 return($returnVal); 292 } 293
Note:
See TracChangeset
for help on using the changeset viewer.
