OLD | NEW |
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/mac host build of nacl_io can't do wrapping of syscalls so all | 5 // The linux/mac 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__) && !defined(__APPLE__) | 7 #if !defined(__linux__) && !defined(__APPLE__) |
8 | 8 |
9 #include <unistd.h> | 9 #include <unistd.h> |
10 | 10 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // Initialize the global errno value to a consistent value rather than | 143 // Initialize the global errno value to a consistent value rather than |
144 // relying on its value from previous test runs. | 144 // relying on its value from previous test runs. |
145 errno = 0; | 145 errno = 0; |
146 | 146 |
147 // Initializing the KernelProxy opens stdin/stdout/stderr. | 147 // Initializing the KernelProxy opens stdin/stdout/stderr. |
148 EXPECT_CALL(mock, open(_, _, _)) | 148 EXPECT_CALL(mock, open(_, _, _)) |
149 .WillOnce(Return(0)) | 149 .WillOnce(Return(0)) |
150 .WillOnce(Return(1)) | 150 .WillOnce(Return(1)) |
151 .WillOnce(Return(2)); | 151 .WillOnce(Return(2)); |
152 | 152 |
153 ASSERT_EQ(0, ki_push_state_for_testing()); | |
154 ASSERT_EQ(0, ki_init(&mock)); | |
155 | |
156 // We allow write to be called any number of times, and it forwards to | 153 // We allow write to be called any number of times, and it forwards to |
157 // _real_write. This prevents an infinite loop writing output if there is a | 154 // _real_write. This prevents an infinite loop writing output if there is a |
158 // failure. | 155 // failure. |
159 ON_CALL(mock, write(_, _, _)) | 156 ON_CALL(mock, write(_, _, _)) |
160 .WillByDefault(Invoke(this, &KernelWrapTest::DefaultWrite)); | 157 .WillByDefault(Invoke(this, &KernelWrapTest::DefaultWrite)); |
161 EXPECT_CALL(mock, write(_, _, _)).Times(AnyNumber()); | 158 EXPECT_CALL(mock, write(_, _, _)).Times(AnyNumber()); |
162 | 159 |
163 // Ignore calls to munmap. These can be generated from within the standard | 160 // Ignore calls to munmap. These can be generated from within the standard |
164 // library malloc implementation so can be expected at pretty much any time. | 161 // library malloc implementation so can be expected at pretty much any time. |
165 // Returning zero is fine since the real munmap see also run. | 162 // Returning zero is fine since the real munmap see also run. |
166 // See kernel_wrap_newlib.cc. | 163 // See kernel_wrap_newlib.cc. |
167 ON_CALL(mock, munmap(_, _)) | 164 ON_CALL(mock, munmap(_, _)) |
168 .WillByDefault(Return(0)); | 165 .WillByDefault(Return(0)); |
169 EXPECT_CALL(mock, munmap(_, _)).Times(AnyNumber()); | 166 EXPECT_CALL(mock, munmap(_, _)).Times(AnyNumber()); |
| 167 |
| 168 ASSERT_EQ(0, ki_push_state_for_testing()); |
| 169 ASSERT_EQ(0, ki_init(&mock)); |
170 } | 170 } |
171 | 171 |
172 void TearDown() { | 172 void TearDown() { |
173 // Uninitialize the kernel proxy so wrapped functions passthrough to their | 173 // Uninitialize the kernel proxy so wrapped functions passthrough to their |
174 // unwrapped versions. | 174 // unwrapped versions. |
175 ki_uninit(); | 175 ki_uninit(); |
176 } | 176 } |
177 | 177 |
178 MockKernelProxy mock; | 178 MockKernelProxy mock; |
179 | 179 |
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 .WillOnce(Return(0)) | 926 .WillOnce(Return(0)) |
927 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); | 927 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); |
928 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); | 928 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); |
929 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); | 929 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); |
930 EXPECT_EQ(kDummyErrno, errno); | 930 EXPECT_EQ(kDummyErrno, errno); |
931 } | 931 } |
932 | 932 |
933 #endif // PROVIDES_SOCKET_API | 933 #endif // PROVIDES_SOCKET_API |
934 | 934 |
935 #endif // __linux__ | 935 #endif // __linux__ |
OLD | NEW |