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

Unified Diff: sandbox/linux/tests/unit_tests.cc

Issue 1133483002: WIP: Non-SFI mode: Enable nacl_helper_nonsfi_unittests. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/system_headers/arm_linux_syscalls.h ('k') | sandbox/sandbox_nacl_nonsfi.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..19ef03cb90612d92401a2b936be7c54d9bab5906 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
+#endif
+
namespace {
std::string TestFailedMessage(const std::string& msg) {
return msg.empty() ? std::string() : "Actual test failure: " + msg;
@@ -67,14 +73,20 @@ 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, we just drop the "timeout" feature from unittest
+// framework.
+#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 +118,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
@@ -162,9 +175,11 @@ void UnitTests::RunTestInProcess(SandboxTestRunner* test_runner,
// Don't set a timeout if running on Valgrind, since it's generally much
// slower.
+#if !defined(OS_NACL_NONSFI)
if (!IsRunningOnValgrind()) {
SetProcessTimeout(GetSubProcessTimeoutTimeInSeconds());
}
+#endif
// Disable core files. They are not very useful for our individual test
// cases.
@@ -282,7 +297,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
« no previous file with comments | « sandbox/linux/system_headers/arm_linux_syscalls.h ('k') | sandbox/sandbox_nacl_nonsfi.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698