summaryrefslogtreecommitdiff
path: root/tests/extmod/websocket_toobig.py
blob: f4c5a74bbceac0079b3e8bf87aa86ed9b19f194c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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)