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

Unified Diff: dbus/message_unittest.cc

Issue 9700072: dbus: add support for passing file descriptors (Closed) Base URL: http://git.chromium.org/git/chromium/src@master
Patch Set: more review comments; fill-in unit test Created 8 years, 9 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 | « dbus/message.cc ('k') | dbus/values_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dbus/message_unittest.cc
diff --git a/dbus/message_unittest.cc b/dbus/message_unittest.cc
index a40ba0aa740f5538ec5b0c784020fa6587096616..92950469e32fe8a0866d15fdcb6361f589456bf4 100644
--- a/dbus/message_unittest.cc
+++ b/dbus/message_unittest.cc
@@ -94,6 +94,39 @@ TEST(MessageTest, AppendAndPopBasicDataTypes) {
EXPECT_EQ(dbus::ObjectPath("/object/path"), object_path_value);
}
+// Check all basic types can be properly written and read.
+TEST(MessageTest, AppendAndPopFileDescriptor) {
+ if (!dbus::kDBusTypeUnixFdIsSupported) {
+ LOG(WARNING) << "FD passing is not supported";
+ return;
+ }
+
+ scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty());
+ dbus::MessageWriter writer(message.get());
+
+ // Append stdout.
+ dbus::FileDescriptor temp(1);
+ writer.AppendFileDescriptor(temp);
+
+ dbus::FileDescriptor fd_value;
+
+ dbus::MessageReader reader(message.get());
+ ASSERT_TRUE(reader.HasMoreData());
+ ASSERT_TRUE(reader.PopFileDescriptor(&fd_value));
+ ASSERT_FALSE(reader.HasMoreData());
+
+ // Stdout should be returned but we cannot check the descriptor
+ // value because stdout will be dup'd. Instead check st_rdev
+ // which should be identical.
+ struct stat sb_stdout;
+ int status_stdout = ::fstat(1, &sb_stdout);
satorux1 2012/03/28 22:20:41 nit: is :: needed? wrapping it with HANDLE_EINTR
+ ASSERT_TRUE(status_stdout >= 0);
+ struct stat sb_fd;
+ int status_fd = ::fstat(fd_value.value(), &sb_fd);
+ ASSERT_TRUE(status_fd >= 0);
+ EXPECT_EQ(sb_stdout.st_rdev, sb_fd.st_rdev);
+}
+
// Check all variant types can be properly written and read.
TEST(MessageTest, AppendAndPopVariantDataTypes) {
scoped_ptr<dbus::Response> message(dbus::Response::CreateEmpty());
« no previous file with comments | « dbus/message.cc ('k') | dbus/values_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698