| OLD | NEW |
| 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 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 EXPECT_EQ(-1, ki_open("/", O_WRONLY, 0)); | 560 EXPECT_EQ(-1, ki_open("/", O_WRONLY, 0)); |
| 561 EXPECT_EQ(errno, EISDIR); | 561 EXPECT_EQ(errno, EISDIR); |
| 562 } | 562 } |
| 563 | 563 |
| 564 TEST_F(KernelProxyTest, OpenWithMode) { | 564 TEST_F(KernelProxyTest, OpenWithMode) { |
| 565 int fd = ki_open("/foo", O_CREAT | O_RDWR, 0723); | 565 int fd = ki_open("/foo", O_CREAT | O_RDWR, 0723); |
| 566 ASSERT_GT(fd, -1); | 566 ASSERT_GT(fd, -1); |
| 567 | 567 |
| 568 struct stat buf; | 568 struct stat buf; |
| 569 EXPECT_EQ(0, ki_lstat("/foo", &buf)); | 569 EXPECT_EQ(0, ki_lstat("/foo", &buf)); |
| 570 EXPECT_EQ(0723, buf.st_mode & ~S_IFMT); | 570 EXPECT_EQ(0723, buf.st_mode & 0777); |
| 571 } | 571 } |
| 572 | 572 |
| 573 TEST_F(KernelProxyTest, CreateWronlyWithReadOnlyMode) { | 573 TEST_F(KernelProxyTest, CreateWronlyWithReadOnlyMode) { |
| 574 int fd = ki_open("/foo", O_CREAT | O_WRONLY, 0444); | 574 int fd = ki_open("/foo", O_CREAT | O_WRONLY, 0444); |
| 575 ASSERT_GT(fd, -1); | 575 ASSERT_GT(fd, -1); |
| 576 } | 576 } |
| 577 | 577 |
| 578 TEST_F(KernelProxyTest, UseAfterClose) { | 578 TEST_F(KernelProxyTest, UseAfterClose) { |
| 579 int fd = ki_open("/dummy", O_CREAT | O_WRONLY, 0777); | 579 int fd = ki_open("/dummy", O_CREAT | O_WRONLY, 0777); |
| 580 ASSERT_GT(fd, -1); | 580 ASSERT_GT(fd, -1); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 656 EXPECT_EQ(0, oldmask); | 656 EXPECT_EQ(0, oldmask); |
| 657 | 657 |
| 658 int fd = ki_open("/foo", O_CREAT | O_RDONLY, 0666); | 658 int fd = ki_open("/foo", O_CREAT | O_RDONLY, 0666); |
| 659 ASSERT_GT(fd, -1); | 659 ASSERT_GT(fd, -1); |
| 660 ki_close(fd); | 660 ki_close(fd); |
| 661 | 661 |
| 662 EXPECT_EQ(0, ki_mkdir("/dir", 0777)); | 662 EXPECT_EQ(0, ki_mkdir("/dir", 0777)); |
| 663 | 663 |
| 664 struct stat buf; | 664 struct stat buf; |
| 665 EXPECT_EQ(0, ki_stat("/foo", &buf)); | 665 EXPECT_EQ(0, ki_stat("/foo", &buf)); |
| 666 EXPECT_EQ(0444, buf.st_mode & ~S_IFMT); | 666 EXPECT_EQ(0444, buf.st_mode & 0777); |
| 667 | 667 |
| 668 EXPECT_EQ(0, ki_stat("/dir", &buf)); | 668 EXPECT_EQ(0, ki_stat("/dir", &buf)); |
| 669 EXPECT_EQ(0555, buf.st_mode & ~S_IFMT); | 669 EXPECT_EQ(0555, buf.st_mode & 0777); |
| 670 | 670 |
| 671 EXPECT_EQ(0222, ki_umask(0)); | 671 EXPECT_EQ(0222, ki_umask(0)); |
| 672 } | 672 } |
| 673 | 673 |
| 674 namespace { | 674 namespace { |
| 675 | 675 |
| 676 StringMap_t g_string_map; | 676 StringMap_t g_string_map; |
| 677 bool g_fs_ioctl_called; | 677 bool g_fs_ioctl_called; |
| 678 int g_fs_dev; | 678 int g_fs_dev; |
| 679 | 679 |
| (...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 | 995 |
| 996 int fd = ki_open("/dummy", O_RDONLY, 0); | 996 int fd = ki_open("/dummy", O_RDONLY, 0); |
| 997 EXPECT_NE(0, fd); | 997 EXPECT_NE(0, fd); |
| 998 | 998 |
| 999 char buf[20]; | 999 char buf[20]; |
| 1000 EXPECT_EQ(-1, ki_read(fd, &buf[0], 20)); | 1000 EXPECT_EQ(-1, ki_read(fd, &buf[0], 20)); |
| 1001 // The Filesystem should be able to return whatever error it wants and have it | 1001 // The Filesystem should be able to return whatever error it wants and have it |
| 1002 // propagate through. | 1002 // propagate through. |
| 1003 EXPECT_EQ(1234, errno); | 1003 EXPECT_EQ(1234, errno); |
| 1004 } | 1004 } |
| OLD | NEW |