Skip to content

Commit 6729493

Browse files
jeplerdpgeorge
authored andcommitted
tests/extmod: Test websocket too-big packet transmission.
Signed-off-by: Jeff Epler <[email protected]>
1 parent 8013ef4 commit 6729493

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

tests/extmod/websocket_toobig.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
try:
2+
import io
3+
import errno
4+
import websocket
5+
except ImportError:
6+
print("SKIP")
7+
raise SystemExit
8+
9+
try:
10+
buf = "x" * 65536
11+
except MemoryError:
12+
print("SKIP")
13+
raise SystemExit
14+
15+
16+
# do a websocket write and then return the raw data from the stream
17+
def ws_write(msg, sz):
18+
s = io.BytesIO()
19+
ws = websocket.websocket(s)
20+
ws.write(msg)
21+
s.seek(0)
22+
return s.read(sz)
23+
24+
25+
try:
26+
print(ws_write(buf, 1))
27+
except OSError as e:
28+
print("ioctl: ENOBUFS:", e.errno == errno.ENOBUFS)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ioctl: ENOBUFS: True

0 commit comments

Comments
 (0)