| 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 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 | 503 |
| 504 EXPECT_CALL(mock, readlink(kDummyConstChar, buf, 10)) | 504 EXPECT_CALL(mock, readlink(kDummyConstChar, buf, 10)) |
| 505 .WillOnce(Return(kDummyInt)) | 505 .WillOnce(Return(kDummyInt)) |
| 506 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); | 506 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); |
| 507 | 507 |
| 508 EXPECT_EQ(kDummyInt, readlink(kDummyConstChar, buf, 10)); | 508 EXPECT_EQ(kDummyInt, readlink(kDummyConstChar, buf, 10)); |
| 509 EXPECT_EQ(-1, readlink(kDummyConstChar, buf, 10)); | 509 EXPECT_EQ(-1, readlink(kDummyConstChar, buf, 10)); |
| 510 ASSERT_EQ(kDummyErrno, errno); | 510 ASSERT_EQ(kDummyErrno, errno); |
| 511 } | 511 } |
| 512 | 512 |
| 513 #ifdef __GLIBC__ | |
| 514 // Under newlib there is no remove syscall. Instead it is implemented | |
| 515 // in terms of unlink()/rmdir(). | |
| 516 TEST_F(KernelWrapTest, remove) { | 513 TEST_F(KernelWrapTest, remove) { |
| 517 EXPECT_CALL(mock, remove(kDummyConstChar)).WillOnce(Return(-1)); | 514 // The remove syscall is not directly intercepted. Instead it is implemented |
| 515 // in terms of unlink()/rmdir(). |
| 516 EXPECT_CALL(mock, unlink(kDummyConstChar)) |
| 517 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); |
| 518 EXPECT_EQ(-1, remove(kDummyConstChar)); | 518 EXPECT_EQ(-1, remove(kDummyConstChar)); |
| 519 } | 519 } |
| 520 #endif | |
| 521 | 520 |
| 522 TEST_F(KernelWrapTest, rename) { | 521 TEST_F(KernelWrapTest, rename) { |
| 523 EXPECT_CALL(mock, rename(kDummyConstChar, kDummyConstChar2)) | 522 EXPECT_CALL(mock, rename(kDummyConstChar, kDummyConstChar2)) |
| 524 .WillOnce(Return(0)) | 523 .WillOnce(Return(0)) |
| 525 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); | 524 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); |
| 526 | 525 |
| 527 EXPECT_EQ(0, rename(kDummyConstChar, kDummyConstChar2)); | 526 EXPECT_EQ(0, rename(kDummyConstChar, kDummyConstChar2)); |
| 528 EXPECT_EQ(-1, rename(kDummyConstChar, kDummyConstChar2)); | 527 EXPECT_EQ(-1, rename(kDummyConstChar, kDummyConstChar2)); |
| 529 ASSERT_EQ(kDummyErrno, errno); | 528 ASSERT_EQ(kDummyErrno, errno); |
| 530 } | 529 } |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 .WillOnce(Return(0)) | 919 .WillOnce(Return(0)) |
| 921 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); | 920 .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); |
| 922 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); | 921 EXPECT_EQ(0, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); |
| 923 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); | 922 EXPECT_EQ(-1, socketpair(kDummyInt, kDummyInt2, kDummyInt3, &dummy_val)); |
| 924 EXPECT_EQ(kDummyErrno, errno); | 923 EXPECT_EQ(kDummyErrno, errno); |
| 925 } | 924 } |
| 926 | 925 |
| 927 #endif // PROVIDES_SOCKET_API | 926 #endif // PROVIDES_SOCKET_API |
| 928 | 927 |
| 929 #endif // __linux__ | 928 #endif // __linux__ |
| OLD | NEW |