Skip to content

Commit

Permalink
gnrc_tcp: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brummer-simon committed Oct 14, 2020
1 parent 627060b commit 3ea8961
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/gnrc_tcp/tests/05-garbage-pkts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# directory for more details.

import base64
import pexpect
import os
import socket
import sys
Expand Down Expand Up @@ -96,14 +97,25 @@ def test_short_header(child, src_if, src_ll, dst_if, dst_l2, dst_ll, dst_port):
@testfunc
def test_send_ack_instead_of_syn(child, src_if, src_ll,
dst_if, dst_l2, dst_ll, dst_port):
# check if entering _event_loop in `@testfunc` decorator generates debug
# output
debug = child.expect([pexpect.TIMEOUT, 'GNRC_TCP'], timeout=1)
# with debug output the node can be overwhelmed by packets + output
if debug:
count = 10
else:
count = 1000

print(debug)
print(count)
# see https://github.com/RIOT-OS/RIOT/pull/12001
provided_data = base64.b64decode("rwsQf2pekYLaU+exUBBwgPDKAAA=")
tcp_hdr = TCP(provided_data)
assert provided_data == raw(tcp_hdr)
# set destination port to application specific port
tcp_hdr.dport = dst_port
sendp(Ether(dst=dst_l2) / IPv6(src=src_ll, dst=dst_ll) / tcp_hdr,
iface=src_if, verbose=0, count=1000)
iface=src_if, verbose=0, count=count)

# check if server actually still works
with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as sock:
Expand Down Expand Up @@ -140,7 +152,7 @@ def test_option_parsing_term(child, src_if, src_ll,
if type(getattr(script, t)).__name__ == "function"
and t.startswith("test_")]
for test in tests:
res = run(test, timeout=10, echo=False)
res = run(test, timeout=10, echo=True)
if res != 0:
sys.exit(res)
print(os.path.basename(sys.argv[0]) + ": success\n")

0 comments on commit 3ea8961

Please sign in to comment.