example_test.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/env python
  2. #
  3. # Copyright 2021 Espressif Systems (Shanghai) CO LTD
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. import os
  17. import re
  18. import tiny_test_fw
  19. import ttfw_idf
  20. from tiny_test_fw import Utility
  21. @ttfw_idf.idf_example_test(env_tag='Example_EthKitV1')
  22. def test_examples_protocol_https_mbedtls(env, extra_data): # type: (tiny_test_fw.Env.Env, None) -> None # pylint: disable=unused-argument
  23. """
  24. steps: |
  25. 1. join AP
  26. 2. connect to www.howsmyssl.com:443
  27. 3. send http request
  28. """
  29. app_name = 'https_mbedtls'
  30. dut1 = env.get_dut(app_name, 'examples/protocols/https_mbedtls', dut_class=ttfw_idf.ESP32DUT)
  31. # check and log bin size
  32. binary_file = os.path.join(dut1.app.binary_path, 'https-mbedtls.bin')
  33. bin_size = os.path.getsize(binary_file)
  34. ttfw_idf.log_performance('https_mbedtls_bin_size', '{}KB'.format(bin_size // 1024))
  35. # start test
  36. dut1.start_app()
  37. dut1.expect('Connected.', timeout=30)
  38. Utility.console_log('TCP connection established with the server\n performing SSL/TLS handshake')
  39. dut1.expect('Performing the SSL/TLS handshake...')
  40. dut1.expect('Certificate verified.')
  41. Utility.console_log('SSL/TLS handshake successful')
  42. dut1.expect('Writing HTTP request...')
  43. dut1.expect('Reading HTTP response...')
  44. dut1.expect(re.compile(r'Completed (\d) requests'))
  45. # Read free heap size
  46. res = dut1.expect(ttfw_idf.MINIMUM_FREE_HEAP_SIZE_RE)
  47. if not res:
  48. raise ValueError('Maximum heap size info not found')
  49. ttfw_idf.print_heap_size(app_name, dut1.app.config_name, dut1.TARGET, res[0])
  50. if __name__ == '__main__':
  51. test_examples_protocol_https_mbedtls() # pylint: disable=no-value-for-parameter