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

Unified Diff: util/mach/mach_extensions_test.cc

Issue 809103002: Add NewMachPort() and its test, and switch call sites to use it (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Address review feedback Created 6 years 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/mach_message_server_test.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 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
« no previous file with comments | « util/mach/mach_extensions.cc ('k') | util/mach/mach_message_server_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698