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

Side by Side Diff: native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc

Issue 1335783005: [NaCl SDK] nacl_io: Add support for basic socketpairs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Class renamed/cl-format applied. 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <pthread.h> 7 #include <pthread.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
1086 TEST_F(KernelProxyErrorTest, WriteError) { 1086 TEST_F(KernelProxyErrorTest, WriteError) {
1087 ScopedRef<MockFs> mock_fs(fs()); 1087 ScopedRef<MockFs> mock_fs(fs());
1088 ScopedRef<MockNode> mock_node(new MockNode(&*mock_fs)); 1088 ScopedRef<MockNode> mock_node(new MockNode(&*mock_fs));
1089 EXPECT_CALL(*mock_fs, OpenWithMode(_, _, _, _)) 1089 EXPECT_CALL(*mock_fs, OpenWithMode(_, _, _, _))
1090 .WillOnce(DoAll(SetArgPointee<3>(mock_node), Return(0))); 1090 .WillOnce(DoAll(SetArgPointee<3>(mock_node), Return(0)));
1091 1091
1092 EXPECT_CALL(*mock_node, Write(_, _, _, _)) 1092 EXPECT_CALL(*mock_node, Write(_, _, _, _))
1093 .WillOnce(DoAll(SetArgPointee<3>(0), // Wrote 0 bytes. 1093 .WillOnce(DoAll(SetArgPointee<3>(0), // Wrote 0 bytes.
1094 Return(1234))); // Returned error 1234. 1094 Return(1234))); // Returned error 1234.
1095 1095
1096 EXPECT_CALL(*mock_node, GetType()).WillRepeatedly(Return(S_IFDIR));
Sam Clegg 2015/09/22 17:53:44 Why is this change needed?
avallee 2015/09/22 20:25:06 I'll split this out to a separate CL, this was a c
1096 EXPECT_CALL(*mock_node, IsaDir()).Times(1); 1097 EXPECT_CALL(*mock_node, IsaDir()).Times(1);
1097 EXPECT_CALL(*mock_node, Destroy()).Times(1); 1098 EXPECT_CALL(*mock_node, Destroy()).Times(1);
1098 1099
1099 int fd = ki_open("/dummy", O_WRONLY, 0); 1100 int fd = ki_open("/dummy", O_WRONLY, 0);
1100 EXPECT_NE(0, fd); 1101 EXPECT_NE(0, fd);
1101 1102
1102 char buf[20]; 1103 char buf[20];
1103 EXPECT_EQ(-1, ki_write(fd, &buf[0], 20)); 1104 EXPECT_EQ(-1, ki_write(fd, &buf[0], 20));
1104 // The Filesystem should be able to return whatever error it wants and have it 1105 // The Filesystem should be able to return whatever error it wants and have it
1105 // propagate through. 1106 // propagate through.
1106 EXPECT_EQ(1234, errno); 1107 EXPECT_EQ(1234, errno);
1107 } 1108 }
1108 1109
1109 TEST_F(KernelProxyErrorTest, ReadError) { 1110 TEST_F(KernelProxyErrorTest, ReadError) {
1110 ScopedRef<MockFs> mock_fs(fs()); 1111 ScopedRef<MockFs> mock_fs(fs());
1111 ScopedRef<MockNode> mock_node(new MockNode(&*mock_fs)); 1112 ScopedRef<MockNode> mock_node(new MockNode(&*mock_fs));
1112 EXPECT_CALL(*mock_fs, OpenWithMode(_, _, _, _)) 1113 EXPECT_CALL(*mock_fs, OpenWithMode(_, _, _, _))
1113 .WillOnce(DoAll(SetArgPointee<3>(mock_node), Return(0))); 1114 .WillOnce(DoAll(SetArgPointee<3>(mock_node), Return(0)));
1114 1115
1115 EXPECT_CALL(*mock_node, Read(_, _, _, _)) 1116 EXPECT_CALL(*mock_node, Read(_, _, _, _))
1116 .WillOnce(DoAll(SetArgPointee<3>(0), // Read 0 bytes. 1117 .WillOnce(DoAll(SetArgPointee<3>(0), // Read 0 bytes.
1117 Return(1234))); // Returned error 1234. 1118 Return(1234))); // Returned error 1234.
1118 1119
1120 EXPECT_CALL(*mock_node, GetType()).WillRepeatedly(Return(S_IFDIR));
1119 EXPECT_CALL(*mock_node, Destroy()).Times(1); 1121 EXPECT_CALL(*mock_node, Destroy()).Times(1);
1120 1122
1121 int fd = ki_open("/dummy", O_RDONLY, 0); 1123 int fd = ki_open("/dummy", O_RDONLY, 0);
1122 EXPECT_NE(0, fd); 1124 EXPECT_NE(0, fd);
1123 1125
1124 char buf[20]; 1126 char buf[20];
1125 EXPECT_EQ(-1, ki_read(fd, &buf[0], 20)); 1127 EXPECT_EQ(-1, ki_read(fd, &buf[0], 20));
1126 // The Filesystem should be able to return whatever error it wants and have it 1128 // The Filesystem should be able to return whatever error it wants and have it
1127 // propagate through. 1129 // propagate through.
1128 EXPECT_EQ(1234, errno); 1130 EXPECT_EQ(1234, errno);
1129 } 1131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698