3#include <gtest/gtest.h>
13class TtyEofTest :
public ::testing::Test
18 ASSERT_EQ(0, socketpair(AF_UNIX, SOCK_STREAM, 0, m_fds));
24 void TearDown()
override
30 EXPECT_EQ(0, close(
fd));
38 const int writer = m_fds[1];
40 ASSERT_EQ(0, close(writer));
43 int m_fds[2] { -1, -1 };
44 std::array<char, 64> m_buffer {};
47TEST_F(TtyEofTest, ReadSectionEmptyEof)
52 EXPECT_EQ(0, nbytesRead);
55TEST_F(TtyEofTest, ReadSectionPartialReplyThenEof)
57 ASSERT_EQ(2, write(m_fds[1],
"AB", 2));
61 EXPECT_EQ(2, nbytesRead);
64TEST_F(TtyEofTest, ReadSectionValidDelimitedReply)
66 ASSERT_EQ(3, write(m_fds[1],
"OK#", 3));
69 EXPECT_EQ(3, nbytesRead);
72TEST_F(TtyEofTest, NReadSectionEmptyEof)
77 EXPECT_EQ(0, nbytesRead);
80TEST_F(TtyEofTest, NReadSectionPartialReplyThenEof)
82 ASSERT_EQ(2, write(m_fds[1],
"AB", 2));
86 EXPECT_EQ(2, nbytesRead);
89TEST_F(TtyEofTest, NReadSectionValidDelimitedReply)
91 ASSERT_EQ(3, write(m_fds[1],
"OK#", 3));
94 EXPECT_EQ(3, nbytesRead);
int tty_read_section(int fd, char *buf, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
int tty_nread_section(int fd, char *buf, int nsize, char stop_char, int timeout, int *nbytes_read)
read buffer from terminal with a delimiter
Implementations for common driver routines.
TEST_F(AlignmentPluginTest, Test_BuiltIn_ErrorRecovery)