| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <fcntl.h> | 5 #include <fcntl.h> |
| 6 #include <poll.h> | 6 #include <poll.h> |
| 7 #include <signal.h> | 7 #include <signal.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <sys/resource.h> | 9 #include <sys/resource.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #if !defined(POLLRDHUP) | 24 #if !defined(POLLRDHUP) |
| 25 #define POLLRDHUP 0x2000 | 25 #define POLLRDHUP 0x2000 |
| 26 #endif | 26 #endif |
| 27 | 27 |
| 28 namespace { | 28 namespace { |
| 29 std::string TestFailedMessage(const std::string& msg) { | 29 std::string TestFailedMessage(const std::string& msg) { |
| 30 return msg.empty() ? std::string() : "Actual test failure: " + msg; | 30 return msg.empty() ? std::string() : "Actual test failure: " + msg; |
| 31 } | 31 } |
| 32 | 32 |
| 33 int GetSubProcessTimeoutTimeInSeconds() { | 33 int GetSubProcessTimeoutTimeInSeconds() { |
| 34 // Previously 10s, but that timed out (just) on Chromecast. | 34 #ifdef NDEBUG |
| 35 return 12; | 35 // Chromecast build lab devices need this much time to complete. |
| 36 // They only run in release. |
| 37 return 30; |
| 38 #else |
| 39 // Want a shorter timeout than test runner to get a useful callstack |
| 40 // in debug. |
| 41 return 10; |
| 42 #endif |
| 36 } | 43 } |
| 37 | 44 |
| 38 // Returns the number of threads of the current process or -1. | 45 // Returns the number of threads of the current process or -1. |
| 39 int CountThreads() { | 46 int CountThreads() { |
| 40 struct stat task_stat; | 47 struct stat task_stat; |
| 41 int task_d = stat("/proc/self/task", &task_stat); | 48 int task_d = stat("/proc/self/task", &task_stat); |
| 42 // task_stat.st_nlink should be the number of tasks + 2 (accounting for | 49 // task_stat.st_nlink should be the number of tasks + 2 (accounting for |
| 43 // "." and "..". | 50 // "." and "..". |
| 44 if (task_d != 0 || task_stat.st_nlink < 3) | 51 if (task_d != 0 || task_stat.st_nlink < 3) |
| 45 return -1; | 52 return -1; |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 fflush(stderr); | 352 fflush(stderr); |
| 346 _exit(kExitWithAssertionFailure); | 353 _exit(kExitWithAssertionFailure); |
| 347 } | 354 } |
| 348 | 355 |
| 349 void UnitTests::IgnoreThisTest() { | 356 void UnitTests::IgnoreThisTest() { |
| 350 fflush(stderr); | 357 fflush(stderr); |
| 351 _exit(kIgnoreThisTest); | 358 _exit(kIgnoreThisTest); |
| 352 } | 359 } |
| 353 | 360 |
| 354 } // namespace | 361 } // namespace |
| OLD | NEW |