Changeset 585 for trunk/psLib/test/FullUnitTest
- Timestamp:
- May 5, 2004, 2:45:10 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/FullUnitTest (modified) (11 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
Note:
See TracChangeset
for help on using the changeset viewer.
