Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 /* Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 #include <dirent.h> | |
| 7 #include <errno.h> | 6 #include <errno.h> |
| 8 #include <fcntl.h> | 7 #include <fcntl.h> |
| 9 #include <unistd.h> | |
| 10 #include <sys/stat.h> | 8 #include <sys/stat.h> |
| 11 | 9 |
| 12 #include <string> | 10 #include <string> |
| 13 | 11 |
| 14 #include "nacl_mounts/mount.h" | 12 #include "nacl_mounts/mount.h" |
| 15 #include "nacl_mounts/mount_mem.h" | 13 #include "nacl_mounts/mount_mem.h" |
| 14 #include "nacl_mounts/osdirent.h" | |
| 16 | 15 |
| 17 #define __STDC__ 1 | |
| 18 #include "gtest/gtest.h" | 16 #include "gtest/gtest.h" |
| 19 | 17 |
| 20 class MountMock : public MountMem { | 18 class MountMock : public MountMem { |
| 21 public: | 19 public: |
| 22 MountMock() | 20 MountMock() |
| 23 : MountMem(), | 21 : MountMem(), |
| 24 nodes_(0) { | 22 nodes_(0) { |
| 25 StringMap_t map; | 23 StringMap_t map; |
| 26 Init(1, map); | 24 Init(1, map); |
| 27 }; | 25 }; |
| 28 | 26 |
| 29 MountNode *AllocateData(int mode) { | 27 MountNode *AllocateData(int mode) { |
| 30 nodes_++; | 28 nodes_++; |
| 31 return MountMem::AllocateData(mode); | 29 return MountMem::AllocateData(mode); |
| 32 } | 30 } |
| 33 | 31 |
| 34 void ReleaseNode(MountNode* node) { | 32 void ReleaseNode(MountNode* node) { |
| 35 if (!node->Release()) { | 33 if (!node->Release()) { |
|
binji
2012/08/09 19:39:23
return value from Release is used here.
| |
| 36 nodes_--; | 34 nodes_--; |
| 37 } | 35 } |
| 38 } | 36 } |
| 39 | 37 |
| 40 int nodes_; | 38 int nodes_; |
| 41 }; | 39 }; |
| 42 | 40 |
| 43 #define NULL_NODE ((MountNode *) NULL) | 41 #define NULL_NODE ((MountNode *) NULL) |
| 44 | 42 |
| 45 TEST(MountTest, Sanity) { | 43 TEST(MountTest, Sanity) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 EXPECT_EQ(0, mnt->Rmdir(Path("/foo"))); | 118 EXPECT_EQ(0, mnt->Rmdir(Path("/foo"))); |
| 121 EXPECT_EQ(1, mnt->nodes_); | 119 EXPECT_EQ(1, mnt->nodes_); |
| 122 EXPECT_EQ(0, mnt->Close(file)); | 120 EXPECT_EQ(0, mnt->Close(file)); |
| 123 EXPECT_EQ(0, mnt->nodes_); | 121 EXPECT_EQ(0, mnt->nodes_); |
| 124 | 122 |
| 125 // Verify the directory is gone | 123 // Verify the directory is gone |
| 126 file = mnt->Open(Path("/foo"), O_RDWR); | 124 file = mnt->Open(Path("/foo"), O_RDWR); |
| 127 EXPECT_EQ(NULL_NODE, file); | 125 EXPECT_EQ(NULL_NODE, file); |
| 128 EXPECT_EQ(errno, ENOENT); | 126 EXPECT_EQ(errno, ENOENT); |
| 129 } | 127 } |
| OLD | NEW |