Skip to content

Commit 924ed4c

Browse files
committed
fix inappropriate ioctl for device in ioctl tests
1 parent d628541 commit 924ed4c

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

libc/test/src/sys/ioctl/linux/ioctl_test.cpp

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,20 @@
1717
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
1818
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
1919

20-
TEST(LlvmLibcSysIoctlTest, NullAndTestFileFIONREAD) {
20+
TEST(LlvmLibcSysIoctlTest, TestFileFIONREAD) {
2121
LIBC_NAMESPACE::libc_errno = 0;
2222

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
3823
constexpr const char TEST_MSG[] = "ioctl test";
3924
constexpr int TEST_MSG_SIZE = sizeof(TEST_MSG) - 1;
4025
constexpr const char *TEST_FILE = "testdata/ioctl.test";
4126
int test_file_fd = LIBC_NAMESPACE::open(TEST_FILE, O_RDONLY);
4227
ASSERT_GT(test_file_fd, 0);
4328
ASSERT_ERRNO_SUCCESS();
4429

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
4632
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);
4834
ASSERT_GT(ret, -1);
4935
ASSERT_ERRNO_SUCCESS();
5036
ASSERT_EQ(test_file_n, TEST_MSG_SIZE);

0 commit comments

Comments
 (0)