[riot-notifications] [RIOT-OS/RIOT] tests: provide testcase for issue 11398 (#11401)

Gaëtan Harter notifications at github.com
Tue Apr 30 20:08:49 CEST 2019

cladmi commented on this pull request.

> +    global the_socket
+    assert(the_socket is not None)
+    now = int(system_to_ntp_time(time.time()))
+    payload = b"\x01\xdc\x00\x23\x00\x5a\x45\x00\x0a\x50\x45\x5a\x00"
+    packet = struct.pack(ZEP_HDR, b"EX", ZEP_V2_VERSION,
+                         ZEP_V2_TYPE_DATA, 26, 1, 1, 0xff,
+                         now, 0, 1, len(payload)) + payload
+    the_socket.sendto(packet, ("::1", 17755))
+    res = child.expect([TIMEOUT, EOF, "PKTDUMP: data received:"])
+    # we actually want the timeout here. The application either receives a
+    # bogus packet or crashes in an error case case
+    assert(res == 0)
+if __name__ == "__main__":
+    with socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) as s:

In general, if a test would require some setup that needs to be done before `testfunc` I would prefer a pattern with `testmain():` that calls then `sys.exit(run(_testfunc))` after initialization.

This would allow "knowing" when importing what should be called directly or not. I should put this in a documentation PR for review I think.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190430/160ac77a/attachment.html>

More information about the notifications mailing list