Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(551)

Side by Side Diff: base/test/launcher/unit_test_launcher.cc

Issue 101223009: GTTF: Make new test launcher automatically use single process mode when debugged. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | base/test/test_switches.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/debug/debugger.h"
11 #include "base/file_util.h" 12 #include "base/file_util.h"
12 #include "base/files/scoped_temp_dir.h" 13 #include "base/files/scoped_temp_dir.h"
13 #include "base/format_macros.h" 14 #include "base/format_macros.h"
14 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
15 #include "base/stl_util.h" 16 #include "base/stl_util.h"
16 #include "base/strings/string_number_conversions.h" 17 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
18 #include "base/sys_info.h" 19 #include "base/sys_info.h"
19 #include "base/test/gtest_xml_util.h" 20 #include "base/test/gtest_xml_util.h"
20 #include "base/test/launcher/test_launcher.h" 21 #include "base/test/launcher/test_launcher.h"
21 #include "base/test/test_switches.h" 22 #include "base/test/test_switches.h"
22 #include "base/test/test_timeouts.h" 23 #include "base/test/test_timeouts.h"
24 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
23 #include "base/threading/thread_checker.h" 25 #include "base/threading/thread_checker.h"
24 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
25 27
26 namespace base { 28 namespace base {
27 29
28 namespace { 30 namespace {
29 31
30 // This constant controls how many tests are run in a single batch by default. 32 // This constant controls how many tests are run in a single batch by default.
31 const size_t kDefaultTestBatchLimit = 10; 33 const size_t kDefaultTestBatchLimit = 10;
32 34
(...skipping 21 matching lines...) Expand all
54 " Sets the number of parallel test jobs to N.\n" 56 " Sets the number of parallel test jobs to N.\n"
55 "\n" 57 "\n"
56 " --single-process-tests\n" 58 " --single-process-tests\n"
57 " Runs the tests and the launcher in the same process. Useful\n" 59 " Runs the tests and the launcher in the same process. Useful\n"
58 " for debugging a specific test in a debugger.\n" 60 " for debugging a specific test in a debugger.\n"
59 "\n" 61 "\n"
60 " Other flags:\n" 62 " Other flags:\n"
61 " --test-launcher-batch-limit=N\n" 63 " --test-launcher-batch-limit=N\n"
62 " Sets the limit of test batch to run in a single process to N.\n" 64 " Sets the limit of test batch to run in a single process to N.\n"
63 "\n" 65 "\n"
66 " --test-launcher-debug-launcher\n"
67 " Disables autodetection of debuggers and similar tools,\n"
68 " making it possible to use them to debug launcher itself.\n"
69 "\n"
64 " --test-launcher-retry-limit=N\n" 70 " --test-launcher-retry-limit=N\n"
65 " Sets the limit of test retries on failures to N.\n" 71 " Sets the limit of test retries on failures to N.\n"
66 "\n" 72 "\n"
67 " --test-launcher-summary-output=PATH\n" 73 " --test-launcher-summary-output=PATH\n"
68 " Saves a JSON machine-readable summary of the run.\n" 74 " Saves a JSON machine-readable summary of the run.\n"
69 "\n" 75 "\n"
70 " --test-launcher-print-test-stdio=auto|always|never\n" 76 " --test-launcher-print-test-stdio=auto|always|never\n"
71 " Controls when full test output is printed.\n" 77 " Controls when full test output is printed.\n"
72 " auto means to print it when the test failed.\n" 78 " auto means to print it when the test failed.\n"
73 "\n" 79 "\n"
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 } 462 }
457 463
458 return true; 464 return true;
459 } 465 }
460 466
461 int LaunchUnitTestsInternal(int argc, 467 int LaunchUnitTestsInternal(int argc,
462 char** argv, 468 char** argv,
463 const RunTestSuiteCallback& run_test_suite, 469 const RunTestSuiteCallback& run_test_suite,
464 int default_jobs) { 470 int default_jobs) {
465 CommandLine::Init(argc, argv); 471 CommandLine::Init(argc, argv);
472
466 #if defined(OS_ANDROID) 473 #if defined(OS_ANDROID)
467 // We can't easily fork on Android, just run the test suite directly. 474 // We can't easily fork on Android, just run the test suite directly.
468 return run_test_suite.Run(); 475 return run_test_suite.Run();
469 #else 476 #else
477 bool force_single_process = false;
478 if (CommandLine::ForCurrentProcess()->HasSwitch(
479 switches::kTestLauncherDebugLauncher)) {
480 fprintf(stdout, "Forcing test launcher debugging mode.\n");
481 fflush(stdout);
482 } else {
483 if (base::debug::BeingDebugged()) {
484 fprintf(stdout,
485 "Debugger detected, switching to single process mode.\n"
486 "Pass --test-launcher-debug-launcher to debug the launcher "
487 "itself.\n");
488 fflush(stdout);
489 force_single_process = true;
490 }
491
492 if (RunningOnValgrind()) {
493 fprintf(stdout,
494 "Valgrind detected, switching to single process mode.\n"
495 "Pass --test-launcher-debug-launcher to valgrind the launcher "
496 "itself.\n");
497 fflush(stdout);
498 force_single_process = true;
499 }
500 }
501
470 if (CommandLine::ForCurrentProcess()->HasSwitch(kGTestHelpFlag) || 502 if (CommandLine::ForCurrentProcess()->HasSwitch(kGTestHelpFlag) ||
471 CommandLine::ForCurrentProcess()->HasSwitch(kSingleProcessTestsFlag)) { 503 CommandLine::ForCurrentProcess()->HasSwitch(kSingleProcessTestsFlag) ||
504 force_single_process) {
472 return run_test_suite.Run(); 505 return run_test_suite.Run();
473 } 506 }
474 #endif 507 #endif
475 508
476 if (CommandLine::ForCurrentProcess()->HasSwitch(kHelpFlag)) { 509 if (CommandLine::ForCurrentProcess()->HasSwitch(kHelpFlag)) {
477 PrintUsage(); 510 PrintUsage();
478 return 0; 511 return 0;
479 } 512 }
480 513
481 base::TimeTicks start_time(base::TimeTicks::Now()); 514 base::TimeTicks start_time(base::TimeTicks::Now());
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 argc, argv, run_test_suite, SysInfo::NumberOfProcessors()); 550 argc, argv, run_test_suite, SysInfo::NumberOfProcessors());
518 } 551 }
519 552
520 int LaunchUnitTestsSerially(int argc, 553 int LaunchUnitTestsSerially(int argc,
521 char** argv, 554 char** argv,
522 const RunTestSuiteCallback& run_test_suite) { 555 const RunTestSuiteCallback& run_test_suite) {
523 return LaunchUnitTestsInternal(argc, argv, run_test_suite, 1); 556 return LaunchUnitTestsInternal(argc, argv, run_test_suite, 1);
524 } 557 }
525 558
526 } // namespace base 559 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | base/test/test_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698