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

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

Issue 16122002: [NaCl SDK] MountNodeDir::GetDents sets d_off instead of leaving it undefined. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 6 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
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_node_dir.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 8
9 #include "nacl_io/kernel_proxy.h" 9 #include "nacl_io/kernel_proxy.h"
10 #include "nacl_io/mount_node.h" 10 #include "nacl_io/mount_node.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 EXPECT_EQ(0, file->GetSize()); 100 EXPECT_EQ(0, file->GetSize());
101 EXPECT_EQ(0, file->Read(0, buf2, sizeof(buf2))); 101 EXPECT_EQ(0, file->Read(0, buf2, sizeof(buf2)));
102 EXPECT_EQ(0, file->GetSize()); 102 EXPECT_EQ(0, file->GetSize());
103 EXPECT_EQ(sizeof(buf1), file->Write(0, buf1, sizeof(buf1))); 103 EXPECT_EQ(sizeof(buf1), file->Write(0, buf1, sizeof(buf1)));
104 EXPECT_EQ(sizeof(buf1), file->GetSize()); 104 EXPECT_EQ(sizeof(buf1), file->GetSize());
105 EXPECT_EQ(sizeof(buf1), file->Read(0, buf2, sizeof(buf2))); 105 EXPECT_EQ(sizeof(buf1), file->Read(0, buf2, sizeof(buf2)));
106 EXPECT_EQ(0, memcmp(buf1, buf2, sizeof(buf1))); 106 EXPECT_EQ(0, memcmp(buf1, buf2, sizeof(buf1)));
107 107
108 struct stat s; 108 struct stat s;
109 EXPECT_EQ(0, file->GetStat(&s)); 109 EXPECT_EQ(0, file->GetStat(&s));
110 EXPECT_LT(0, s.st_ino); // 0 is an invalid inode number.
110 EXPECT_EQ(sizeof(buf1), s.st_size); 111 EXPECT_EQ(sizeof(buf1), s.st_size);
111 112
112 // Directory operations should fail 113 // Directory operations should fail
113 struct dirent d; 114 struct dirent d;
114 EXPECT_EQ(-1, file->GetDents(0, &d, sizeof(d))); 115 EXPECT_EQ(-1, file->GetDents(0, &d, sizeof(d)));
115 EXPECT_EQ(errno, ENOTDIR); 116 EXPECT_EQ(errno, ENOTDIR);
116 EXPECT_EQ(-1, file->AddChild("", file)); 117 EXPECT_EQ(-1, file->AddChild("", file));
117 EXPECT_EQ(errno, ENOTDIR); 118 EXPECT_EQ(errno, ENOTDIR);
118 EXPECT_EQ(-1, file->RemoveChild("")); 119 EXPECT_EQ(-1, file->RemoveChild(""));
119 EXPECT_EQ(errno, ENOTDIR); 120 EXPECT_EQ(errno, ENOTDIR);
(...skipping 30 matching lines...) Expand all
150 151
151 EXPECT_EQ(1, root->RefCount()); 152 EXPECT_EQ(1, root->RefCount());
152 EXPECT_EQ(1, file->RefCount()); 153 EXPECT_EQ(1, file->RefCount());
153 EXPECT_EQ(0, root->AddChild("F1", file)); 154 EXPECT_EQ(0, root->AddChild("F1", file));
154 EXPECT_EQ(1, file->GetLinks()); 155 EXPECT_EQ(1, file->GetLinks());
155 EXPECT_EQ(2, file->RefCount()); 156 EXPECT_EQ(2, file->RefCount());
156 157
157 // Test that the directory is there 158 // Test that the directory is there
158 struct dirent d; 159 struct dirent d;
159 EXPECT_EQ(sizeof(d), root->GetDents(0, &d, sizeof(d))); 160 EXPECT_EQ(sizeof(d), root->GetDents(0, &d, sizeof(d)));
161 EXPECT_LT(0, d.d_ino); // 0 is an invalid inode number.
162 EXPECT_EQ(sizeof(d), d.d_off);
163 EXPECT_EQ(sizeof(d), d.d_reclen);
160 EXPECT_EQ(0, strcmp("F1", d.d_name)); 164 EXPECT_EQ(0, strcmp("F1", d.d_name));
161 EXPECT_EQ(0, root->GetDents(sizeof(d), &d, sizeof(d))); 165 EXPECT_EQ(0, root->GetDents(sizeof(d), &d, sizeof(d)));
162 166
163 EXPECT_EQ(0, root->AddChild("F2", file)); 167 EXPECT_EQ(0, root->AddChild("F2", file));
164 EXPECT_EQ(2, file->GetLinks()); 168 EXPECT_EQ(2, file->GetLinks());
165 EXPECT_EQ(3, file->RefCount()); 169 EXPECT_EQ(3, file->RefCount());
166 EXPECT_EQ(-1, root->AddChild("F1", file)); 170 EXPECT_EQ(-1, root->AddChild("F1", file));
167 EXPECT_EQ(EEXIST, errno); 171 EXPECT_EQ(EEXIST, errno);
168 EXPECT_EQ(2, file->GetLinks()); 172 EXPECT_EQ(2, file->GetLinks());
169 173
(...skipping 11 matching lines...) Expand all
181 EXPECT_EQ(0, file->GetLinks()); 185 EXPECT_EQ(0, file->GetLinks());
182 EXPECT_EQ(1, file->RefCount()); 186 EXPECT_EQ(1, file->RefCount());
183 EXPECT_EQ(2, s_AllocNum); 187 EXPECT_EQ(2, s_AllocNum);
184 188
185 file->Release(); 189 file->Release();
186 EXPECT_EQ(1, s_AllocNum); 190 EXPECT_EQ(1, s_AllocNum);
187 root->Release(); 191 root->Release();
188 EXPECT_EQ(0, s_AllocNum); 192 EXPECT_EQ(0, s_AllocNum);
189 } 193 }
190 194
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_node_dir.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698