From 6729493531b1910064ccd1eb95e65ed07f4d0f17 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 4 Oct 2025 19:20:56 -0500 Subject: [PATCH] tests/extmod: Test websocket too-big packet transmission. Signed-off-by: Jeff Epler --- tests/extmod/websocket_toobig.py | 28 ++++++++++++++++++++++++++++ tests/extmod/websocket_toobig.py.exp | 1 + 2 files changed, 29 insertions(+) create mode 100644 tests/extmod/websocket_toobig.py create mode 100644 tests/extmod/websocket_toobig.py.exp diff --git a/tests/extmod/websocket_toobig.py b/tests/extmod/websocket_toobig.py new file mode 100644 index 0000000000..f4c5a74bbc --- /dev/null +++ b/tests/extmod/websocket_toobig.py @@ -0,0 +1,28 @@ +try: + import io + import errno + import websocket +except ImportError: + print("SKIP") + raise SystemExit + +try: + buf = "x" * 65536 +except MemoryError: + print("SKIP") + raise SystemExit + + +# do a websocket write and then return the raw data from the stream +def ws_write(msg, sz): + s = io.BytesIO() + ws = websocket.websocket(s) + ws.write(msg) + s.seek(0) + return s.read(sz) + + +try: + print(ws_write(buf, 1)) +except OSError as e: + print("ioctl: ENOBUFS:", e.errno == errno.ENOBUFS) diff --git a/tests/extmod/websocket_toobig.py.exp b/tests/extmod/websocket_toobig.py.exp new file mode 100644 index 0000000000..3bbd95282f --- /dev/null +++ b/tests/extmod/websocket_toobig.py.exp @@ -0,0 +1 @@ +ioctl: ENOBUFS: True