Changeset 1490 for trunk/psLib/test/runTest
- Timestamp:
- Aug 11, 2004, 1:42:49 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/psLib/test/runTest (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/runTest
r1404 r1490 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. If there are no STDOUT, STDERR files in 8 # in a subdirectory named verified. If there are no STDOUT, STDERR files in 9 9 # the verified directory, the captured STDOUT, STDERR files will be scanned 10 10 # for words which indicate a failure. 11 11 # 12 # Assumptions: A verified subdirectory with STDOUT, STDERR files exists for 12 # Assumptions: A verified subdirectory with STDOUT, STDERR files exists for 13 13 # the test driver specified in the arguements if an exact 14 14 # match of the streams STDOUT, STDERR is necessary. … … 30 30 # 31 31 # $Revison: $ $Name: not supported by cvs2svn $ 32 # $Date: 2004-08- 06 21:50:13$32 # $Date: 2004-08-11 23:42:49 $ 33 33 # 34 34 # Copyright 2004 Maui High Performance Computering Center, University of Hawaii … … 40 40 41 41 # Assign variables based on the presence of command line options to the script 42 GetOptions("reset!"=>\$reset, 43 "resetStderr!"=>\$resetStderr, 44 "resetStdout!"=>\$resetStdout, 45 "help!"=>\$help); 42 GetOptions( 43 "reset!" => \$reset, 44 "resetStderr!" => \$resetStderr, 45 "resetStdout!" => \$resetStdout, 46 "help!" => \$help 47 ); 46 48 47 49 if ($help) { … … 54 56 $resetStdout = 1; 55 57 } 56 58 57 59 # Initialize exit value 58 60 $exitValue = 0; 59 61 60 62 # Set up the PSLIB_ROOT environment variable if the user doesn't have it set 61 if ( ! $ENV{'PSLIB_ROOT'}) { 63 if ( !$ENV{'PSLIB_ROOT'} ) { 64 62 65 # Use the directory directly above test 63 66 $PSLIB_ROOT = `cd ..;pwd`; 67 64 68 # Remove newline for the end of path returned 65 69 chomp($PSLIB_ROOT); 70 66 71 # Set the environment variable 67 72 $ENV{'PSLIB_ROOT'} = $PSLIB_ROOT; 68 # Display message that PSLIB_ROOT not found and set to 73 74 # Display message that PSLIB_ROOT not found and set to 69 75 print("PSLIB_ROOT not found: set to $PSLIB_ROOT\n"); 70 76 } 71 77 72 78 # Add PSLIB_ROOT/lib to LD_LIBRARY_PATH and DYLD_LIBRARY_PATH environment vars 73 $ENV{'LD_LIBRARY_PATH'} = "$ENV{'PSLIB_ROOT'}/lib:$ENV{'LD_LIBRARY_PATH'}";79 $ENV{'LD_LIBRARY_PATH'} = "$ENV{'PSLIB_ROOT'}/lib:$ENV{'LD_LIBRARY_PATH'}"; 74 80 $ENV{'DYLD_LIBRARY_PATH'} = "$ENV{'PSLIB_ROOT'}/lib:$ENV{'DYLD_LIBRARY_PATH'}"; 75 81 … … 80 86 81 87 # Check if a temp directory already exists in the current work directory 82 if ( !( -e "temp" )) { 83 # Create temp directory to store STDOUT, STDERR files during test run 84 `mkdir temp`; 85 # Display message of new directory created 86 print("Creating temp directory\n"); 87 } 88 88 if ( !( -e "temp" ) ) { 89 90 # Create temp directory to store STDOUT, STDERR files during test run 91 `mkdir temp`; 92 93 # Display message of new directory created 94 print("Creating temp directory\n"); 95 } 96 89 97 # Check if a verified directory exists in the current work directory 90 if ( !( -e "verified" )) { 98 if ( !( -e "verified" ) ) { 99 91 100 # Display message that verified subdirectory doesn't exist 92 101 print(" Verified directory doesn't exist.\n"); 102 93 103 # Exit script since the test cannot be run with verified files 94 104 $exitValue = 1; 95 105 } 96 106 97 107 # Check if the test driver file exists and is executable 98 if ( ( -e $testFile) && (-x $testFile) ) {99 108 if ( ( -e $testFile ) && ( -x $testFile ) ) { 109 100 110 # Display message the test driver is being executed 101 111 print("--- Executing test driver: $testFile\n"); 102 112 103 113 # Invoke the test driver 104 114 system("./$testFile 1> temp/$testFile.stdout 2> temp/$testFile.stderr"); 105 115 106 116 # Check the return value of the test driver. A value other than 0 107 117 # indicates failure of the test driver unless the test driver is name 108 118 # with a leading 'a' which indicates the test driver is expecting an 109 119 # abort condition to terminate the driver. 110 if ( ( $? != 0 && ( $testFile !~ /^A/i)) || 111 ( $? == 0 && ( $testFile =~ /^A/i)) ) { 112 120 if ( ( $? != 0 && ( $testFile !~ /^A/i ) ) 121 || ( $? == 0 && ( $testFile =~ /^A/i ) ) ) 122 { 123 113 124 # Display failure message with return value to user 114 if ( $? != 0 && ( $testFile !~ /^A/i ) ) {125 if ( $? != 0 && ( $testFile !~ /^A/i ) ) { 115 126 print(" Failed - Test Driver expected 0 return value (Return value $?)\n"); 116 } elsif ( $? == 0 && ( $testFile =~ /^A/i) ) { 127 } 128 elsif ( $? == 0 && ( $testFile =~ /^A/i ) ) { 117 129 print(" Failed - Test Driver expected abort (Return value $?)\n"); 118 130 } 119 131 $exitValue |= 256; 120 } else { 121 132 } 133 else { 134 122 135 # Test driver succeeded. 123 136 124 137 # Create filtered version of stdout and stderr 125 126 # Open the STDOUT file for reading 127 open(OUTFILE, "< temp/$testFile.stdout"); 138 139 # Open the STDOUT file for reading 140 open( OUTFILE, "< temp/$testFile.stdout" ); 141 128 142 # Open mod file to place filtered STDOUT 129 open(MODFILE, "> temp/$testFile.stdout.mod"); 130 open(MODFILE2, "> verified/$testFile.stdout") if $resetStdout; 143 open( MODFILE, "> temp/$testFile.stdout.mod" ); 144 open( MODFILE2, "> verified/$testFile.stdout" ) if $resetStdout; 145 131 146 # Replace the variable date, time and host information with constants 132 147 $hostname = `hostname`; 133 148 chop $hostname; 134 while ( <OUTFILE>) {149 while (<OUTFILE>) { 135 150 s/\s+\d+:\d+:\d+\w/<TIME>/g; 136 151 s/\d+:\d+:\d+/<DATE>/g; … … 138 153 s/: Line \d+/: Line <LINENO>/g; 139 154 s/\:\d+/\:<LINENO>/g; 155 140 156 # Filter lines with malloc. This is an artifact of memory testing 141 157 # with the Mac testbed 142 if ( ! m/\*\*\*\smalloc/ ) {143 print MODFILE ($_);144 print MODFILE2 ($_) if $resetStdout;158 if ( !m/\*\*\*\smalloc/ ) { 159 print MODFILE ($_); 160 print MODFILE2 ($_) if $resetStdout; 145 161 } 146 162 } 163 147 164 # Close mod file 148 165 close(MODFILE); 149 166 close(MODFILE2) if $resetStdout; 167 150 168 # Close STDERR file 151 169 close(OUTFILE); 152 153 # Open the STDERR file for reading 154 open(OUTFILE, "< temp/$testFile.stderr"); 170 171 # Open the STDERR file for reading 172 open( OUTFILE, "< temp/$testFile.stderr" ); 173 155 174 # Open mod file to place filtered STDERR 156 open(MODFILE, "> temp/$testFile.stderr.mod"); 157 open(MODFILE2, "> verified/$testFile.stderr") if $resetStderr; 175 open( MODFILE, "> temp/$testFile.stderr.mod" ); 176 open( MODFILE2, "> verified/$testFile.stderr" ) if $resetStderr; 177 158 178 # Replace the variable date, time and host information with constants 159 while ( <OUTFILE>) {179 while (<OUTFILE>) { 160 180 s/\s+\d+:\d+:\d+\w/<TIME>/g; 161 181 s/\d+:\d+:\d+/<DATE>/g; … … 163 183 s/: Line \d+/: Line <LINENO>/g; 164 184 s/\:\d+/\:<LINENO>/g; 185 165 186 # Filter lines with malloc. This is an artifact of memory testing 166 187 # with the Mac testbed 167 if ( ! m/\*\*\*\smalloc/ ) {168 print MODFILE ($_);169 print MODFILE2 ($_) if $resetStderr;188 if ( !m/\*\*\*\smalloc/ ) { 189 print MODFILE ($_); 190 print MODFILE2 ($_) if $resetStderr; 170 191 } 171 192 } 193 172 194 # Close mod file 173 195 close(MODFILE); 174 196 close(MODFILE2) if $resetStderr; 197 175 198 # Close STDERR file 176 199 close(OUTFILE); 177 200 178 201 # Compare STDOUT capture with verified file 179 202 $exitValue |= &compareStream("verified/$testFile.stdout"); 180 203 181 204 # Check exit value to determine if verified file doesn't exist 182 205 if ( $exitValue & 2 ) { 183 206 184 207 # STDOUT verified doesn't exist. Search STDOUT capture 185 208 # for strings indicating error or failure 186 209 $exitValue |= &errorStrSearch("$testFile.stdout"); 187 210 } 188 211 189 212 # Compare STDERR capture with verified file 190 213 $exitValue |= &compareStream("verified/$testFile.stderr"); 191 214 192 215 # Check exit value to determine if verified file doesn't exist 193 216 if ( $exitValue & 4 ) { 194 217 195 218 # STDERR verified doesn't exist. Search STDERR capture 196 219 # for strings indicating error or failure … … 198 221 } 199 222 } 200 } else { 201 # Since test driver doesn't exist or is not executable then display 223 } 224 else { 225 226 # Since test driver doesn't exist or is not executable then display 202 227 # message to user. 203 228 print(" Need to specify an executable test file within directory.\n"); 204 229 205 230 # Exit value set to indicate test driver doesn't exist or not executable 206 231 $exitValue |= 32; … … 211 236 # Ignore the first three bit flags in exitValue since there are not indicators 212 237 # of a failed test 213 if ( ( $exitValue >> 3) != 0 ) {238 if ( ( $exitValue >> 3 ) != 0 ) { 214 239 print("Test failed - return status = $exitValue\n\n"); 215 } else { 240 } 241 else { 216 242 print("Test successful\n\n"); 217 243 } … … 235 261 236 262 sub errorStrSearch { 237 local ($fileName)= @_;238 local ($returnVal) = 0;263 local ($fileName) = @_; 264 local ($returnVal) = 0; 239 265 240 266 # Open the captured file 241 open( CAPT_FILE, "<temp/$fileName");267 open( CAPT_FILE, "<temp/$fileName" ); 242 268 243 269 # Scan through all the lines of the file searching for error strings 244 while ( <CAPT_FILE> ) { 245 if ( m/FAIL/i || m/FAULT/i || m/ERROR/i || m/Not Found/i 246 || m/SIGNAL/i || m/NO SUCH FILE/i || m/\|E\|/i 247 || m/\|A\|/i ) { 270 while (<CAPT_FILE>) { 271 if ( m/FAIL/i 272 || m/FAULT/i 273 || m/ERROR/i 274 || m/Not Found/i 275 || m/SIGNAL/i 276 || m/NO SUCH FILE/i 277 || m/\|E\|/i 278 || m/\|A\|/i ) 279 { 248 280 if ( $fileName =~ m/out/ ) { 249 281 print(" Failed - File $fileName contains error strings.\n"); 250 282 $returnVal = 64; 251 } elsif ( $fileName =~ m/err/ ) { 283 } 284 elsif ( $fileName =~ m/err/ ) { 252 285 print(" Failed - File $fileName contains error strings.\n"); 253 286 $returnVal = 128; … … 256 289 } 257 290 } 291 258 292 # Close the capture file 259 293 close(CAPT_FILE); 294 260 295 # Return the return value 261 return ($returnVal);296 return ($returnVal); 262 297 } 263 298 … … 280 315 281 316 sub compareStream { 282 local ($streamFile) = @_;283 local ($returnVal)= 0;284 local ($tempFile)= "";317 local ($streamFile) = @_; 318 local ($returnVal) = 0; 319 local ($tempFile) = ""; 285 320 286 321 # Check for existence of verified STD stream files 287 if ( !( -e $streamFile ) ) {288 322 if ( !( -e $streamFile ) ) { 323 289 324 # Display message to user that verified STDOUT file doesn't exist 290 325 print(" File $streamFile doesn't exist.\n"); 291 326 292 327 # Set exit value bit 1 to indicate proper failure 293 328 if ( $streamFile =~ /out$/ ) { 294 329 $returnVal |= 2; 295 } elsif ( $streamFile =~ /err$/ ) { 330 } 331 elsif ( $streamFile =~ /err$/ ) { 296 332 $returnVal |= 4; 297 333 } 298 } else { 334 } 335 else { 299 336 300 337 # Verified STD stream file exists 301 338 302 339 # Create name of the temp file to compare 303 $tempFile = $streamFile; 340 $tempFile = $streamFile; 304 341 $tempFile =~ s/verified/temp/; 305 342 $tempFile = $tempFile . ".mod"; 306 343 307 344 # Perform difference on the STD stream files 308 345 $diffstdout = `diff $streamFile $tempFile`; … … 310 347 # Check the return value of the difference 311 348 if ( $? != 0 ) { 312 349 313 350 # Difference of STD stream files failed 314 351 315 352 # Check for STDOUT in file name to convey appropirate return value 316 353 if ( $streamFile =~ /out$/ ) { 317 # Display message of the failure of difference to user 318 print(" Failed - STDOUT difference\n$diffstdout\n"); 319 320 # Exit value to indicate STDOUT did not compare 321 $returnVal |= 8; 322 } elsif ( $streamFile =~ /err$/ ) { 323 # Display message of the failure of difference to user 324 print(" Failed - STDERR difference\n$diffstdout\n"); 325 326 # Exit value to indicate STDERR did not compare 327 $returnVal |= 16; 328 } 329 } 330 } 331 354 355 # Display message of the failure of difference to user 356 print(" Failed - STDOUT difference\n$diffstdout\n"); 357 358 # Exit value to indicate STDOUT did not compare 359 $returnVal |= 8; 360 } 361 elsif ( $streamFile =~ /err$/ ) { 362 363 # Display message of the failure of difference to user 364 print(" Failed - STDERR difference\n$diffstdout\n"); 365 366 # Exit value to indicate STDERR did not compare 367 $returnVal |= 16; 368 } 369 } 370 } 371 332 372 # Return the result of the compare 333 return ($returnVal);334 } 335 373 return ($returnVal); 374 } 375
Note:
See TracChangeset
for help on using the changeset viewer.
