Fix mac build.
Test: Builds on mac/linux.
Test: Ran unit tests on mac/linux.
Change-Id: Ie89c2d8ac52a4df42e63ae0968f672482d2730f6
diff --git a/Isolate.cpp b/Isolate.cpp
index 1c2b73e..3eb63ac 100644
--- a/Isolate.cpp
+++ b/Isolate.cpp
@@ -48,7 +48,7 @@
}
static void RegisterSignalHandler() {
- sighandler_t ret = signal(SIGINT, SignalHandler);
+ auto ret = signal(SIGINT, SignalHandler);
if (ret == SIG_ERR) {
PLOG(FATAL) << "Setting up SIGINT handler failed";
}
@@ -59,7 +59,7 @@
}
static void UnregisterSignalHandler() {
- sighandler_t ret = signal(SIGINT, SIG_DFL);
+ auto ret = signal(SIGINT, SIG_DFL);
if (ret == SIG_ERR) {
PLOG(FATAL) << "Disabling SIGINT handler failed";
}
@@ -89,7 +89,11 @@
command += " --gtest_filter=" + options_.filter();
}
command += " --gtest_list_tests";
+#if defined(__APPLE__)
+ FILE* fp = popen(command.c_str(), "r");
+#else
FILE* fp = popen(command.c_str(), "re");
+#endif
if (fp == nullptr) {
PLOG(FATAL) << "Unexpected failure from popen";
}
diff --git a/tests/SystemTests.cpp b/tests/SystemTests.cpp
index aa90906..61b0f13 100644
--- a/tests/SystemTests.cpp
+++ b/tests/SystemTests.cpp
@@ -87,8 +87,12 @@
void SystemTests::Exec(std::vector<const char*> args) {
int fds[2];
+#if !defined(__APPLE__)
ASSERT_NE(-1, pipe2(fds, O_NONBLOCK));
+#else
+ ASSERT_NE(-1, pipe(fds));
ASSERT_NE(-1, fcntl(fds[0], F_SETFL, O_NONBLOCK));
+#endif
if ((pid_ = fork()) == 0) {
// Run the test.
@@ -416,7 +420,11 @@
std::string expected =
"[==========] Running 1 test from 1 test case (20 jobs).\n"
"[ FAILED ] SystemTests.DISABLED_crash (XX ms)\n"
+#if defined(__APPLE__)
+ "SystemTests.DISABLED_crash terminated by signal: Segmentation fault: 11.\n"
+#else
"SystemTests.DISABLED_crash terminated by signal: Segmentation fault.\n"
+#endif
"[==========] 1 test from 1 test case ran. (XX ms total)\n"
"[ PASS ] 0 tests.\n"
"[ FAIL ] 1 test, listed below:\n"