| 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 <errno.h> | 6 #include <errno.h> |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 | 8 |
| 9 #include "nacl_mounts/kernel_proxy.h" | 9 #include "nacl_mounts/kernel_proxy.h" |
| 10 #include "nacl_mounts/mount_node.h" | 10 #include "nacl_mounts/mount_node.h" |
| 11 #include "nacl_mounts/mount_node_dir.h" | 11 #include "nacl_mounts/mount_node_dir.h" |
| 12 #include "nacl_mounts/mount_node_mem.h" | 12 #include "nacl_mounts/mount_node_mem.h" |
| 13 #include "nacl_mounts/osdirent.h" | 13 #include "nacl_mounts/osdirent.h" |
| 14 | 14 |
| 15 #include "gtest/gtest.h" | 15 #include "gtest/gtest.h" |
| 16 | 16 |
| 17 #define NULL_NODE ((MountNode *) NULL) | 17 #define NULL_NODE ((MountNode *) NULL) |
| 18 | 18 |
| 19 static int s_AllocNum = 0; | 19 static int s_AllocNum = 0; |
| 20 | 20 |
| 21 class MockMemory : public MountNodeMem { | 21 class MockMemory : public MountNodeMem { |
| 22 public: | 22 public: |
| 23 MockMemory() : MountNodeMem(NULL, 0, 0) { | 23 MockMemory() : MountNodeMem(NULL) { |
| 24 s_AllocNum++; | 24 s_AllocNum++; |
| 25 } | 25 } |
| 26 | 26 |
| 27 ~MockMemory() { | 27 ~MockMemory() { |
| 28 s_AllocNum--; | 28 s_AllocNum--; |
| 29 } | 29 } |
| 30 | 30 |
| 31 bool Init(int mode) { | 31 bool Init(int mode) { |
| 32 return MountNodeMem::Init(mode,0,0); | 32 return MountNodeMem::Init(mode); |
| 33 } | 33 } |
| 34 int AddChild(const std::string& name, MountNode *node) { | 34 int AddChild(const std::string& name, MountNode *node) { |
| 35 return MountNodeMem::AddChild(name, node); | 35 return MountNodeMem::AddChild(name, node); |
| 36 } | 36 } |
| 37 int RemoveChild(const std::string& name) { | 37 int RemoveChild(const std::string& name) { |
| 38 return MountNodeMem::RemoveChild(name); | 38 return MountNodeMem::RemoveChild(name); |
| 39 } | 39 } |
| 40 MountNode* FindChild(const std::string& name) { | 40 MountNode* FindChild(const std::string& name) { |
| 41 return MountNodeMem::FindChild(name); | 41 return MountNodeMem::FindChild(name); |
| 42 } | 42 } |
| 43 void Link() { MountNodeMem::Link(); } | 43 void Link() { MountNodeMem::Link(); } |
| 44 void Unlink() { MountNodeMem::Unlink(); } | 44 void Unlink() { MountNodeMem::Unlink(); } |
| 45 | 45 |
| 46 protected: | 46 protected: |
| 47 using MountNodeMem::Init; | 47 using MountNodeMem::Init; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 class MockDir : public MountNodeDir { | 50 class MockDir : public MountNodeDir { |
| 51 public: | 51 public: |
| 52 MockDir() : MountNodeDir(NULL, 0, 0) { | 52 MockDir() : MountNodeDir(NULL) { |
| 53 s_AllocNum++; | 53 s_AllocNum++; |
| 54 } | 54 } |
| 55 | 55 |
| 56 ~MockDir() { | 56 ~MockDir() { |
| 57 s_AllocNum--; | 57 s_AllocNum--; |
| 58 } | 58 } |
| 59 | 59 |
| 60 bool Init(int mode) { | 60 bool Init(int mode) { |
| 61 return MountNodeDir::Init(mode,0,0); | 61 return MountNodeDir::Init(mode); |
| 62 } | 62 } |
| 63 int AddChild(const std::string& name, MountNode *node) { | 63 int AddChild(const std::string& name, MountNode *node) { |
| 64 return MountNodeDir::AddChild(name, node); | 64 return MountNodeDir::AddChild(name, node); |
| 65 } | 65 } |
| 66 int RemoveChild(const std::string& name) { | 66 int RemoveChild(const std::string& name) { |
| 67 return MountNodeDir::RemoveChild(name); | 67 return MountNodeDir::RemoveChild(name); |
| 68 } | 68 } |
| 69 MountNode* FindChild(const std::string& name) { | 69 MountNode* FindChild(const std::string& name) { |
| 70 return MountNodeDir::FindChild(name); | 70 return MountNodeDir::FindChild(name); |
| 71 } | 71 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 EXPECT_EQ(0, file->GetLinks()); | 181 EXPECT_EQ(0, file->GetLinks()); |
| 182 EXPECT_EQ(1, file->RefCount()); | 182 EXPECT_EQ(1, file->RefCount()); |
| 183 EXPECT_EQ(2, s_AllocNum); | 183 EXPECT_EQ(2, s_AllocNum); |
| 184 | 184 |
| 185 file->Release(); | 185 file->Release(); |
| 186 EXPECT_EQ(1, s_AllocNum); | 186 EXPECT_EQ(1, s_AllocNum); |
| 187 root->Release(); | 187 root->Release(); |
| 188 EXPECT_EQ(0, s_AllocNum); | 188 EXPECT_EQ(0, s_AllocNum); |
| 189 } | 189 } |
| 190 | 190 |
| OLD | NEW |