pytest_https_mbedtls.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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.ethernet
  11. def test_examples_protocol_https_mbedtls(dut: Dut) -> None:
  12. """
  13. steps: |
  14. 1. join AP
  15. 2. connect to www.howsmyssl.com:443
  16. 3. send http request
  17. """
  18. # check and log bin size
  19. binary_file = os.path.join(dut.app.binary_path, 'https_mbedtls.bin')
  20. bin_size = os.path.getsize(binary_file)
  21. logging.info('https_mbedtls_bin_size : {}KB'.format(bin_size // 1024))
  22. # start test
  23. dut.expect('Connected.', timeout=30)
  24. logging.info('TCP connection established with the server\n performing SSL/TLS handshake')
  25. dut.expect('Performing the SSL/TLS handshake...')
  26. dut.expect('Certificate verified.')
  27. logging.info('SSL/TLS handshake successful')
  28. dut.expect('Writing HTTP request...')
  29. dut.expect('Reading HTTP response...')
  30. dut.expect(r'Completed (\d) requests')
  31. # Read free heap size
  32. res = dut.expect(r'Minimum free heap size: (\d+)')[1].decode()
  33. if not res:
  34. raise ValueError('Maximum heap size info not found')