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

Unified Diff: native_client_sdk/src/libraries/nacl_io_test/mount_test.cc

Issue 15800004: [NaCl SDK] nacl_io: Added support for access() syscall. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to HEAD. Created 7 years, 6 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/nacl_io_test/mount_http_test.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/libraries/nacl_io_test/mount_test.cc
diff --git a/native_client_sdk/src/libraries/nacl_io_test/mount_test.cc b/native_client_sdk/src/libraries/nacl_io_test/mount_test.cc
index 245d13daf400682c0c856e7a5bb7b3753ed96fde..1b75ab43d2058d4754f38ba5be9390cdbae9e59b 100644
--- a/native_client_sdk/src/libraries/nacl_io_test/mount_test.cc
+++ b/native_client_sdk/src/libraries/nacl_io_test/mount_test.cc
@@ -55,6 +55,7 @@ TEST(MountTest, Sanity) {
EXPECT_EQ(1, mnt->num_nodes());
// Fail to open non existent file
+ EXPECT_EQ(ENOENT, mnt->Access(Path("/foo"), R_OK | W_OK));
EXPECT_EQ(ENOENT, mnt->Open(Path("/foo"), O_RDWR, &result_node));
EXPECT_EQ(NULL, result_node);
@@ -65,7 +66,12 @@ TEST(MountTest, Sanity) {
return;
EXPECT_EQ(2, file->RefCount());
EXPECT_EQ(2, mnt->num_nodes());
+ EXPECT_EQ(0, mnt->Access(Path("/foo"), R_OK | W_OK));
+ EXPECT_EQ(EACCES, mnt->Access(Path("/foo"), X_OK));
+ // Write access should be allowed on the root directory.
+ EXPECT_EQ(0, mnt->Access(Path("/"), R_OK | W_OK));
+ EXPECT_EQ(EACCES, mnt->Access(Path("/"), X_OK));
// Open the root directory for write should fail.
EXPECT_EQ(EISDIR, mnt->Open(Path("/"), O_RDWR, &root));
@@ -136,6 +142,7 @@ TEST(MountTest, Sanity) {
EXPECT_EQ(1, mnt->num_nodes());
// Verify the directory is gone
+ EXPECT_EQ(ENOENT, mnt->Access(Path("/foo"), F_OK));
EXPECT_EQ(ENOENT, mnt->Open(Path("/foo"), O_RDWR, &file));
EXPECT_EQ(NULL_NODE, file);
}
@@ -160,11 +167,19 @@ TEST(MountTest, MemMountRemove) {
EXPECT_EQ(NULL_NODE, result_node);
}
+TEST(MountTest, DevAccess) {
+ // Should not be able to open non-existent file.
+ MountDevMock* mnt = new MountDevMock();
+ ASSERT_EQ(ENOENT, mnt->Access(Path("/foo"), F_OK));
+}
+
TEST(MountTest, DevNull) {
MountDevMock* mnt = new MountDevMock();
MountNode* dev_null = NULL;
int result_bytes = 0;
+ ASSERT_EQ(0, mnt->Access(Path("/null"), R_OK | W_OK));
+ ASSERT_EQ(EACCES, mnt->Access(Path("/null"), X_OK));
ASSERT_EQ(0, mnt->Open(Path("/null"), O_RDWR, &dev_null));
ASSERT_NE(NULL_NODE, dev_null);
@@ -186,6 +201,8 @@ TEST(MountTest, DevZero) {
MountNode* dev_zero = NULL;
int result_bytes = 0;
+ ASSERT_EQ(0, mnt->Access(Path("/zero"), R_OK | W_OK));
+ ASSERT_EQ(EACCES, mnt->Access(Path("/zero"), X_OK));
ASSERT_EQ(0, mnt->Open(Path("/zero"), O_RDWR, &dev_zero));
ASSERT_NE(NULL_NODE, dev_zero);
@@ -213,6 +230,8 @@ TEST(MountTest, DevUrandom) {
MountNode* dev_urandom = NULL;
int result_bytes = 0;
+ ASSERT_EQ(0, mnt->Access(Path("/urandom"), R_OK | W_OK));
+ ASSERT_EQ(EACCES, mnt->Access(Path("/urandom"), X_OK));
ASSERT_EQ(0, mnt->Open(Path("/urandom"), O_RDWR, &dev_urandom));
ASSERT_NE(NULL_NODE, dev_urandom);
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698