mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
tests/net_inet/tls_num_errors.py: Switch to tls mod and require mbedTLS.
This test is very specific to mbedTLS and how it raises errors when the heap is locked. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
# test that modtls produces a numerical error message when out of heap
|
||||
|
||||
import socket, ssl, sys
|
||||
import socket, tls
|
||||
|
||||
# This test is specific to the mbedTLS implementation, so require that.
|
||||
if not hasattr(tls, "MBEDTLS_VERSION"):
|
||||
print("SKIP")
|
||||
raise SystemExit
|
||||
|
||||
try:
|
||||
from micropython import heap_lock, heap_unlock
|
||||
@@ -18,11 +23,13 @@ except:
|
||||
|
||||
# test with heap locked to see it switch to number-only error message
|
||||
def test(addr):
|
||||
ctx = tls.SSLContext(tls.PROTOCOL_TLS_CLIENT)
|
||||
ctx.verify_mode = tls.CERT_NONE
|
||||
s = socket.socket()
|
||||
s.connect(addr)
|
||||
try:
|
||||
s.setblocking(False)
|
||||
s = ssl.wrap_socket(s, do_handshake=False)
|
||||
s = ctx.wrap_socket(s, do_handshake_on_connect=False)
|
||||
heap_lock()
|
||||
print("heap is locked")
|
||||
while True:
|
||||
|
||||
Reference in New Issue
Block a user