From 14c714c96c6f5281ab5f2695f4fcab2a80fc517d Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Wed, 10 Feb 2016 18:27:24 +0100
Subject: [PATCH] Make testdebugallocator_fail{1,4,5} pass on OS X

mprotect violations are required to lead to a SIGSEGV on Linux.
OS X is more permissive, allowing for both SIGSEGV and SIGBUS.

And practice, the tests generate a SIGBUS for me, causing the tests to
fail. Confusingly, ctest describes the problem as

  Exception: SegFault

which I assume they use as a catch-all term.
---
 dune/common/test/CMakeLists.txt        | 6 +++---
 dune/common/test/testdebugallocator.cc | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/dune/common/test/CMakeLists.txt b/dune/common/test/CMakeLists.txt
index e8a111f62..91dbfc662 100644
--- a/dune/common/test/CMakeLists.txt
+++ b/dune/common/test/CMakeLists.txt
@@ -116,7 +116,7 @@ dune_add_test(SOURCES testdebugallocator.cc
 dune_add_test(NAME testdebugallocator_fail1
               SOURCES testdebugallocator.cc
               LINK_LIBRARIES dunecommon
-              COMPILE_DEFINITIONS "FAILURE1;EXPECTED_SIGNAL=SIGSEGV"
+              COMPILE_DEFINITIONS "FAILURE1;EXPECTED_SIGNAL=SIGSEGV;EXPECTED_ALT_SIGNAL=SIGBUS"
               EXPECT_FAIL)
 
 dune_add_test(NAME testdebugallocator_fail2
@@ -134,13 +134,13 @@ dune_add_test(NAME testdebugallocator_fail3
 dune_add_test(NAME testdebugallocator_fail4
               SOURCES testdebugallocator.cc
               LINK_LIBRARIES dunecommon
-              COMPILE_DEFINITIONS "FAILURE4;DEBUG_ALLOCATOR_KEEP=1;EXPECTED_SIGNAL=SIGSEGV"
+              COMPILE_DEFINITIONS "FAILURE4;DEBUG_ALLOCATOR_KEEP=1;EXPECTED_SIGNAL=SIGSEGV;EXPECTED_ALT_SIGNAL=SIGBUS"
               EXPECT_FAIL)
 
 dune_add_test(NAME testdebugallocator_fail5
               SOURCES testdebugallocator.cc
               LINK_LIBRARIES dunecommon
-              COMPILE_DEFINITIONS "FAILURE5;EXPECTED_SIGNAL=SIGSEGV"
+              COMPILE_DEFINITIONS "FAILURE5;EXPECTED_SIGNAL=SIGSEGV;EXPECTED_ALT_SIGNAL=SIGBUS"
               EXPECT_FAIL)
 
 dune_add_test(SOURCES testfloatcmp.cc)
diff --git a/dune/common/test/testdebugallocator.cc b/dune/common/test/testdebugallocator.cc
index 1fd7a357e..dd7107f9c 100644
--- a/dune/common/test/testdebugallocator.cc
+++ b/dune/common/test/testdebugallocator.cc
@@ -93,6 +93,9 @@ int main(int, char**)
 #if EXPECTED_SIGNAL
   std::signal(EXPECTED_SIGNAL, std::_Exit);
 #endif
+#if EXPECTED_ALT_SIGNAL
+  std::signal(EXPECTED_ALT_SIGNAL, std::_Exit);
+#endif
 
   basic_tests();
   allocator_tests();
-- 
GitLab