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

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

Issue 565763002: Plumbing though mode parameter to open, since fusefs can make use of it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 // The linux host build of nacl_io can't do wrapping of syscalls so all 5 // The linux host build of nacl_io can't do wrapping of syscalls so all
6 // these tests must be disabled. 6 // these tests must be disabled.
7 #if !defined(__linux__) 7 #if !defined(__linux__)
8 8
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 class KernelWrapTest : public ::testing::Test { 120 class KernelWrapTest : public ::testing::Test {
121 public: 121 public:
122 KernelWrapTest() {} 122 KernelWrapTest() {}
123 123
124 virtual void SetUp() { 124 virtual void SetUp() {
125 // Initialize the global errno value to a consistent value rather than 125 // Initialize the global errno value to a consistent value rather than
126 // relying on its value from previous test runs. 126 // relying on its value from previous test runs.
127 errno = 0; 127 errno = 0;
128 128
129 // Initializing the KernelProxy opens stdin/stdout/stderr. 129 // Initializing the KernelProxy opens stdin/stdout/stderr.
130 EXPECT_CALL(mock, open(_, _)) 130 EXPECT_CALL(mock, open(_, _, _))
131 .WillOnce(Return(0)) 131 .WillOnce(Return(0))
132 .WillOnce(Return(1)) 132 .WillOnce(Return(1))
133 .WillOnce(Return(2)); 133 .WillOnce(Return(2));
134 134
135 ASSERT_EQ(0, ki_push_state_for_testing()); 135 ASSERT_EQ(0, ki_push_state_for_testing());
136 ASSERT_EQ(0, ki_init(&mock)); 136 ASSERT_EQ(0, ki_init(&mock));
137 137
138 // We allow write to be called any number of times, and it forwards to 138 // We allow write to be called any number of times, and it forwards to
139 // _real_write. This prevents an infinite loop writing output if there is a 139 // _real_write. This prevents an infinite loop writing output if there is a
140 // failure. 140 // failure.
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // one. The result returned is from the "real" mmap. 443 // one. The result returned is from the "real" mmap.
444 int dummy1 = 123; 444 int dummy1 = 123;
445 void* kDummyVoidPtr = &dummy1; 445 void* kDummyVoidPtr = &dummy1;
446 size_t kDummySizeT = sizeof(kDummyVoidPtr); 446 size_t kDummySizeT = sizeof(kDummyVoidPtr);
447 EXPECT_CALL(mock, munmap(kDummyVoidPtr, kDummySizeT)); 447 EXPECT_CALL(mock, munmap(kDummyVoidPtr, kDummySizeT));
448 munmap(kDummyVoidPtr, kDummySizeT); 448 munmap(kDummyVoidPtr, kDummySizeT);
449 } 449 }
450 450
451 TEST_F(KernelWrapTest, open) { 451 TEST_F(KernelWrapTest, open) {
452 // We pass O_RDONLY because we do not want an error in flags translation 452 // We pass O_RDONLY because we do not want an error in flags translation
453 EXPECT_CALL(mock, open(kDummyConstChar, 0)) 453 EXPECT_CALL(mock, open(kDummyConstChar, 0, 0))
454 .WillOnce(Return(kDummyInt2)) 454 .WillOnce(Return(kDummyInt2))
455 .WillOnce(Return(kDummyInt2)); 455 .WillOnce(Return(kDummyInt2));
456 456
457 EXPECT_EQ(kDummyInt2, open(kDummyConstChar, 0)); 457 EXPECT_EQ(kDummyInt2, open(kDummyConstChar, 0, 0));
458 EXPECT_EQ(kDummyInt2, open(kDummyConstChar, 0)); 458 EXPECT_EQ(kDummyInt2, open(kDummyConstChar, 0, 0));
459 } 459 }
460 460
461 TEST_F(KernelWrapTest, pipe) { 461 TEST_F(KernelWrapTest, pipe) {
462 int fds[] = {1, 2}; 462 int fds[] = {1, 2};
463 EXPECT_CALL(mock, pipe(fds)).WillOnce(Return(kDummyInt)); 463 EXPECT_CALL(mock, pipe(fds)).WillOnce(Return(kDummyInt));
464 EXPECT_EQ(kDummyInt, pipe(fds)); 464 EXPECT_EQ(kDummyInt, pipe(fds));
465 } 465 }
466 466
467 TEST_F(KernelWrapTest, read) { 467 TEST_F(KernelWrapTest, read) {
468 int dummy_value; 468 int dummy_value;
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 .WillOnce(Return(0)) 893 .WillOnce(Return(0))
894 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); 894 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1)));
895 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); 895 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val));
896 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); 896 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val));
897 EXPECT_EQ(kDummyErrno, errno); 897 EXPECT_EQ(kDummyErrno, errno);
898 } 898 }
899 899
900 #endif // PROVIDES_SOCKET_API 900 #endif // PROVIDES_SOCKET_API
901 901
902 #endif // __linux__ 902 #endif // __linux__
OLDNEW
« no previous file with comments | « native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc ('k') | native_client_sdk/src/tests/nacl_io_test/mock_fs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698