|
17 | 17 | using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails; |
18 | 18 | using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds; |
19 | 19 |
|
20 | | -TEST(LlvmLibcSysIoctlTest, NullAndTestFileFIONREAD) { |
| 20 | +TEST(LlvmLibcSysIoctlTest, TestFileFIONREAD) { |
21 | 21 | LIBC_NAMESPACE::libc_errno = 0; |
22 | 22 |
|
23 | | - // FIONREAD reports the number of available bytes to read for the passed fd |
24 | | - int dev_zero_fd = LIBC_NAMESPACE::open("/dev/zero", O_RDONLY); |
25 | | - ASSERT_GT(dev_zero_fd, 0); |
26 | | - ASSERT_ERRNO_SUCCESS(); |
27 | | - |
28 | | - // For /dev/zero, this is always 0 |
29 | | - int dev_zero_n = -1; |
30 | | - int ret = LIBC_NAMESPACE::ioctl(dev_zero_fd, FIONREAD, &dev_zero_n); |
31 | | - ASSERT_GT(ret, -1); |
32 | | - ASSERT_ERRNO_SUCCESS(); |
33 | | - ASSERT_EQ(dev_zero_n, 0); |
34 | | - |
35 | | - ASSERT_THAT(LIBC_NAMESPACE::close(dev_zero_fd), Succeeds(0)); |
36 | | - |
37 | | - // Now, with a file known to have a non-zero size |
38 | 23 | constexpr const char TEST_MSG[] = "ioctl test"; |
39 | 24 | constexpr int TEST_MSG_SIZE = sizeof(TEST_MSG) - 1; |
40 | 25 | constexpr const char *TEST_FILE = "testdata/ioctl.test"; |
41 | 26 | int test_file_fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY); |
42 | 27 | ASSERT_GT(test_file_fd, 0); |
43 | 28 | ASSERT_ERRNO_SUCCESS(); |
44 | 29 |
|
45 | | - // This reports the full size of the file, as we haven't read anything yet |
| 30 | + // FIONREAD reports the number of available bytes to read for the passed fd |
| 31 | + // This will report the full size of the file, as we haven't read anything yet |
46 | 32 | int test_file_n = -1; |
47 | | - ret = LIBC_NAMESPACE::ioctl(test_file_fd, FIONREAD, &test_file_n); |
| 33 | + int ret = LIBC_NAMESPACE::ioctl(test_file_fd, FIONREAD, &test_file_n); |
48 | 34 | ASSERT_GT(ret, -1); |
49 | 35 | ASSERT_ERRNO_SUCCESS(); |
50 | 36 | ASSERT_EQ(test_file_n, TEST_MSG_SIZE); |
|
0 commit comments