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

Gaƫtan Harter notifications at github.com
Tue Apr 30 19:28:38 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:

Could you do this in the `testfunc` instead of here?
I really dislike having important job done inside the `if __name__ == '__main__'` in `python` in general.
It breaks executing the code when imported as this part is on purpose removed.

It also needs `global` so, shows for me the architecture issue.
It could be done with `testfunc` and `_testfunc(child, socket)` if needed.

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/6f0691c9/attachment.html>

More information about the notifications mailing list