Chromium Code Reviews| Index: native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc |
| diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc |
| index 9b03b5a4830346bc31d06d3ac7fc7626fa28254c..bef3cc350459d5dd855aabf595e1226a0ba3a984 100644 |
| --- a/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc |
| +++ b/native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc |
| @@ -188,14 +188,16 @@ TEST_F(KernelWrapTest, chdir) { |
| TEST_F(KernelWrapTest, chmod) { |
| EXPECT_CALL(mock, chmod(kDummyConstChar, kDummyMode)) |
| - .WillOnce(Return(kDummyInt2)); |
| - EXPECT_EQ(kDummyInt2,chmod(kDummyConstChar, kDummyMode)); |
| + .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); |
| + EXPECT_EQ(-1, chmod(kDummyConstChar, kDummyMode)); |
| + ASSERT_EQ(kDummyErrno, errno); |
| } |
| TEST_F(KernelWrapTest, chown) { |
| EXPECT_CALL(mock, chown(kDummyConstChar, kDummyUid, kDummyGid)) |
| - .WillOnce(Return(kDummyInt)); |
| - EXPECT_EQ(kDummyInt, chown(kDummyConstChar, kDummyUid, kDummyGid)); |
| + .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); |
| + EXPECT_EQ(-1, chown(kDummyConstChar, kDummyUid, kDummyGid)); |
| + ASSERT_EQ(kDummyErrno, errno); |
| } |
| TEST_F(KernelWrapTest, close) { |
| @@ -372,8 +374,9 @@ TEST_F(KernelWrapTest, lchown) { |
| TEST_F(KernelWrapTest, link) { |
| EXPECT_CALL(mock, link(kDummyConstChar, kDummyConstChar2)) |
| - .WillOnce(Return(kDummyInt)); |
| - EXPECT_EQ(kDummyInt, link(kDummyConstChar, kDummyConstChar2)); |
| + .WillOnce(DoAll(SetErrno(kDummyErrno), Return(-1))); |
| + EXPECT_EQ(-1, link(kDummyConstChar, kDummyConstChar2)); |
| + ASSERT_EQ(kDummyErrno, errno); |
| } |
| TEST_F(KernelWrapTest, lseek) { |
| @@ -630,6 +633,36 @@ TEST_F(KernelWrapTest, write) { |
| EXPECT_EQ(kDummyInt3, write(kDummyInt, kDummyVoidPtr, kDummyInt2)); |
| } |
| +#if defined SEL_LDR |
| +class KernelWrapTestUninit : public ::testing::Test { |
| + void SetUp() { |
| + ASSERT_EQ(0, ki_push_state_for_testing()); |
| + } |
| + |
| + void TearDown() { |
| + ki_pop_state_for_testing(); |
| + } |
| +}; |
| + |
| +TEST_F(KernelWrapTestUninit, Mkdir_Uninitialised) { |
| + // If we are running within chrome we can't use these calls without |
| + // nacl_io initialized. |
| + EXPECT_EQ(0, mkdir("./foo", S_IREAD | S_IWRITE)); |
| + EXPECT_EQ(0, rmdir("./foo")); |
| +} |
| + |
| +TEST_F(KernelWrapTestUninit, Getcwd_Uninitialised) { |
| + // If we are running within chrome we can't use these calls without |
| + // nacl_io initialized. |
| + char dir[PATH_MAX]; |
| + ASSERT_NE((char*)NULL, getcwd(dir, 1024)); |
|
binji
2014/08/20 18:13:35
PATH_MAX?
Sam Clegg
2014/08/21 10:19:34
Done.
|
| + // Verify that the CWD ends with 'nacl_io_test' |
| + const char* suffix = "nacl_io_test"; |
|
binji
2014/08/20 18:13:35
hm, seems like a fragile test. There's no reason w
Sam Clegg
2014/08/21 10:19:34
Got any better ideas? My goal here is to check th
|
| + ASSERT_GT(strlen(dir), strlen(suffix)); |
| + ASSERT_EQ(0, strcmp(dir+strlen(dir)-strlen(suffix), suffix)); |
| +} |
| +#endif |
| + |
| #if defined(PROVIDES_SOCKET_API) and !defined(__BIONIC__) |
| TEST_F(KernelWrapTest, poll) { |
| struct pollfd fds; |