Index: util/mach/mach_extensions_test.cc |
diff --git a/util/mach/mach_extensions_test.cc b/util/mach/mach_extensions_test.cc |
index 9334d30ad574ee548d62499e1c33593847da8aaf..d3faebdf27fd4939861ca4e8d509286ae829566d 100644 |
--- a/util/mach/mach_extensions_test.cc |
+++ b/util/mach/mach_extensions_test.cc |
@@ -16,6 +16,7 @@ |
#include "base/mac/scoped_mach_port.h" |
#include "gtest/gtest.h" |
+#include "util/test/mac/mach_errors.h" |
namespace crashpad { |
namespace test { |
@@ -26,6 +27,39 @@ TEST(MachExtensions, MachThreadSelf) { |
EXPECT_EQ(thread_self, MachThreadSelf()); |
} |
+TEST(MachExtensions, NewMachPort_Receive) { |
+ base::mac::ScopedMachReceiveRight port(NewMachPort(MACH_PORT_RIGHT_RECEIVE)); |
+ ASSERT_NE(kMachPortNull, port); |
+ |
+ mach_port_type_t type; |
+ kern_return_t kr = mach_port_type(mach_task_self(), port, &type); |
+ ASSERT_EQ(KERN_SUCCESS, kr) << MachErrorMessage(kr, "mach_port_get_type"); |
+ |
+ EXPECT_EQ(MACH_PORT_TYPE_RECEIVE, type); |
+} |
+ |
+TEST(MachExtensions, NewMachPort_PortSet) { |
+ base::mac::ScopedMachPortSet port(NewMachPort(MACH_PORT_RIGHT_PORT_SET)); |
+ ASSERT_NE(kMachPortNull, port); |
+ |
+ mach_port_type_t type; |
+ kern_return_t kr = mach_port_type(mach_task_self(), port, &type); |
+ ASSERT_EQ(KERN_SUCCESS, kr) << MachErrorMessage(kr, "mach_port_get_type"); |
+ |
+ EXPECT_EQ(MACH_PORT_TYPE_PORT_SET, type); |
+} |
+ |
+TEST(MachExtensions, NewMachPort_DeadName) { |
+ base::mac::ScopedMachSendRight port(NewMachPort(MACH_PORT_RIGHT_DEAD_NAME)); |
+ ASSERT_NE(kMachPortNull, port); |
+ |
+ mach_port_type_t type; |
+ kern_return_t kr = mach_port_type(mach_task_self(), port, &type); |
+ ASSERT_EQ(KERN_SUCCESS, kr) << MachErrorMessage(kr, "mach_port_get_type"); |
+ |
+ EXPECT_EQ(MACH_PORT_TYPE_DEAD_NAME, type); |
+} |
+ |
} // namespace |
} // namespace test |
} // namespace crashpad |