OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/test/test_launcher.h" | 5 #include "content/test/test_launcher.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/environment.h" | 11 #include "base/environment.h" |
12 #include "base/file_util.h" | 12 #include "base/file_util.h" |
13 #include "base/hash_tables.h" | 13 #include "base/hash_tables.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/mac/scoped_nsautorelease_pool.h" | |
16 #include "base/memory/linked_ptr.h" | 15 #include "base/memory/linked_ptr.h" |
17 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
18 #include "base/process_util.h" | 17 #include "base/process_util.h" |
19 #include "base/scoped_temp_dir.h" | 18 #include "base/scoped_temp_dir.h" |
20 #include "base/string_number_conversions.h" | 19 #include "base/string_number_conversions.h" |
21 #include "base/string_util.h" | 20 #include "base/string_util.h" |
22 #include "base/test/test_suite.h" | 21 #include "base/test/test_suite.h" |
23 #include "base/test/test_timeouts.h" | 22 #include "base/test/test_timeouts.h" |
24 #include "base/time.h" | 23 #include "base/time.h" |
25 #include "base/utf_string_conversions.h" | 24 #include "base/utf_string_conversions.h" |
26 #include "content/test/browser_test.h" | 25 #include "content/test/browser_test.h" |
27 #include "net/base/escape.h" | 26 #include "net/base/escape.h" |
28 #include "testing/gtest/include/gtest/gtest.h" | 27 #include "testing/gtest/include/gtest/gtest.h" |
29 | 28 |
30 #if defined(OS_WIN) | 29 #if defined(OS_WIN) |
31 #include "base/base_switches.h" | 30 #include "base/base_switches.h" |
32 #include "content/common/sandbox_policy.h" | 31 #include "content/common/sandbox_policy.h" |
33 #include "sandbox/src/dep.h" | 32 #include "sandbox/src/dep.h" |
34 #include "sandbox/src/sandbox_factory.h" | 33 #include "sandbox/src/sandbox_factory.h" |
35 #include "sandbox/src/sandbox_types.h" | 34 #include "sandbox/src/sandbox_types.h" |
| 35 #elif defined(OS_MACOSX) |
| 36 #include "base/mac/scoped_nsautorelease_pool.h" |
36 #endif | 37 #endif |
37 | 38 |
38 namespace test_launcher { | 39 namespace test_launcher { |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 // The environment variable name for the total number of test shards. | 43 // The environment variable name for the total number of test shards. |
43 static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS"; | 44 static const char kTestTotalShards[] = "GTEST_TOTAL_SHARDS"; |
44 // The environment variable name for the test shard index. | 45 // The environment variable name for the test shard index. |
45 static const char kTestShardIndex[] = "GTEST_SHARD_INDEX"; | 46 static const char kTestShardIndex[] = "GTEST_SHARD_INDEX"; |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 timeout_ms *= kSlowTestTimeoutMultiplier; | 296 timeout_ms *= kSlowTestTimeoutMultiplier; |
296 | 297 |
297 return timeout_ms; | 298 return timeout_ms; |
298 } | 299 } |
299 | 300 |
300 // Runs test specified by |test_name| in a child process, | 301 // Runs test specified by |test_name| in a child process, |
301 // and returns the exit code. | 302 // and returns the exit code. |
302 int RunTest(TestLauncherDelegate* launcher_delegate, | 303 int RunTest(TestLauncherDelegate* launcher_delegate, |
303 const std::string& test_name, | 304 const std::string& test_name, |
304 int default_timeout_ms) { | 305 int default_timeout_ms) { |
| 306 #if defined(OS_MACOSXS) |
305 // Some of the below method calls will leak objects if there is no | 307 // Some of the below method calls will leak objects if there is no |
306 // autorelease pool in place. | 308 // autorelease pool in place. |
307 base::mac::ScopedNSAutoreleasePool pool; | 309 base::mac::ScopedNSAutoreleasePool pool; |
| 310 #endif |
308 | 311 |
309 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 312 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
310 CommandLine new_cmd_line(cmd_line->GetProgram()); | 313 CommandLine new_cmd_line(cmd_line->GetProgram()); |
311 CommandLine::SwitchMap switches = cmd_line->GetSwitches(); | 314 CommandLine::SwitchMap switches = cmd_line->GetSwitches(); |
312 | 315 |
313 // Strip out gtest_output flag because otherwise we would overwrite results | 316 // Strip out gtest_output flag because otherwise we would overwrite results |
314 // of the previous test. We will generate the final output file later | 317 // of the previous test. We will generate the final output file later |
315 // in RunTests(). | 318 // in RunTests(). |
316 switches.erase(kGTestOutputFlag); | 319 switches.erase(kGTestOutputFlag); |
317 | 320 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 } | 635 } |
633 | 636 |
634 // Special value "-1" means "repeat indefinitely". | 637 // Special value "-1" means "repeat indefinitely". |
635 if (cycles != -1) | 638 if (cycles != -1) |
636 cycles--; | 639 cycles--; |
637 } | 640 } |
638 return exit_code; | 641 return exit_code; |
639 } | 642 } |
640 | 643 |
641 } // namespace test_launcher | 644 } // namespace test_launcher |
OLD | NEW |