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

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

Issue 565763002: Plumbing though mode parameter to open, since fusefs can make use of it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 6 years, 3 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
Index: native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc b/native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc
index 962ca811921a7f60dbdc0529f17724f607c4cd51..bf4b51d8a03cb20e94acc992b77ea64a14a536dd 100644
--- a/native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc
@@ -36,6 +36,7 @@ struct File {
typedef std::vector<File> Files;
Files g_files;
+mode_t last_create_mode = 0666;
bool IsValidPath(const char* path) {
if (path == NULL)
@@ -74,7 +75,7 @@ int testfs_getattr(const char* path, struct stat* stbuf) {
if (file == NULL)
return -ENOENT;
- stbuf->st_mode = S_IFREG | 0666;
+ stbuf->st_mode = S_IFREG | last_create_mode;
stbuf->st_size = file->data.size();
return 0;
}
@@ -95,7 +96,7 @@ int testfs_readdir(const char* path,
return 0;
}
-int testfs_create(const char* path, mode_t, struct fuse_file_info* fi) {
+int testfs_create(const char* path, mode_t mode, struct fuse_file_info* fi) {
if (!IsValidPath(path))
return -ENOENT;
@@ -108,6 +109,7 @@ int testfs_create(const char* path, mode_t, struct fuse_file_info* fi) {
file = &g_files.back();
file->name = &path[1]; // Skip initial /
}
+ last_create_mode = mode;
return 0;
}
@@ -232,6 +234,17 @@ TEST_F(FuseFsTest, OpenAndRead) {
ASSERT_STREQ("World!\n", buffer);
}
+TEST_F(FuseFsTest, CreateWithMode) {
+ ScopedNode node;
+ struct stat statbuf;
+
+ ASSERT_EQ(0, fs_.OpenWithMode(Path("/hello"),
+ O_RDWR | O_CREAT, 0723, &node));
+ EXPECT_EQ(0, node->GetStat(&statbuf));
+ EXPECT_EQ(S_IFREG, statbuf.st_mode & S_IFMT);
+ EXPECT_EQ(0723, statbuf.st_mode & ~S_IFMT);
+}
+
TEST_F(FuseFsTest, CreateAndWrite) {
ScopedNode node;
ASSERT_EQ(0, fs_.Open(Path("/foobar"), O_RDWR | O_CREAT, &node));
@@ -341,14 +354,14 @@ void KernelProxyFuseTest::TearDown() {
TEST_F(KernelProxyFuseTest, Basic) {
// Write a file.
- int fd = ki_open("/hello", O_WRONLY | O_CREAT);
+ int fd = ki_open("/hello", O_WRONLY | O_CREAT, 0777);
ASSERT_GT(fd, -1);
ASSERT_EQ(sizeof(hello_world),
ki_write(fd, hello_world, sizeof(hello_world)));
EXPECT_EQ(0, ki_close(fd));
// Then read it back in.
- fd = ki_open("/hello", O_RDONLY);
+ fd = ki_open("/hello", O_RDONLY, 0);
ASSERT_GT(fd, -1);
char buffer[30];
« no previous file with comments | « native_client_sdk/src/tests/nacl_io_test/event_test.cc ('k') | native_client_sdk/src/tests/nacl_io_test/jspipe_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698