Changeset 86907 in webkit
- Timestamp:
- May 19, 2011 5:12:31 PM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r86887 r86907 1 2011-05-19 Dmitry Lomov <dslomov@google.com> 2 3 Reviewed by Adam Roben. 4 5 run-api-tests should run one test per process 6 https://bugs.webkit.org/show_bug.cgi?id=61088 7 8 * Scripts/run-api-tests: Resurrecting the previous revison of this file, with fixes to system call under Windows, 9 return code, and parsing GTest output format. 10 1 11 2011-05-15 Robert Hogan <robert@webkit.org> 2 12 -
trunk/Tools/Scripts/run-api-tests
r86671 r86907 37 37 use lib $FindBin::Bin; 38 38 use webkitdirs; 39 40 sub runTestTool(@); 39 use Term::ANSIColor qw(:constants); 40 41 41 sub buildTestTool(); 42 sub dumpAllTests(); 43 sub populateTests(); 44 sub runAllTests(); 45 sub runAllTestsInSuite($); 46 sub runTest($$); 42 47 43 48 my $showHelp = 0; … … 67 72 buildTestTool(); 68 73 setPathForRunningWebKitApp(\%ENV); 74 my %testsToRun = populateTests(); 69 75 70 76 if ($dump) { 71 my @dumpArguments = ("--gtest_list_tests"); 72 runTestTool(@dumpArguments); 73 exit(0); 74 } 75 76 runTestTool(); 77 78 sub runTestTool(@) 79 { 80 my (@arguments) = @_; 77 dumpAllTests(); 78 exit 0; 79 } 80 81 if (runAllTests()) { 82 exit 1; 83 } 84 85 sub dumpAllTests() 86 { 87 print "Dumping test cases\n"; 88 print "------------------\n"; 89 for my $suite (keys %testsToRun) { 90 print $suite . ":\n"; 91 print map { " " . $_ . "\n" } @{ $testsToRun{$suite} }; 92 } 93 print "------------------\n"; 94 } 95 96 sub runAllTests() 97 { 98 my $anyFailures = 0; 99 for my $suite (keys %testsToRun) { 100 my $failed = runAllTestsInSuite($suite); 101 if ($failed) { 102 $anyFailures = 1; 103 } 104 } 105 return $anyFailures; 106 } 107 108 sub runAllTestsInSuite($) 109 { 110 my ($suite) = @_; 111 print "Suite: $suite\n"; 112 113 my $anyFailures = 0; 114 for my $test (@{$testsToRun{$suite}}) { 115 my $failed = runTest($suite, $test); 116 if ($failed) { 117 $anyFailures = 1; 118 } 119 } 120 121 return $anyFailures; 122 } 123 124 sub runTest($$) 125 { 126 my ($suite, $testName) = @_; 127 my $test = $suite . "." . $testName; 128 129 my $gtestArg = "--gtest_filter=" . $test; 130 131 print " Test: $testName -> "; 81 132 82 133 my $result = 0; … … 89 140 local *DEVNULL; 90 141 my ($childIn, $childOut, $childErr); 91 92 $childOut = ">&STDOUT"; 93 unless ($verbose) { 142 if ($verbose) { 143 $childOut = ">&STDOUT"; 144 $childErr = ">&STDERR"; 145 } else { 94 146 open(DEVNULL, ">", File::Spec->devnull()) or die "Failed to open /dev/null"; 147 $childOut = ">&DEVNULL"; 95 148 $childErr = ">&DEVNULL"; 96 } else {97 $childErr = ">&STDERR";98 149 } 99 150 100 151 my $pid; 101 152 if (architecture()) { 102 $pid = open3($childIn, $childOut, $childErr, "arch", "-" . architecture(), $apiTesterPath, @arguments, @ARGV) or die "Failed to run test tool.";103 } else { 104 $pid = open3($childIn, $childOut, $childErr, $apiTesterPath, @arguments, @ARGV) or die "Failed to run test tool.";153 $pid = open3($childIn, $childOut, $childErr, "arch", "-" . architecture(), $apiTesterPath, $gtestArg, @ARGV) or die "Failed to run test: $test."; 154 } else { 155 $pid = open3($childIn, $childOut, $childErr, $apiTesterPath, $gtestArg, @ARGV) or die "Failed to run test: $test."; 105 156 } 106 157 … … 108 159 close($childOut); 109 160 close($childErr); 110 close(DEVNULL) ;161 close(DEVNULL) unless ($verbose); 111 162 112 163 waitpid($pid, 0); … … 120 171 } 121 172 my $apiTesterPath = File::Spec->catfile(productDir(), "TestWebKitAPI$apiTesterNameSuffix.exe"); 122 $result = system { $apiTesterPath } $apiTesterPath, @ARGV;173 $result = system { $apiTesterPath } $apiTesterPath, $gtestArg, @ARGV; 123 174 } else { 124 175 die "run-api-tests is not supported on this platform.\n" 125 176 } 126 177 178 if (!$result) { 179 print BOLD GREEN, "Passed", RESET, "\n"; 180 } else { 181 print BOLD RED, "Failed", RESET, "\n"; 182 } 127 183 return $result; 128 184 } 185 186 sub populateTests() 187 { 188 my @tests; 189 my $timedOut; 190 191 if (isAppleMacWebKit()) { 192 my $productDir = productDir(); 193 $ENV{DYLD_FRAMEWORK_PATH} = $productDir; 194 $ENV{WEBKIT_UNSET_DYLD_FRAMEWORK_PATH} = "YES"; 195 my $apiTesterPath = "$productDir/TestWebKitAPI"; 196 197 local *DEVNULL; 198 my ($childIn, $childOut, $childErr); 199 if ($verbose) { 200 $childErr = ">&STDERR"; 201 } else { 202 open(DEVNULL, ">", File::Spec->devnull()) or die "Failed to open /dev/null"; 203 $childErr = ">&DEVNULL"; 204 } 205 206 my $pid; 207 if (architecture()) { 208 $pid = open3($childIn, $childOut, $childErr, "arch", "-" . architecture(), $apiTesterPath, "--gtest_list_tests") or die "Failed to build list of tests!"; 209 } else { 210 $pid = open3($childIn, $childOut, $childErr, $apiTesterPath, "--gtest_list_tests") or die "Failed to build list of tests!"; 211 } 212 213 close($childIn); 214 @tests = <$childOut>; 215 close($childOut); 216 close($childErr); 217 close(DEVNULL) unless ($verbose); 218 219 waitpid($pid, 0); 220 my $result = $?; 221 222 if ($result) { 223 print STDERR "Failed to build list of tests!\n"; 224 exit exitStatus($result); 225 } 226 } elsif (isAppleWinWebKit()) { 227 my $apiTesterNameSuffix; 228 if (configurationForVisualStudio() ne "Debug_All") { 229 $apiTesterNameSuffix = ""; 230 } else { 231 $apiTesterNameSuffix = "_debug"; 232 } 233 my $apiTesterPath = File::Spec->catfile(productDir(), "TestWebKitAPI$apiTesterNameSuffix.exe"); 234 open(TESTS, "-|", $apiTesterPath, "--dump-tests") or die $!; 235 @tests = <TESTS>; 236 close(TESTS) or die $!; 237 } else { 238 die "run-api-tests is not supported on this platform.\n" 239 } 240 241 my %keyedTests = (); 242 my $suite; 243 for my $test (@tests) { 244 $test =~ s/[\r\n]*$//; 245 if ($test =~ m/\.$/) { 246 $test =~ s/\.$//; 247 $suite = $test; 248 } else { 249 $test =~ s/^\s*//; 250 push @{$keyedTests{$suite}}, $test; 251 } 252 } 253 254 return %keyedTests; 255 } 256 129 257 130 258 sub buildTestTool() … … 139 267 local *DEVNULL; 140 268 my ($childIn, $childOut, $childErr); 141 unless ($verbose) { 269 if ($verbose) { 270 # When not quiet, let the child use our stdout/stderr. 271 $childOut = ">&STDOUT"; 272 $childErr = ">&STDERR"; 273 } else { 142 274 open(DEVNULL, ">", File::Spec->devnull()) or die "Failed to open /dev/null"; 143 275 $childOut = ">&DEVNULL"; 144 276 $childErr = ">&DEVNULL"; 145 } else {146 # When not quiet, let the child use our stdout/stderr.147 $childOut = ">&STDOUT";148 $childErr = ">&STDERR";149 277 } 150 278
Note: See TracChangeset
for help on using the changeset viewer.