diff options
author | Angus Gratton <angus@redyak.com.au> | 2025-05-01 16:24:13 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2025-05-02 17:24:58 +1000 |
commit | 79abdad9e97f18f45650e1abce64ee51c3372953 (patch) | |
tree | cb63d72006f20f4ca5505726833dd207f287d872 /tests/extmod/tls_noleak.py | |
parent | 70ed3151933635429a66937bae2701958b6b47dd (diff) | |
download | micropython-79abdad9e97f18f45650e1abce64ee51c3372953.tar.gz micropython-79abdad9e97f18f45650e1abce64ee51c3372953.zip |
tests/extmod: Rename ssl tests that only use the tls module.
Signed-off-by: Angus Gratton <angus@redyak.com.au>
Diffstat (limited to 'tests/extmod/tls_noleak.py')
-rw-r--r-- | tests/extmod/tls_noleak.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/extmod/tls_noleak.py b/tests/extmod/tls_noleak.py new file mode 100644 index 0000000000..870032d58e --- /dev/null +++ b/tests/extmod/tls_noleak.py @@ -0,0 +1,50 @@ +# Ensure that SSLSockets can be allocated sequentially +# without running out of available memory. +try: + import io + import tls +except ImportError: + print("SKIP") + raise SystemExit + +import unittest + + +class TestSocket(io.IOBase): + def write(self, buf): + return len(buf) + + def readinto(self, buf): + return 0 + + def ioctl(self, cmd, arg): + return 0 + + def setblocking(self, value): + pass + + +ITERS = 128 + + +class TLSNoLeaks(unittest.TestCase): + def test_unique_context(self): + for n in range(ITERS): + print(n) + s = TestSocket() + ctx = tls.SSLContext(tls.PROTOCOL_TLS_CLIENT) + ctx.verify_mode = tls.CERT_NONE + s = ctx.wrap_socket(s, do_handshake_on_connect=False) + + def test_shared_context(self): + # Single SSLContext, multiple sockets + ctx = tls.SSLContext(tls.PROTOCOL_TLS_CLIENT) + ctx.verify_mode = tls.CERT_NONE + for n in range(ITERS): + print(n) + s = TestSocket() + s = ctx.wrap_socket(s, do_handshake_on_connect=False) + + +if __name__ == "__main__": + unittest.main() |