| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/test/launcher/unit_test_launcher.h" | 5 #include "base/test/launcher/unit_test_launcher.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 if (CommandLine::ForCurrentProcess()->HasSwitch(kHelpFlag)) { | 457 if (CommandLine::ForCurrentProcess()->HasSwitch(kHelpFlag)) { |
| 458 PrintUsage(); | 458 PrintUsage(); |
| 459 return 0; | 459 return 0; |
| 460 } | 460 } |
| 461 | 461 |
| 462 base::TimeTicks start_time(base::TimeTicks::Now()); | 462 base::TimeTicks start_time(base::TimeTicks::Now()); |
| 463 | 463 |
| 464 testing::InitGoogleTest(&argc, argv); | 464 testing::InitGoogleTest(&argc, argv); |
| 465 TestTimeouts::Initialize(); | 465 TestTimeouts::Initialize(); |
| 466 | 466 |
| 467 int jobs = SysInfo::NumberOfProcessors(); | |
| 468 if (!GetSwitchValueAsInt(switches::kTestLauncherJobs, &jobs)) | |
| 469 return 1; | |
| 470 | |
| 471 int batch_limit = kDefaultTestBatchLimit; | 467 int batch_limit = kDefaultTestBatchLimit; |
| 472 if (!GetSwitchValueAsInt(switches::kTestLauncherBatchLimit, &batch_limit)) | 468 if (!GetSwitchValueAsInt(switches::kTestLauncherBatchLimit, &batch_limit)) |
| 473 return 1; | 469 return 1; |
| 474 | 470 |
| 475 fprintf(stdout, | 471 fprintf(stdout, |
| 476 "Starting tests (using %d parallel jobs)...\n" | |
| 477 "IMPORTANT DEBUGGING NOTE: batches of tests are run inside their\n" | 472 "IMPORTANT DEBUGGING NOTE: batches of tests are run inside their\n" |
| 478 "own process. For debugging a test inside a debugger, use the\n" | 473 "own process. For debugging a test inside a debugger, use the\n" |
| 479 "--gtest_filter=<your_test_name> flag along with\n" | 474 "--gtest_filter=<your_test_name> flag along with\n" |
| 480 "--single-process-tests.\n", jobs); | 475 "--single-process-tests.\n"); |
| 481 fflush(stdout); | 476 fflush(stdout); |
| 482 | 477 |
| 483 MessageLoopForIO message_loop; | 478 MessageLoopForIO message_loop; |
| 484 | 479 |
| 485 base::UnitTestLauncherDelegate delegate(batch_limit); | 480 base::UnitTestLauncherDelegate delegate(batch_limit); |
| 486 base::TestLauncher launcher(&delegate, jobs); | 481 base::TestLauncher launcher(&delegate, SysInfo::NumberOfProcessors()); |
| 487 bool success = launcher.Run(argc, argv); | 482 bool success = launcher.Run(argc, argv); |
| 488 | 483 |
| 489 fprintf(stdout, | 484 fprintf(stdout, |
| 490 "Tests took %" PRId64 " seconds.\n", | 485 "Tests took %" PRId64 " seconds.\n", |
| 491 (base::TimeTicks::Now() - start_time).InSeconds()); | 486 (base::TimeTicks::Now() - start_time).InSeconds()); |
| 492 fflush(stdout); | 487 fflush(stdout); |
| 493 | 488 |
| 494 return (success ? 0 : 1); | 489 return (success ? 0 : 1); |
| 495 } | 490 } |
| 496 | 491 |
| 497 } // namespace base | 492 } // namespace base |
| OLD | NEW |