example_test.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import os
  2. import re
  3. import ttfw_idf
  4. @ttfw_idf.idf_example_test(env_tag="Example_WIFI", ignore=True)
  5. def test_examples_protocol_https_x509_bundle(env, extra_data):
  6. """
  7. steps: |
  8. 1. join AP
  9. 2. connect to multiple URLs
  10. 3. send http request
  11. """
  12. dut1 = env.get_dut("https_x509_bundle", "examples/protocols/https_x509_bundle")
  13. # check and log bin size
  14. binary_file = os.path.join(dut1.app.binary_path, "https_x509_bundle.bin")
  15. bin_size = os.path.getsize(binary_file)
  16. ttfw_idf.log_performance("https_x509_bundle_bin_size", "{}KB".format(bin_size // 1024))
  17. ttfw_idf.check_performance("https_x509_bundle_bin_size", bin_size // 1024, dut1.TARGET)
  18. # start test
  19. dut1.start_app()
  20. num_URLS = dut1.expect(re.compile(r"Connecting to (\d+) URLs"), timeout=30)
  21. dut1.expect(re.compile(r"Connection established to ([\s\S]*)"), timeout=30)
  22. dut1.expect("Completed {} connections".format(num_URLS[0]), timeout=60)
  23. # test mbedtls dynamic resource
  24. dut1 = env.get_dut("https_x509_bundle", "examples/protocols/https_x509_bundle", app_config_name='ssldyn')
  25. # check and log bin size
  26. binary_file = os.path.join(dut1.app.binary_path, "https_x509_bundle.bin")
  27. bin_size = os.path.getsize(binary_file)
  28. ttfw_idf.log_performance("https_x509_bundle_bin_size", "{}KB".format(bin_size // 1024))
  29. ttfw_idf.check_performance("https_x509_bundle_bin_size", bin_size // 1024, dut1.TARGET)
  30. # start test
  31. dut1.start_app()
  32. num_URLS = dut1.expect(re.compile(r"Connecting to (\d+) URLs"), timeout=30)
  33. dut1.expect(re.compile(r"Connection established to ([\s\S]*)"), timeout=30)
  34. dut1.expect("Completed {} connections".format(num_URLS[0]), timeout=60)
  35. if __name__ == '__main__':
  36. test_examples_protocol_https_x509_bundle()