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

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

Issue 125693002: Implement lstat by stat in nacl_io (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/kernel_proxy.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 #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 <stdio.h> 8 #include <stdio.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 10
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 ASSERT_EQ(4, ki_write(dup_fd, "more", 4)); 409 ASSERT_EQ(4, ki_write(dup_fd, "more", 4));
410 410
411 ASSERT_EQ(0, ki_close(dup2_fd)); 411 ASSERT_EQ(0, ki_close(dup2_fd));
412 // fd, new_fd -> "/bar" 412 // fd, new_fd -> "/bar"
413 // dup_fd -> "/foo" 413 // dup_fd -> "/foo"
414 414
415 ASSERT_EQ(dup_fd, ki_dup2(fd, dup_fd)); 415 ASSERT_EQ(dup_fd, ki_dup2(fd, dup_fd));
416 // fd, new_fd, dup_fd -> "/bar" 416 // fd, new_fd, dup_fd -> "/bar"
417 } 417 }
418 418
419 TEST_F(KernelProxyTest, Lstat) {
420 int fd = ki_open("/foo", O_CREAT | O_RDWR);
421 ASSERT_GT(fd, -1);
422 ASSERT_EQ(0, ki_mkdir("/bar", S_IREAD | S_IWRITE));
423
424 struct stat buf;
425 EXPECT_EQ(0, ki_lstat("/foo", &buf));
426 EXPECT_EQ(0, buf.st_size);
427 EXPECT_TRUE(S_ISREG(buf.st_mode));
428
429 EXPECT_EQ(0, ki_lstat("/bar", &buf));
430 EXPECT_EQ(0, buf.st_size);
431 EXPECT_TRUE(S_ISDIR(buf.st_mode));
432
433 EXPECT_EQ(-1, ki_lstat("/no-such-file", &buf));
434 EXPECT_EQ(ENOENT, errno);
435 }
436
419 namespace { 437 namespace {
420 438
421 StringMap_t g_string_map; 439 StringMap_t g_string_map;
422 440
423 class KernelProxyMountTest_Filesystem : public MemFs { 441 class KernelProxyMountTest_Filesystem : public MemFs {
424 public: 442 public:
425 using MemFs::Init; 443 using MemFs::Init;
426 444
427 virtual Error Init(const FsInitArgs& args) { 445 virtual Error Init(const FsInitArgs& args) {
428 g_string_map = args.string_map; 446 g_string_map = args.string_map;
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 685
668 int fd = ki_open("/dummy", O_RDONLY); 686 int fd = ki_open("/dummy", O_RDONLY);
669 EXPECT_NE(0, fd); 687 EXPECT_NE(0, fd);
670 688
671 char buf[20]; 689 char buf[20];
672 EXPECT_EQ(-1, ki_read(fd, &buf[0], 20)); 690 EXPECT_EQ(-1, ki_read(fd, &buf[0], 20));
673 // The Filesystem should be able to return whatever error it wants and have it 691 // The Filesystem should be able to return whatever error it wants and have it
674 // propagate through. 692 // propagate through.
675 EXPECT_EQ(1234, errno); 693 EXPECT_EQ(1234, errno);
676 } 694 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698