Changeset 585
- Timestamp:
- May 5, 2004, 2:45:10 PM (22 years ago)
- Location:
- trunk/psLib/test
- Files:
-
- 2 edited
-
FullUnitTest (modified) (11 diffs)
-
runTest (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/FullUnitTest
r521 r585 19 19 # RETURN : integer number of tests which failed 20 20 # 21 # $Revision: 1. 1$ $Name: not supported by cvs2svn $22 # $Date: 2004-0 4-27 01:47:20 $21 # $Revision: 1.2 $ $Name: not supported by cvs2svn $ 22 # $Date: 2004-05-06 00:45:10 $ 23 23 # 24 24 # Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 131 131 # Parameter(s): base directory to start testing 132 132 # 133 # Return: None 134 # 133 135 ################################################################################ 134 136 … … 175 177 # 176 178 # Parameter(s): base directory where make and test drivers are located 179 # 180 # Return: None 177 181 # 178 182 ################################################################################ … … 243 247 local(@files,$j); 244 248 local($pwd); 249 local($exitValue) = 0; 245 250 246 251 # Set variable to pwd to current test directory … … 276 281 # Display message to user that verified directories do not 277 282 # 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"); 279 284 print("No verified subdirectory present.\n"); 280 285 # Increment test fail count 281 $testFailCount++;286 # $testFailCount++; 282 287 # Save the file failed 283 push(@testsFailed, $pwd . "/" . $files[$j]);284 return;288 # push(@testsFailed, $pwd . "/" . $files[$j]); 289 # return; 285 290 } 286 291 } … … 305 310 # Perform difference on STDOUT file collected 306 311 # 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) ) { 311 319 # Increment the total number of test failed 312 320 $testFailCount++; … … 315 323 } else { 316 324 # 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 320 333 $testFailCount++; 334 # Push test on failed list 321 335 push(@testsFailed, $pwd . "/" . $files[$j]); 322 336 } else { … … 332 346 ################################################################################ 333 347 # 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 362 sub 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 407 sub 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 # 334 465 # SUBROUTINE: checkForTempDirectory 335 466 # … … 406 537 s/\d+:\d+:\d+/ <DATE> /; 407 538 s/\s+\d+:\d+:\d+\w/ <TIME> /; 408 s/\| \S+\|/<HOST>|/;539 s/\|[\w\.]+\|/<HOST> |/; 409 540 print MODFILE ($_); 410 541 } … … 422 553 s/\d+:\d+:\d+/ <DATE> /; 423 554 s/\s+\d+:\d+:\d+\w/ <TIME> /; 424 s/\| \S+\|/<HOST>|/;555 s/\|[\w\.]+\|/<HOST> |/; 425 556 print MODFILE ($_); 426 557 } … … 431 562 } 432 563 433 434 435 436 437 # Check for the existence of a file named UnitTest in current directory438 # if (-e "UnitTest") {439 440 # Open the UnitTest file441 # open(TESTFILE,"<UnitTest");442 443 # Loop through the UnitTest file contents line by line444 # while(<TESTFILE>) {445 446 # Set variable line and remove any newline characters447 # $line = $_;448 # chomp($line);449 450 # Check if line doesn't have comment character '#' or is empty451 # if ( ! ($line =~ m/^#/) && $line) {452 453 # Increment total number of tests drivers executed454 # $totalTests++;455 456 # Display line of the test driver being executed457 # if silent option not set458 # print("Testing: '$line'\n") if ( ! $silent);459 460 # Execute the test driver and save results461 # $_ = join("\n:: ", split("\n","\n" . `$line`));462 463 # Check the output of test driver execution for a return464 # value != 0 or any of the following phrases: FAILED465 # FAULT, ERROR, Not found, SIGNAL466 # if (($? != 0) || m/FAILED/i || m/FAULT/i || m/ERROR/i467 # || m/Not Found/i || m/SIGNAL/i ) {468 469 # Dispaly failed output of test driver470 # print("$_\n") if ( ! $silent);471 # Display the test driver failed472 # print("\nTest for '$line' Failed (Return value $?).\n");473 # Increment number of tests failed474 # $testFailCount++;475 # Push the current working directory ont the list of476 # failed test drivers list477 # push(@testsFailed, $pwd . ":" . $line);478 # } else {479 # Display results of successful test if verbose480 # printf("$_\n") if ($verbose);481 # Display success if silent not set482 # printf("Test successful.\n") if ( ! $silent);483 # }484 # }485 # }486 # }487 #}488 -
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.
