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

Unified Diff: util/mach/mach_extensions_test.cc

Issue 1305893010: Don’t trigger EXC_CORPSE_NOTIFY on OS X 10.11 (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 5 years, 3 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 | « util/mach/mach_extensions.cc ('k') | util/mach/symbolic_constants_mach.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/mach/mach_extensions_test.cc
diff --git a/util/mach/mach_extensions_test.cc b/util/mach/mach_extensions_test.cc
index aefe489d1bf993ad2f96c11fc2210402e7a2db09..9853944cb969875be186042a05e87dbf6badaf14 100644
--- a/util/mach/mach_extensions_test.cc
+++ b/util/mach/mach_extensions_test.cc
@@ -17,6 +17,7 @@
#include "base/mac/scoped_mach_port.h"
#include "gtest/gtest.h"
#include "test/mac/mach_errors.h"
+#include "util/mac/mac_util.h"
namespace crashpad {
namespace test {
@@ -60,6 +61,76 @@ TEST(MachExtensions, NewMachPort_DeadName) {
EXPECT_EQ(MACH_PORT_TYPE_DEAD_NAME, type);
}
+const exception_mask_t kExcMaskBasic =
+ EXC_MASK_BAD_ACCESS |
+ EXC_MASK_BAD_INSTRUCTION |
+ EXC_MASK_ARITHMETIC |
+ EXC_MASK_EMULATION |
+ EXC_MASK_SOFTWARE |
+ EXC_MASK_BREAKPOINT |
+ EXC_MASK_SYSCALL |
+ EXC_MASK_MACH_SYSCALL |
+ EXC_MASK_RPC_ALERT;
+
+TEST(MachExtensions, ExcMaskAll) {
+ const exception_mask_t exc_mask_all = ExcMaskAll();
+ EXPECT_EQ(kExcMaskBasic, exc_mask_all & kExcMaskBasic);
+
+ EXPECT_FALSE(exc_mask_all & EXC_MASK_CRASH);
+ EXPECT_FALSE(exc_mask_all & EXC_MASK_CORPSE_NOTIFY);
+
+ const int mac_os_x_minor_version = MacOSXMinorVersion();
+ if (mac_os_x_minor_version >= 8) {
+ EXPECT_TRUE(exc_mask_all & EXC_MASK_RESOURCE);
+ } else {
+ EXPECT_FALSE(exc_mask_all & EXC_MASK_RESOURCE);
+ }
+
+ if (mac_os_x_minor_version >= 9) {
+ EXPECT_TRUE(exc_mask_all & EXC_MASK_GUARD);
+ } else {
+ EXPECT_FALSE(exc_mask_all & EXC_MASK_GUARD);
+ }
+
+ // Bit 0 should not be set.
+ EXPECT_FALSE(ExcMaskAll() & 1);
+
+ // Every bit set in ExcMaskAll() must also be set in ExcMaskValid().
+ EXPECT_EQ(ExcMaskAll(), ExcMaskAll() & ExcMaskValid());
+}
+
+TEST(MachExtensions, ExcMaskValid) {
+ const exception_mask_t exc_mask_valid = ExcMaskValid();
+ EXPECT_EQ(kExcMaskBasic, exc_mask_valid & kExcMaskBasic);
+
+ EXPECT_TRUE(exc_mask_valid & EXC_MASK_CRASH);
+
+ const int mac_os_x_minor_version = MacOSXMinorVersion();
+ if (mac_os_x_minor_version >= 8) {
+ EXPECT_TRUE(exc_mask_valid & EXC_MASK_RESOURCE);
+ } else {
+ EXPECT_FALSE(exc_mask_valid & EXC_MASK_RESOURCE);
+ }
+
+ if (mac_os_x_minor_version >= 9) {
+ EXPECT_TRUE(exc_mask_valid & EXC_MASK_GUARD);
+ } else {
+ EXPECT_FALSE(exc_mask_valid & EXC_MASK_GUARD);
+ }
+
+ if (mac_os_x_minor_version >= 11) {
+ EXPECT_TRUE(exc_mask_valid & EXC_MASK_CORPSE_NOTIFY);
+ } else {
+ EXPECT_FALSE(exc_mask_valid & EXC_MASK_CORPSE_NOTIFY);
+ }
+
+ // Bit 0 should not be set.
+ EXPECT_FALSE(ExcMaskValid() & 1);
+
+ // There must be bits set in ExcMaskValid() that are not set in ExcMaskAll().
+ EXPECT_TRUE(ExcMaskValid() & ~ExcMaskAll());
+}
+
} // namespace
} // namespace test
} // namespace crashpad
« no previous file with comments | « util/mach/mach_extensions.cc ('k') | util/mach/symbolic_constants_mach.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698