Chromium Code Reviews| Index: sandbox/linux/tests/unit_tests.cc |
| diff --git a/sandbox/linux/tests/unit_tests.cc b/sandbox/linux/tests/unit_tests.cc |
| index 5872e94030e143da76d49f3cd3035bf01d11cd2d..6a8ace39502bd903a1d4e976f861a773847a9384 100644 |
| --- a/sandbox/linux/tests/unit_tests.cc |
| +++ b/sandbox/linux/tests/unit_tests.cc |
| @@ -7,6 +7,8 @@ |
| #include <signal.h> |
| #include <stdio.h> |
| #include <sys/resource.h> |
| +#include <sys/types.h> |
| +#include <sys/wait.h> |
| #include <sys/time.h> |
| #include <time.h> |
| #include <unistd.h> |
| @@ -18,6 +20,10 @@ |
| #include "build/build_config.h" |
| #include "sandbox/linux/tests/unit_tests.h" |
| +#if !defined(POLLRDHUP) |
| +#define POLLRDHUP 0x2000 |
|
Mark Seaborn
2015/05/12 18:07:37
See other comment: It would be nice to put this in
hidehiko
2015/05/13 05:43:15
Done.
|
| +#endif |
| + |
| namespace { |
| std::string TestFailedMessage(const std::string& msg) { |
| return msg.empty() ? std::string() : "Actual test failure: " + msg; |
| @@ -67,14 +73,19 @@ bool IsRunningOnValgrind() { return RUNNING_ON_VALGRIND; } |
| static const int kExpectedValue = 42; |
| static const int kIgnoreThisTest = 43; |
| static const int kExitWithAssertionFailure = 1; |
| +#if !defined(OS_NACL_NONSFI) |
| static const int kExitForTimeout = 2; |
| +#endif |
| -#if !defined(OS_ANDROID) |
| +#if !defined(OS_ANDROID) && !defined(OS_NACL_NONSFI) |
| // This is due to StackDumpSignalHandler() performing _exit(1). |
| // TODO(jln): get rid of the collision with kExitWithAssertionFailure. |
| const int kExitAfterSIGSEGV = 1; |
| #endif |
| +// PNaCl toolchain's signal ABIs are incompatible with Linux's. |
| +// So, for simplicity, just drop the "timeout" feature from unittest framework. |
|
Mark Seaborn
2015/05/12 18:07:37
You might say that we'll rely on Buildbot's timeou
hidehiko
2015/05/13 05:43:15
Done.
|
| +#if !defined(OS_NACL_NONSFI) |
| static void SigAlrmHandler(int) { |
| const char failure_message[] = "Timeout reached!\n"; |
| // Make sure that we never block here. |
| @@ -106,6 +117,7 @@ static void SetProcessTimeout(int time_in_seconds) { |
| SANDBOX_ASSERT(alarm(time_in_seconds) == 0); // There should be no previous |
| // alarm. |
| } |
| +#endif // !defined(OS_NACL_NONSFI) |
| // Runs a test in a sub-process. This is necessary for most of the code |
| // in the BPF sandbox, as it potentially makes global state changes and as |
| @@ -163,7 +175,9 @@ void UnitTests::RunTestInProcess(SandboxTestRunner* test_runner, |
| // Don't set a timeout if running on Valgrind, since it's generally much |
| // slower. |
| if (!IsRunningOnValgrind()) { |
| +#if !defined(OS_NACL_NONSFI) |
| SetProcessTimeout(GetSubProcessTimeoutTimeInSeconds()); |
| +#endif |
| } |
| // Disable core files. They are not very useful for our individual test |
| @@ -282,7 +296,7 @@ void UnitTests::DeathSEGVMessage(int status, |
| std::string details(TestFailedMessage(msg)); |
| const char* expected_msg = static_cast<const char*>(aux); |
| -#if defined(OS_ANDROID) |
| +#if defined(OS_ANDROID) || defined(OS_NACL_NONSFI) |
| const bool subprocess_got_sigsegv = |
| WIFSIGNALED(status) && (SIGSEGV == WTERMSIG(status)); |
| #else |