def test_gnrc_tcp_accept_respects_GNRC_TCP_NO_TIMEOUT(child): """ gnrc_tcp_accept timeout mechanism must be disabled if GNRC_TCP_NO_TIMEOUT is set as timeout value. """ pexpect_timeout_sec = _GNRC_TCP_NO_TIMEOUT + 1 riot_srv = RiotTcpServer(child, generate_port_number()) riot_srv.listen() child.sendline('gnrc_tcp_accept {}'.format(_GNRC_TCP_NO_TIMEOUT)) # The test is successful if gnrc_tcp_accept does not return before pexpects timeout. # Afterwards the connection must be still able to accept a connection. returned = True try: child.expect_exact('gnrc_tcp_accept: returns', timeout=pexpect_timeout_sec) except pexpect.TIMEOUT: returned = False finally: if returned: raise RuntimeError('gnrc_tcp_accept returned') # Ensure that gnrc_tcp_accept returns after the test host connects with HostTcpClient(riot_srv): child.expect_exact('gnrc_tcp_accept: returns 0') riot_srv.close()
def test_gnrc_tcp_queue_get_local_returns_0(child): """ This test verifies that queue_get_local returns 0 then put after listen. And the endpoint content is as are as expected. """ # Enter listen with accept all address listen_addr = '::' listen_port = generate_port_number() riot_srv = RiotTcpServer(child, listen_port) riot_srv.listen() riot_srv.queue_get_local() child.expect_exact('Endpoint: addr.ipv6=:: netif=0 port={}'.format( listen_port) ) riot_srv.stop_listen() # Enter listen with specified address listen_addr = 'fe80::4c49:c7ff:fecd:34a3' listen_port = generate_port_number() riot_srv = RiotTcpServer(child, listen_port, listen_addr) riot_srv.listen() riot_srv.queue_get_local() child.expect_exact('Endpoint: addr.ipv6={} netif=0 port={}'.format( listen_addr, listen_port) ) riot_srv.stop_listen()
def test_gnrc_tcp_accept_returns_ETIMEDOUT(child): """ gnrc_tcp_accept must return with -ETIMEDOUT if no connection is ready and timeout is not 0 """ riot_srv = RiotTcpServer(child, generate_port_number()) riot_srv.listen() child.sendline('gnrc_tcp_accept 1000') child.expect_exact('gnrc_tcp_accept: returns -ETIMEDOUT')