pytest_https_mbedtls.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/usr/bin/env python
  2. #
  3. # SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  4. # SPDX-License-Identifier: Apache-2.0
  5. import logging
  6. import os
  7. import pytest
  8. from pytest_embedded import Dut
  9. @pytest.mark.esp32
  10. @pytest.mark.esp32c3
  11. @pytest.mark.esp32s2
  12. @pytest.mark.esp32s3
  13. @pytest.mark.ethernet
  14. def test_examples_protocol_https_mbedtls(dut: Dut) -> None:
  15. """
  16. steps: |
  17. 1. join AP
  18. 2. connect to www.howsmyssl.com:443
  19. 3. send http request
  20. """
  21. # check and log bin size
  22. binary_file = os.path.join(dut.app.binary_path, 'https_mbedtls.bin')
  23. bin_size = os.path.getsize(binary_file)
  24. logging.info('https_mbedtls_bin_size : {}KB'.format(bin_size // 1024))
  25. # start test
  26. dut.expect('Connected.', timeout=30)
  27. logging.info('TCP connection established with the server\n performing SSL/TLS handshake')
  28. dut.expect('Performing the SSL/TLS handshake...')
  29. dut.expect('Certificate verified.')
  30. logging.info('SSL/TLS handshake successful')
  31. dut.expect('Writing HTTP request...')
  32. dut.expect('Reading HTTP response...')
  33. dut.expect(r'Completed (\d) requests')
  34. # Read free heap size
  35. res = dut.expect(r'Minimum free heap size: (\d+)')[1].decode()
  36. if not res:
  37. raise ValueError('Maximum heap size info not found')