summaryrefslogtreecommitdiffstats
path: root/native_client_sdk
diff options
context:
space:
mode:
authorsbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 17:17:31 +0000
committersbc@chromium.org <sbc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-06-18 17:17:31 +0000
commit12e23c6045930f717ed50e416907fccac2d31710 (patch)
tree3e44c170d71bc700e5721e2bc30446f50d728577 /native_client_sdk
parent940fb1c9ca08476b1d52fdb6e92b42e699f2d1e4 (diff)
downloadchromium_src-12e23c6045930f717ed50e416907fccac2d31710.zip
chromium_src-12e23c6045930f717ed50e416907fccac2d31710.tar.gz
chromium_src-12e23c6045930f717ed50e416907fccac2d31710.tar.bz2
[NaCl SDK] nacl_io: Fix implemenation of mkdir for http mount
Also, remove stray file from nacl_io_test folder. BUG=250910 TEST=run nacl_io_test R=binji@chromium.org Review URL: https://codereview.chromium.org/17121011 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@207020 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'native_client_sdk')
-rw-r--r--native_client_sdk/src/libraries/nacl_io/mount_http.cc39
-rw-r--r--native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc52
-rw-r--r--native_client_sdk/src/libraries/nacl_io_test/nacl_mounts_test.vcproj.GOOGLE.noelallen.user65
3 files changed, 87 insertions, 69 deletions
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_http.cc b/native_client_sdk/src/libraries/nacl_io/mount_http.cc
index 7b4316e..15c32e6 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_http.cc
+++ b/native_client_sdk/src/libraries/nacl_io/mount_http.cc
@@ -101,13 +101,44 @@ Error MountHttp::Open(const Path& path, int mode, MountNode** out_node) {
return 0;
}
-Error MountHttp::Unlink(const Path& path) { return ENOSYS; }
+Error MountHttp::Unlink(const Path& path) {
+ NodeMap_t::iterator iter = node_cache_.find(path.Join());
+ if (iter == node_cache_.end())
+ return ENOENT;
+
+ if (iter->second->IsaDir())
+ return EISDIR;
-Error MountHttp::Mkdir(const Path& path, int permissions) { return ENOSYS; }
+ return EACCES;
+}
-Error MountHttp::Rmdir(const Path& path) { return ENOSYS; }
+Error MountHttp::Mkdir(const Path& path, int permissions) {
+ NodeMap_t::iterator iter = node_cache_.find(path.Join());
+ if (iter != node_cache_.end()) {
+ if (iter->second->IsaDir())
+ return EEXIST;
+ }
+ return EACCES;
+}
-Error MountHttp::Remove(const Path& path) { return ENOSYS; }
+Error MountHttp::Rmdir(const Path& path) {
+ NodeMap_t::iterator iter = node_cache_.find(path.Join());
+ if (iter == node_cache_.end())
+ return ENOENT;
+
+ if (!iter->second->IsaDir())
+ return ENOTDIR;
+
+ return EACCES;
+}
+
+Error MountHttp::Remove(const Path& path) {
+ NodeMap_t::iterator iter = node_cache_.find(path.Join());
+ if (iter == node_cache_.end())
+ return ENOENT;
+
+ return EACCES;
+}
PP_Resource MountHttp::MakeUrlRequestInfo(const std::string& url,
const char* method,
diff --git a/native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc b/native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc
index ced8d06..1bc7506 100644
--- a/native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc
+++ b/native_client_sdk/src/libraries/nacl_io_test/mount_http_test.cc
@@ -69,6 +69,58 @@ TEST_F(MountHttpTest, MountEmpty) {
mnt_ = new MountHttpMock(args, &ppapi_);
}
+TEST_F(MountHttpTest, Mkdir) {
+ StringMap_t args;
+ mnt_ = new MountHttpMock(args, &ppapi_);
+ char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
+ EXPECT_EQ(0, mnt_->ParseManifest(manifest));
+ // mkdir of existing directories should give "File exists".
+ EXPECT_EQ(EEXIST, mnt_->Mkdir(Path("/"), 0));
+ EXPECT_EQ(EEXIST, mnt_->Mkdir(Path("/mydir"), 0));
+ // mkdir of non-existent directories should give "Permission denied".
+ EXPECT_EQ(EACCES, mnt_->Mkdir(Path("/non_existent"), 0));
+}
+
+TEST_F(MountHttpTest, Rmdir) {
+ StringMap_t args;
+ mnt_ = new MountHttpMock(args, &ppapi_);
+ char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
+ EXPECT_EQ(0, mnt_->ParseManifest(manifest));
+ // Rmdir on existing dirs should give "Permission Denied"
+ EXPECT_EQ(EACCES, mnt_->Rmdir(Path("/")));
+ EXPECT_EQ(EACCES, mnt_->Rmdir(Path("/mydir")));
+ // Rmdir on existing files should give "Not a direcotory"
+ EXPECT_EQ(ENOTDIR, mnt_->Rmdir(Path("/mydir/foo")));
+ // Rmdir on non-existent files should give "No such file or directory"
+ EXPECT_EQ(ENOENT, mnt_->Rmdir(Path("/non_existent")));
+}
+
+TEST_F(MountHttpTest, Unlink) {
+ StringMap_t args;
+ mnt_ = new MountHttpMock(args, &ppapi_);
+ char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
+ EXPECT_EQ(0, mnt_->ParseManifest(manifest));
+ // Unlink of existing files should give "Permission Denied"
+ EXPECT_EQ(EACCES, mnt_->Unlink(Path("/mydir/foo")));
+ // Unlink of existing directory should give "Is a directory"
+ EXPECT_EQ(EISDIR, mnt_->Unlink(Path("/mydir")));
+ // Unlink of non-existent files should give "No such file or directory"
+ EXPECT_EQ(ENOENT, mnt_->Unlink(Path("/non_existent")));
+}
+
+TEST_F(MountHttpTest, Remove) {
+ StringMap_t args;
+ mnt_ = new MountHttpMock(args, &ppapi_);
+ char manifest[] = "-r-- 123 /mydir/foo\n-rw- 234 /thatdir/bar\n";
+ EXPECT_EQ(0, mnt_->ParseManifest(manifest));
+ // Remove of existing files should give "Permission Denied"
+ EXPECT_EQ(EACCES, mnt_->Remove(Path("/mydir/foo")));
+ // Remove of existing directory should give "Permission Denied"
+ EXPECT_EQ(EACCES, mnt_->Remove(Path("/mydir")));
+ // Unlink of non-existent files should give "No such file or directory"
+ EXPECT_EQ(ENOENT, mnt_->Remove(Path("/non_existent")));
+}
+
TEST_F(MountHttpTest, ParseManifest) {
StringMap_t args;
size_t result_size = 0;
diff --git a/native_client_sdk/src/libraries/nacl_io_test/nacl_mounts_test.vcproj.GOOGLE.noelallen.user b/native_client_sdk/src/libraries/nacl_io_test/nacl_mounts_test.vcproj.GOOGLE.noelallen.user
deleted file mode 100644
index 1d5bc9b..0000000
--- a/native_client_sdk/src/libraries/nacl_io_test/nacl_mounts_test.vcproj.GOOGLE.noelallen.user
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="Windows-1252"?>
-<VisualStudioUserFile
- ProjectType="Visual C++"
- Version="9.00"
- ShowAllFiles="false"
- >
- <Configurations>
- <Configuration
- Name="Debug|Win32"
- >
- <DebugSettings
- Command="$(TargetPath)"
- WorkingDirectory=""
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- Remote="1"
- RemoteMachine="NOELALLEN0-W"
- RemoteCommand=""
- HttpUrl=""
- PDBPath=""
- SQLDebugging=""
- Environment=""
- EnvironmentMerge="true"
- DebuggerFlavor=""
- MPIRunCommand=""
- MPIRunArguments=""
- MPIRunWorkingDirectory=""
- ApplicationCommand=""
- ApplicationArguments=""
- ShimCommand=""
- MPIAcceptMode=""
- MPIAcceptFilter=""
- />
- </Configuration>
- <Configuration
- Name="Release|Win32"
- >
- <DebugSettings
- Command="$(TargetPath)"
- WorkingDirectory=""
- CommandArguments=""
- Attach="false"
- DebuggerType="3"
- Remote="1"
- RemoteMachine="NOELALLEN0-W"
- RemoteCommand=""
- HttpUrl=""
- PDBPath=""
- SQLDebugging=""
- Environment=""
- EnvironmentMerge="true"
- DebuggerFlavor=""
- MPIRunCommand=""
- MPIRunArguments=""
- MPIRunWorkingDirectory=""
- ApplicationCommand=""
- ApplicationArguments=""
- ShimCommand=""
- MPIAcceptMode=""
- MPIAcceptFilter=""
- />
- </Configuration>
- </Configurations>
-</VisualStudioUserFile>