@@ -23,33 +23,32 @@ TEST(LlvmLibcSysIoctlTest, TestFileFIONREAD) {
2323 constexpr const char TEST_MSG[] = " ioctl test" ;
2424 constexpr int TEST_MSG_SIZE = sizeof (TEST_MSG) - 1 ;
2525 constexpr const char *TEST_FILE = " testdata/ioctl.test" ;
26- int test_file_fd = LIBC_NAMESPACE::open (TEST_FILE, O_RDONLY);
27- ASSERT_GT (test_file_fd, 0 );
26+ int fd = LIBC_NAMESPACE::open (TEST_FILE, O_RDONLY);
2827 ASSERT_ERRNO_SUCCESS ();
28+ ASSERT_GT (fd, 0 );
2929
3030 // FIONREAD reports the number of available bytes to read for the passed fd
3131 // This will report the full size of the file, as we haven't read anything yet
32- int test_file_n = -1 ;
33- int ret = LIBC_NAMESPACE::ioctl (test_file_fd, FIONREAD, &test_file_n);
34- ASSERT_GT (ret, -1 );
32+ int n = -1 ;
33+ int ret = LIBC_NAMESPACE::ioctl (fd, FIONREAD, &n);
3534 ASSERT_ERRNO_SUCCESS ();
36- ASSERT_EQ (test_file_n, TEST_MSG_SIZE);
35+ ASSERT_GT (ret, -1 );
36+ ASSERT_EQ (n, TEST_MSG_SIZE);
3737
3838 // But if we read some bytes...
3939 constexpr int READ_COUNT = 5 ;
40- char buffer [READ_COUNT];
41- ASSERT_THAT (LIBC_NAMESPACE::read (test_file_fd, buffer , READ_COUNT),
40+ char read_buffer [READ_COUNT];
41+ ASSERT_THAT (( int ) LIBC_NAMESPACE::read (fd, read_buffer , READ_COUNT),
4242 Succeeds (READ_COUNT));
4343
4444 // ... n should have decreased by the number of bytes we've read
45- int test_file_n_after_reading = -1 ;
46- ret =
47- LIBC_NAMESPACE::ioctl (test_file_fd, FIONREAD, &test_file_n_after_reading);
48- ASSERT_GT (ret, -1 );
45+ int n_after_reading = -1 ;
46+ ret = LIBC_NAMESPACE::ioctl (fd, FIONREAD, &n_after_reading);
4947 ASSERT_ERRNO_SUCCESS ();
50- ASSERT_EQ (test_file_n - READ_COUNT, test_file_n_after_reading);
48+ ASSERT_GT (ret, -1 );
49+ ASSERT_EQ (n - READ_COUNT, n_after_reading);
5150
52- ASSERT_THAT (LIBC_NAMESPACE::close (test_file_fd ), Succeeds (0 ));
51+ ASSERT_THAT (LIBC_NAMESPACE::close (fd ), Succeeds (0 ));
5352}
5453
5554TEST (LlvmLibcSysIoctlTest, InvalidIoctlCommand) {
0 commit comments