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

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

Issue 13106002: [NaCl SDK] A bunch of spelling fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix presubmit Created 7 years, 8 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 | Annotate | Revision Log
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 5
6 #include <errno.h> 6 #include <errno.h>
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 10
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 // If we "dup" the handle, we should bump the refs 98 // If we "dup" the handle, we should bump the refs
99 int fd2 = proxy->AllocateFD(handle); 99 int fd2 = proxy->AllocateFD(handle);
100 EXPECT_EQ(3, mnt->RefCount()); 100 EXPECT_EQ(3, mnt->RefCount());
101 EXPECT_EQ(3, handle->RefCount()); 101 EXPECT_EQ(3, handle->RefCount());
102 102
103 // If use a new handle with the same values... bump the refs 103 // If use a new handle with the same values... bump the refs
104 int fd3 = proxy->AllocateFD(handle2); 104 int fd3 = proxy->AllocateFD(handle2);
105 EXPECT_EQ(4, mnt->RefCount()); 105 EXPECT_EQ(4, mnt->RefCount());
106 EXPECT_EQ(2, handle2->RefCount()); 106 EXPECT_EQ(2, handle2->RefCount());
107 107
108 // Handles are expectd to come out in order 108 // Handles are expected to come out in order
109 EXPECT_EQ(0, fd1); 109 EXPECT_EQ(0, fd1);
110 EXPECT_EQ(1, fd2); 110 EXPECT_EQ(1, fd2);
111 EXPECT_EQ(2, fd3); 111 EXPECT_EQ(2, fd3);
112 112
113 // We should find the handle by either fd 113 // We should find the handle by either fd
114 EXPECT_EQ(handle, proxy->AcquireHandle(fd1)); 114 EXPECT_EQ(handle, proxy->AcquireHandle(fd1));
115 EXPECT_EQ(handle, proxy->AcquireHandle(fd2)); 115 EXPECT_EQ(handle, proxy->AcquireHandle(fd2));
116 116
117 // A non existant fd should fail 117 // A non existent fd should fail
118 EXPECT_EQ(NULL, proxy->AcquireHandle(-1)); 118 EXPECT_EQ(NULL, proxy->AcquireHandle(-1));
119 EXPECT_EQ(EBADF, errno); 119 EXPECT_EQ(EBADF, errno);
120 EXPECT_EQ(NULL, proxy->AcquireHandle(100)); 120 EXPECT_EQ(NULL, proxy->AcquireHandle(100));
121 EXPECT_EQ(EBADF, errno); 121 EXPECT_EQ(EBADF, errno);
122 122
123 // Acquiring the handle, should have ref'd it 123 // Acquiring the handle, should have ref'd it
124 EXPECT_EQ(4, mnt->RefCount()); 124 EXPECT_EQ(4, mnt->RefCount());
125 EXPECT_EQ(5, handle->RefCount()); 125 EXPECT_EQ(5, handle->RefCount());
126 126
127 // Release the handle for each call to acquire 127 // Release the handle for each call to acquire
(...skipping 27 matching lines...) Expand all
155 } 155 }
156 156
157 TEST_F(KernelObjectTest, FreeAndReassignFD) { 157 TEST_F(KernelObjectTest, FreeAndReassignFD) {
158 EXPECT_EQ(0, handle_count); 158 EXPECT_EQ(0, handle_count);
159 159
160 KernelHandle* handle = new KernelHandleRefMock(mnt, NULL, 0); 160 KernelHandle* handle = new KernelHandleRefMock(mnt, NULL, 0);
161 161
162 EXPECT_EQ(1, handle_count); 162 EXPECT_EQ(1, handle_count);
163 EXPECT_EQ(1, handle->RefCount()); 163 EXPECT_EQ(1, handle->RefCount());
164 164
165 // Assign to a non-existant FD 165 // Assign to a non-existent FD
166 proxy->FreeAndReassignFD(2, handle); 166 proxy->FreeAndReassignFD(2, handle);
167 EXPECT_EQ((KernelHandle*)NULL, proxy->AcquireHandle(0)); 167 EXPECT_EQ((KernelHandle*)NULL, proxy->AcquireHandle(0));
168 EXPECT_EQ((KernelHandle*)NULL, proxy->AcquireHandle(1)); 168 EXPECT_EQ((KernelHandle*)NULL, proxy->AcquireHandle(1));
169 EXPECT_EQ(handle, proxy->AcquireHandle(2)); 169 EXPECT_EQ(handle, proxy->AcquireHandle(2));
170 proxy->ReleaseHandle(handle); 170 proxy->ReleaseHandle(handle);
171 171
172 EXPECT_EQ(1, handle_count); 172 EXPECT_EQ(1, handle_count);
173 EXPECT_EQ(2, handle->RefCount()); 173 EXPECT_EQ(2, handle->RefCount());
174 174
175 proxy->FreeAndReassignFD(0, handle); 175 proxy->FreeAndReassignFD(0, handle);
176 EXPECT_EQ(handle, proxy->AcquireHandle(0)); 176 EXPECT_EQ(handle, proxy->AcquireHandle(0));
177 EXPECT_EQ((KernelHandle*)NULL, proxy->AcquireHandle(1)); 177 EXPECT_EQ((KernelHandle*)NULL, proxy->AcquireHandle(1));
178 EXPECT_EQ(handle, proxy->AcquireHandle(2)); 178 EXPECT_EQ(handle, proxy->AcquireHandle(2));
179 proxy->ReleaseHandle(handle); 179 proxy->ReleaseHandle(handle);
180 proxy->ReleaseHandle(handle); 180 proxy->ReleaseHandle(handle);
181 181
182 EXPECT_EQ(1, handle_count); 182 EXPECT_EQ(1, handle_count);
183 EXPECT_EQ(3, handle->RefCount()); 183 EXPECT_EQ(3, handle->RefCount());
184 184
185 proxy->FreeFD(0); 185 proxy->FreeFD(0);
186 proxy->FreeFD(2); 186 proxy->FreeFD(2);
187 proxy->ReleaseHandle(handle); // handle is constructed with a refcount of 1. 187 proxy->ReleaseHandle(handle); // handle is constructed with a refcount of 1.
188 188
189 EXPECT_EQ(0, handle_count); 189 EXPECT_EQ(0, handle_count);
190 } 190 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/path.cc ('k') | native_client_sdk/src/libraries/nacl_io_test/mount_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698