example_test.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env python
  2. #
  3. # SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
  4. # SPDX-License-Identifier: Apache-2.0
  5. import os
  6. import re
  7. import tiny_test_fw
  8. import ttfw_idf
  9. from tiny_test_fw import Utility
  10. @ttfw_idf.idf_example_test(env_tag='Example_EthKitV1')
  11. def test_examples_protocol_https_mbedtls(env, extra_data): # type: (tiny_test_fw.Env.Env, None) -> None # pylint: disable=unused-argument
  12. """
  13. steps: |
  14. 1. join AP
  15. 2. connect to www.howsmyssl.com:443
  16. 3. send http request
  17. """
  18. app_name = 'https_mbedtls'
  19. dut1 = env.get_dut(app_name, 'examples/protocols/https_mbedtls', dut_class=ttfw_idf.ESP32DUT)
  20. # check and log bin size
  21. binary_file = os.path.join(dut1.app.binary_path, 'https_mbedtls.bin')
  22. bin_size = os.path.getsize(binary_file)
  23. ttfw_idf.log_performance('https_mbedtls_bin_size', '{}KB'.format(bin_size // 1024))
  24. # start test
  25. dut1.start_app()
  26. dut1.expect('Connected.', timeout=30)
  27. Utility.console_log('TCP connection established with the server\n performing SSL/TLS handshake')
  28. dut1.expect('Performing the SSL/TLS handshake...')
  29. dut1.expect('Certificate verified.')
  30. Utility.console_log('SSL/TLS handshake successful')
  31. dut1.expect('Writing HTTP request...')
  32. dut1.expect('Reading HTTP response...')
  33. dut1.expect(re.compile(r'Completed (\d) requests'))
  34. # Read free heap size
  35. res = dut1.expect(ttfw_idf.MINIMUM_FREE_HEAP_SIZE_RE)
  36. if not res:
  37. raise ValueError('Maximum heap size info not found')
  38. ttfw_idf.print_heap_size(app_name, dut1.app.config_name, dut1.TARGET, res[0])
  39. if __name__ == '__main__':
  40. test_examples_protocol_https_mbedtls() # pylint: disable=no-value-for-parameter