Chromium Code Reviews| 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/test_launcher.h" | 5 #include "base/test/launcher/test_launcher.h" |
| 6 | 6 |
| 7 #if defined(OS_POSIX) | 7 #if defined(OS_POSIX) |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 // Maximum time of no output after which we print list of processes still | 69 // Maximum time of no output after which we print list of processes still |
| 70 // running. This deliberately doesn't use TestTimeouts (which is otherwise | 70 // running. This deliberately doesn't use TestTimeouts (which is otherwise |
| 71 // a recommended solution), because they can be increased. This would defeat | 71 // a recommended solution), because they can be increased. This would defeat |
| 72 // the purpose of this timeout, which is 1) to avoid buildbot "no output for | 72 // the purpose of this timeout, which is 1) to avoid buildbot "no output for |
| 73 // X seconds" timeout killing the process 2) help communicate status of | 73 // X seconds" timeout killing the process 2) help communicate status of |
| 74 // the test launcher to people looking at the output (no output for a long | 74 // the test launcher to people looking at the output (no output for a long |
| 75 // time is mysterious and gives no info about what is happening) 3) help | 75 // time is mysterious and gives no info about what is happening) 3) help |
| 76 // debugging in case the process hangs anyway. | 76 // debugging in case the process hangs anyway. |
| 77 const int kOutputTimeoutSeconds = 15; | 77 const int kOutputTimeoutSeconds = 15; |
| 78 | 78 |
| 79 // Limit of output snippet lines when printing to stdout. | |
| 80 // Avoids flooding the logs with amount of output that gums up | |
| 81 // the infrastructure. | |
| 82 const size_t kOutputSnippetLinesLimit = 50; | |
| 83 | |
| 79 // Set of live launch test processes with corresponding lock (it is allowed | 84 // Set of live launch test processes with corresponding lock (it is allowed |
| 80 // for callers to launch processes on different threads). | 85 // for callers to launch processes on different threads). |
| 81 LazyInstance<std::map<ProcessHandle, CommandLine> > g_live_processes | 86 LazyInstance<std::map<ProcessHandle, CommandLine> > g_live_processes |
| 82 = LAZY_INSTANCE_INITIALIZER; | 87 = LAZY_INSTANCE_INITIALIZER; |
| 83 LazyInstance<Lock> g_live_processes_lock = LAZY_INSTANCE_INITIALIZER; | 88 LazyInstance<Lock> g_live_processes_lock = LAZY_INSTANCE_INITIALIZER; |
| 84 | 89 |
| 85 #if defined(OS_POSIX) | 90 #if defined(OS_POSIX) |
| 86 // Self-pipe that makes it possible to do complex shutdown handling | 91 // Self-pipe that makes it possible to do complex shutdown handling |
| 87 // outside of the signal handler. | 92 // outside of the signal handler. |
| 88 int g_shutdown_pipe[2] = { -1, -1 }; | 93 int g_shutdown_pipe[2] = { -1, -1 }; |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 444 print_snippet = (result.status != TestResult::TEST_SUCCESS); | 449 print_snippet = (result.status != TestResult::TEST_SUCCESS); |
| 445 } else if (print_test_stdio == "always") { | 450 } else if (print_test_stdio == "always") { |
| 446 print_snippet = true; | 451 print_snippet = true; |
| 447 } else if (print_test_stdio == "never") { | 452 } else if (print_test_stdio == "never") { |
| 448 print_snippet = false; | 453 print_snippet = false; |
| 449 } else { | 454 } else { |
| 450 LOG(WARNING) << "Invalid value of " << switches::kTestLauncherPrintTestStdio | 455 LOG(WARNING) << "Invalid value of " << switches::kTestLauncherPrintTestStdio |
| 451 << ": " << print_test_stdio; | 456 << ": " << print_test_stdio; |
| 452 } | 457 } |
| 453 if (print_snippet) { | 458 if (print_snippet) { |
| 454 fprintf(stdout, "%s", result.output_snippet.c_str()); | 459 std::vector<std::string> snippet_lines; |
|
sky
2014/06/10 16:25:14
This initially confused me. I would have thought y
| |
| 460 SplitString(result.output_snippet, '\n', &snippet_lines); | |
| 461 if (snippet_lines.size() > kOutputSnippetLinesLimit) { | |
| 462 size_t truncated_size = snippet_lines.size() - kOutputSnippetLinesLimit; | |
| 463 snippet_lines.erase( | |
| 464 snippet_lines.begin(), | |
| 465 snippet_lines.begin() + truncated_size); | |
| 466 snippet_lines.insert(snippet_lines.begin(), "<truncated>"); | |
| 467 } | |
| 468 fprintf(stdout, "%s", JoinString(snippet_lines, "\n").c_str()); | |
| 455 fflush(stdout); | 469 fflush(stdout); |
| 456 } | 470 } |
| 457 | 471 |
| 458 if (result.status == TestResult::TEST_SUCCESS) { | 472 if (result.status == TestResult::TEST_SUCCESS) { |
| 459 ++test_success_count_; | 473 ++test_success_count_; |
| 460 } else { | 474 } else { |
| 461 tests_to_retry_.insert(result.full_name); | 475 tests_to_retry_.insert(result.full_name); |
| 462 } | 476 } |
| 463 | 477 |
| 464 // TODO(phajdan.jr): Flag unreliable unknown results, unless passed on retry. | 478 // TODO(phajdan.jr): Flag unreliable unknown results, unless passed on retry. |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1073 | 1087 |
| 1074 g_live_processes.Get().erase(process_handle); | 1088 g_live_processes.Get().erase(process_handle); |
| 1075 } | 1089 } |
| 1076 | 1090 |
| 1077 base::CloseProcessHandle(process_handle); | 1091 base::CloseProcessHandle(process_handle); |
| 1078 | 1092 |
| 1079 return exit_code; | 1093 return exit_code; |
| 1080 } | 1094 } |
| 1081 | 1095 |
| 1082 } // namespace base | 1096 } // namespace base |
| OLD | NEW |