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

Unified Diff: native_client_sdk/src/tests/nacl_io_test/kernel_wrap_test.cc

Issue 474433005: [NaCl SDK] Remove syscalls wrappers for chmod and unlink. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/src/libraries/ppapi_simple/ps.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « native_client_sdk/src/libraries/ppapi_simple/ps.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698