example_test.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import re
  2. import os
  3. import sys
  4. try:
  5. import IDF
  6. except ImportError:
  7. # this is a test case write with tiny-test-fw.
  8. # to run test cases outside tiny-test-fw,
  9. # we need to set environment variable `TEST_FW_PATH`,
  10. # then get and insert `TEST_FW_PATH` to sys path before import FW module
  11. test_fw_path = os.getenv("TEST_FW_PATH")
  12. if test_fw_path and test_fw_path not in sys.path:
  13. sys.path.insert(0, test_fw_path)
  14. import IDF
  15. @IDF.idf_example_test(env_tag="Example_WIFI", ignore=True)
  16. def test_examples_protocol_https_x509_bundle(env, extra_data):
  17. """
  18. steps: |
  19. 1. join AP
  20. 2. connect to multiple URLs
  21. 3. send http request
  22. """
  23. dut1 = env.get_dut("https_x509_bundle", "examples/protocols/https_x509_bundle")
  24. # check and log bin size
  25. binary_file = os.path.join(dut1.app.binary_path, "https_x509_bundle.bin")
  26. bin_size = os.path.getsize(binary_file)
  27. IDF.log_performance("https_x509_bundle_bin_size", "{}KB".format(bin_size // 1024))
  28. IDF.check_performance("https_x509_bundle_bin_size", bin_size // 1024)
  29. # start test
  30. dut1.start_app()
  31. num_URLS = dut1.expect(re.compile(r"Connecting to (\d+) URLs"), timeout=30)
  32. dut1.expect(re.compile(r"Connection established to ([\s\S]*)"), timeout=30)
  33. dut1.expect("Completed {} connections".format(num_URLS[0]), timeout=60)
  34. if __name__ == '__main__':
  35. test_examples_protocol_https_x509_bundle()