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

Side by Side Diff: native_client_sdk/src/tests/nacl_io_test/kernel_object_test.cc

Issue 99203014: [NaCl SDK] Map active fds to absolute paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Conform to style guide Created 6 years, 11 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 unified diff | Download patch
OLDNEW
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 #include <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <pthread.h> 7 #include <pthread.h>
8 #include <sys/stat.h> 8 #include <sys/stat.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // There should be two references to the KernelHandle, the filesystem and node 88 // There should be two references to the KernelHandle, the filesystem and node
89 // should be unchanged. 89 // should be unchanged.
90 EXPECT_EQ(2, handle_a->RefCount()); 90 EXPECT_EQ(2, handle_a->RefCount());
91 EXPECT_EQ(2, handle_b->RefCount()); 91 EXPECT_EQ(2, handle_b->RefCount());
92 EXPECT_EQ(handle_a.get(), handle_b.get()); 92 EXPECT_EQ(handle_a.get(), handle_b.get());
93 EXPECT_EQ(2, fs->RefCount()); 93 EXPECT_EQ(2, fs->RefCount());
94 EXPECT_EQ(2, node->RefCount()); 94 EXPECT_EQ(2, node->RefCount());
95 95
96 // Allocating an FD should cause the KernelProxy to ref the handle and 96 // Allocating an FD should cause the KernelProxy to ref the handle and
97 // the node and filesystem should be unchanged. 97 // the node and filesystem should be unchanged.
98 int fd1 = proxy.AllocateFD(handle_a); 98 int fd1 = proxy.AllocateFD(handle_a, "/example");
99 EXPECT_EQ(3, handle_a->RefCount()); 99 EXPECT_EQ(3, handle_a->RefCount());
100 EXPECT_EQ(2, fs->RefCount()); 100 EXPECT_EQ(2, fs->RefCount());
101 EXPECT_EQ(2, node->RefCount()); 101 EXPECT_EQ(2, node->RefCount());
102 102
103 // If we "dup" the handle, we should bump the ref count on the handle 103 // If we "dup" the handle, we should bump the ref count on the handle
104 int fd2 = proxy.AllocateFD(handle_b); 104 int fd2 = proxy.AllocateFD(handle_b, "");
105 EXPECT_EQ(4, handle_a->RefCount()); 105 EXPECT_EQ(4, handle_a->RefCount());
106 EXPECT_EQ(2, fs->RefCount()); 106 EXPECT_EQ(2, fs->RefCount());
107 EXPECT_EQ(2, node->RefCount()); 107 EXPECT_EQ(2, node->RefCount());
108 108
109 // Handles are expected to come out in order 109 // Handles are expected to come out in order
110 EXPECT_EQ(0, fd1); 110 EXPECT_EQ(0, fd1);
111 EXPECT_EQ(1, fd2); 111 EXPECT_EQ(1, fd2);
112 112
113 // Now we "free" the handles, since the proxy should hold them. 113 // Now we "free" the handles, since the proxy should hold them.
114 handle_a.reset(NULL); 114 handle_a.reset(NULL);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 EXPECT_EQ(1, fs->RefCount()); 158 EXPECT_EQ(1, fs->RefCount());
159 EXPECT_EQ(1, node->RefCount()); 159 EXPECT_EQ(1, node->RefCount());
160 160
161 KernelHandle* raw_handle = new KernelHandleForTesting(fs, node); 161 KernelHandle* raw_handle = new KernelHandleForTesting(fs, node);
162 ScopedKernelHandle handle(raw_handle); 162 ScopedKernelHandle handle(raw_handle);
163 163
164 EXPECT_EQ(2, fs->RefCount()); 164 EXPECT_EQ(2, fs->RefCount());
165 EXPECT_EQ(2, node->RefCount()); 165 EXPECT_EQ(2, node->RefCount());
166 EXPECT_EQ(1, raw_handle->RefCount()); 166 EXPECT_EQ(1, raw_handle->RefCount());
167 167
168 proxy.AllocateFD(handle); 168 proxy.AllocateFD(handle, "/example");
169 EXPECT_EQ(2, fs->RefCount()); 169 EXPECT_EQ(2, fs->RefCount());
170 EXPECT_EQ(2, node->RefCount()); 170 EXPECT_EQ(2, node->RefCount());
171 EXPECT_EQ(2, raw_handle->RefCount()); 171 EXPECT_EQ(2, raw_handle->RefCount());
172 172
173 proxy.FreeAndReassignFD(5, handle); 173 proxy.FreeAndReassignFD(5, handle, "/example");
174 EXPECT_EQ(2, fs->RefCount()); 174 EXPECT_EQ(2, fs->RefCount());
175 EXPECT_EQ(2, node->RefCount()); 175 EXPECT_EQ(2, node->RefCount());
176 EXPECT_EQ(3, raw_handle->RefCount()); 176 EXPECT_EQ(3, raw_handle->RefCount());
177 177
178
178 handle.reset(); 179 handle.reset();
179 EXPECT_EQ(2, raw_handle->RefCount()); 180 EXPECT_EQ(2, raw_handle->RefCount());
180 181
181 proxy.AcquireHandle(5, &handle); 182 proxy.AcquireHandle(5, &handle);
182 EXPECT_EQ(3, raw_handle->RefCount()); 183 EXPECT_EQ(3, raw_handle->RefCount());
183 EXPECT_EQ(raw_handle, handle.get()); 184 EXPECT_EQ(raw_handle, handle.get());
184 } 185 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc ('k') | native_client_sdk/src/tests/nacl_io_test/kernel_proxy_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698