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

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

Issue 660353003: [NaCl SDK] nacl_io: Fix utime() on directories. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/tests/nacl_io_test/filesystem_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/tests/nacl_io_test/kernel_proxy_test.cc
diff --git a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
index c42ba59cb0391989b72d09ab1a6c2cc7192da6f1..ae3ee82b740b7c105fe2cc07c3927740ca4e5384 100644
--- a/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
+++ b/native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc
@@ -549,6 +549,18 @@ TEST_F(KernelProxyTest, Lstat) {
EXPECT_EQ(0, ki_lstat("/foo", &buf));
}
+TEST_F(KernelProxyTest, OpenDirectory) {
+ // Opening a directory for read should succeed.
+ int fd = ki_open("/", O_RDONLY, 0);
+ ASSERT_GT(fd, -1);
+
+ // Opening a directory for write should fail.
+ EXPECT_EQ(-1, ki_open("/", O_RDWR, 0));
+ EXPECT_EQ(errno, EISDIR);
+ EXPECT_EQ(-1, ki_open("/", O_WRONLY, 0));
+ EXPECT_EQ(errno, EISDIR);
+}
+
TEST_F(KernelProxyTest, OpenWithMode) {
int fd = ki_open("/foo", O_CREAT | O_RDWR, 0723);
ASSERT_GT(fd, -1);
@@ -586,6 +598,9 @@ TEST_F(KernelProxyTest, Utimes) {
// utime should work if the file is write-only.
EXPECT_EQ(0, ki_utimes("/dummy", times));
+ // utime should work on directories (which can never be opened for write)
+ EXPECT_EQ(0, ki_utimes("/", times));
+
// or if the file is read-only.
EXPECT_EQ(0, ki_chmod("/dummy", 0444));
EXPECT_EQ(0, ki_utimes("/dummy", times));
« no previous file with comments | « native_client_sdk/src/tests/nacl_io_test/filesystem_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698