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

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

Issue 604513002: [NaCl SDK] nacl_io: Add chmod/fchmod (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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/mem_fs_node_test.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc b/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc
index f2259d7d4b8c2f259a463de312570cb05e77613f..9b6e347fac375aa912cb3afe52a6a68997ecbcb0 100644
--- a/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/mem_fs_node_test.cc
@@ -127,6 +127,25 @@ TEST(MemFsNodeTest, File) {
EXPECT_EQ(NULL_NODE, result_node.get());
}
+TEST(MemFsNodeTest, Fchmod) {
+ MemFsNodeForTesting file;
+
+ ASSERT_EQ(0, file.Init(0));
+ EXPECT_EQ(S_IRALL | S_IWALL, file.GetMode());
+
+ struct stat s;
+ ASSERT_EQ(0, file.GetStat(&s));
+ EXPECT_EQ(S_IFREG | S_IRALL | S_IWALL, s.st_mode);
+
+ // Change to read-only.
+ EXPECT_EQ(0, file.Fchmod(S_IRALL));
+
+ EXPECT_EQ(S_IRALL, file.GetMode());
+
+ ASSERT_EQ(0, file.GetStat(&s));
+ EXPECT_EQ(S_IFREG | S_IRALL, s.st_mode);
+}
+
TEST(MemFsNodeTest, FTruncate) {
MemFsNodeForTesting file;
off_t result_size = 0;
@@ -229,6 +248,12 @@ TEST(MemFsNodeTest, Directory) {
EXPECT_EQ(EISDIR, root.Read(attr, buf1, sizeof(buf1), &result_bytes));
EXPECT_EQ(EISDIR, root.Write(attr, buf1, sizeof(buf1), &result_bytes));
+ // Chmod test
+ EXPECT_EQ(0, root.Fchmod(S_IRALL | S_IWALL));
+ EXPECT_EQ(S_IRALL | S_IWALL, root.GetMode());
+ // Change it back.
+ EXPECT_EQ(0, root.Fchmod(S_IRALL | S_IWALL | S_IXALL));
+
// Test directory operations
MemFsNodeForTesting* raw_file = new MemFsNodeForTesting;
EXPECT_EQ(0, raw_file->Init(0));

Powered by Google App Engine
This is Rietveld 408576698