mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +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
|
# 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:
|
try:
|
||||||
from micropython import heap_lock, heap_unlock
|
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
|
# test with heap locked to see it switch to number-only error message
|
||||||
def test(addr):
|
def test(addr):
|
||||||
|
ctx = tls.SSLContext(tls.PROTOCOL_TLS_CLIENT)
|
||||||
|
ctx.verify_mode = tls.CERT_NONE
|
||||||
s = socket.socket()
|
s = socket.socket()
|
||||||
s.connect(addr)
|
s.connect(addr)
|
||||||
try:
|
try:
|
||||||
s.setblocking(False)
|
s.setblocking(False)
|
||||||
s = ssl.wrap_socket(s, do_handshake=False)
|
s = ctx.wrap_socket(s, do_handshake_on_connect=False)
|
||||||
heap_lock()
|
heap_lock()
|
||||||
print("heap is locked")
|
print("heap is locked")
|
||||||
while True:
|
while True:
|
||||||
|
|||||||
Reference in New Issue
Block a user