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

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

Issue 15800004: [NaCl SDK] nacl_io: Added support for access() syscall. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to HEAD. 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
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 <string.h> 8 #include <string.h>
9 #include <gmock/gmock.h> 9 #include <gmock/gmock.h>
10 #include <ppapi/c/ppb_file_io.h> 10 #include <ppapi/c/ppb_file_io.h>
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 TEST_F(MountHtml5FsTest, FilesystemType) { 313 TEST_F(MountHtml5FsTest, FilesystemType) {
314 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 100); 314 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 100);
315 315
316 StringMap_t map; 316 StringMap_t map;
317 map["type"] = "PERSISTENT"; 317 map["type"] = "PERSISTENT";
318 map["expected_size"] = "100"; 318 map["expected_size"] = "100";
319 MountHtml5FsMock mnt(map, ppapi_); 319 MountHtml5FsMock mnt(map, ppapi_);
320 } 320 }
321 321
322 TEST_F(MountHtml5FsTest, Access) {
323 const char path[] = "/foo";
324 const PP_Resource fileref_resource = 235;
325 const PP_Resource fileio_resource = 236;
326
327 // These are the default values.
328 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 0);
329
330 FileRefInterfaceMock* fileref = ppapi_->GetFileRefInterface();
331 FileIoInterfaceMock* fileio = ppapi_->GetFileIoInterface();
332
333 EXPECT_CALL(*fileref, Create(filesystem_resource_, StrEq(&path[0])))
334 .WillOnce(Return(fileref_resource));
335 PP_FileInfo info;
336 memset(&info, 0, sizeof(PP_FileInfo));
337 info.type = PP_FILETYPE_REGULAR;
338 EXPECT_CALL(*fileref, Query(fileref_resource, _, _))
339 .WillOnce(DoAll(SetArgPointee<1>(info),
340 Return(int32_t(PP_OK))));
341 EXPECT_CALL(*fileio, Create(instance_)).WillOnce(Return(fileio_resource));
342 int32_t open_flags = PP_FILEOPENFLAG_READ;
343 EXPECT_CALL(*fileio,
344 Open(fileio_resource, fileref_resource, open_flags, _))
345 .WillOnce(Return(int32_t(PP_OK)));
346 EXPECT_CALL(*fileio, Close(fileio_resource));
347 EXPECT_CALL(*fileio, Flush(fileio_resource, _));
348 EXPECT_CALL(*ppapi_, ReleaseResource(fileio_resource));
349 EXPECT_CALL(*ppapi_, ReleaseResource(fileref_resource));
350
351 StringMap_t map;
352 MountHtml5FsMock mnt(map, ppapi_);
353
354 ASSERT_EQ(0, mnt.Access(Path(path), R_OK | W_OK | X_OK));
355 }
356
357 TEST_F(MountHtml5FsTest, AccessFileNotFound) {
358 const char path[] = "/foo";
359 const PP_Resource fileref_resource = 235;
360 const PP_Resource fileio_resource = 236;
361
362 // These are the default values.
363 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 0);
364
365 FileRefInterfaceMock* fileref = ppapi_->GetFileRefInterface();
366 FileIoInterfaceMock* fileio = ppapi_->GetFileIoInterface();
367
368 // Report the file as missing.
369 EXPECT_CALL(*fileref, Create(filesystem_resource_, StrEq(&path[0])))
370 .WillOnce(Return(fileref_resource));
371 PP_FileInfo info;
372 memset(&info, 0, sizeof(PP_FileInfo));
373 info.type = PP_FILETYPE_REGULAR;
374 EXPECT_CALL(*fileref, Query(fileref_resource, _, _))
375 .WillOnce(DoAll(SetArgPointee<1>(info),
376 Return(int32_t(PP_ERROR_FILENOTFOUND))));
377 EXPECT_CALL(*fileio, Create(instance_)).WillOnce(Return(fileio_resource));
378 int32_t open_flags = PP_FILEOPENFLAG_READ;
379 EXPECT_CALL(*fileio,
380 Open(fileio_resource, fileref_resource, open_flags, _))
381 .WillOnce(Return(int32_t(PP_ERROR_FILENOTFOUND)));
382 EXPECT_CALL(*fileio, Close(fileio_resource));
383 EXPECT_CALL(*fileio, Flush(fileio_resource, _));
384 EXPECT_CALL(*ppapi_, ReleaseResource(fileio_resource));
385 EXPECT_CALL(*ppapi_, ReleaseResource(fileref_resource));
386
387 StringMap_t map;
388 MountHtml5FsMock mnt(map, ppapi_);
389
390 ASSERT_EQ(ENOENT, mnt.Access(Path(path), F_OK));
391 }
392
322 TEST_F(MountHtml5FsTest, Mkdir) { 393 TEST_F(MountHtml5FsTest, Mkdir) {
323 const char path[] = "/foo"; 394 const char path[] = "/foo";
324 const PP_Resource fileref_resource = 235; 395 const PP_Resource fileref_resource = 235;
325 396
326 // These are the default values. 397 // These are the default values.
327 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 0); 398 SetUpFilesystemExpectations(PP_FILESYSTEMTYPE_LOCALPERSISTENT, 0);
328 399
329 FileRefInterfaceMock* fileref = ppapi_->GetFileRefInterface(); 400 FileRefInterfaceMock* fileref = ppapi_->GetFileRefInterface();
330 401
331 EXPECT_CALL(*fileref, Create(filesystem_resource_, StrEq(&path[0]))) 402 EXPECT_CALL(*fileref, Create(filesystem_resource_, StrEq(&path[0])))
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 ASSERT_EQ(sizeof(dirent) * 2, result_bytes); 622 ASSERT_EQ(sizeof(dirent) * 2, result_bytes);
552 EXPECT_LT(0, dirents[0].d_ino); // 0 is an invalid inode number. 623 EXPECT_LT(0, dirents[0].d_ino); // 0 is an invalid inode number.
553 EXPECT_EQ(sizeof(dirent), dirents[0].d_off); 624 EXPECT_EQ(sizeof(dirent), dirents[0].d_off);
554 EXPECT_EQ(sizeof(dirent), dirents[0].d_reclen); 625 EXPECT_EQ(sizeof(dirent), dirents[0].d_reclen);
555 EXPECT_STREQ(fileref_name_cstr_1, dirents[0].d_name); 626 EXPECT_STREQ(fileref_name_cstr_1, dirents[0].d_name);
556 EXPECT_LT(0, dirents[1].d_ino); // 0 is an invalid inode number. 627 EXPECT_LT(0, dirents[1].d_ino); // 0 is an invalid inode number.
557 EXPECT_EQ(sizeof(dirent), dirents[1].d_off); 628 EXPECT_EQ(sizeof(dirent), dirents[1].d_off);
558 EXPECT_EQ(sizeof(dirent), dirents[1].d_reclen); 629 EXPECT_EQ(sizeof(dirent), dirents[1].d_reclen);
559 EXPECT_STREQ(fileref_name_cstr_2, dirents[1].d_name); 630 EXPECT_STREQ(fileref_name_cstr_2, dirents[1].d_name);
560 } 631 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698