| 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..2bb619872cdb3404f9db4fba857aaa5928b21291 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, PATH_MAX));
|
| + // Verify that the CWD ends with 'nacl_io_test'
|
| + const char* suffix = "nacl_io_test";
|
| + 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;
|
|
|