example_test.py 1.3 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_request(env, extra_data):
  17. """
  18. steps: |
  19. 1. join AP
  20. 2. connect to www.howsmyssl.com:443
  21. 3. send http request
  22. """
  23. dut1 = env.get_dut("https_request", "examples/protocols/https_request")
  24. # check and log bin size
  25. binary_file = os.path.join(dut1.app.binary_path, "https_request.bin")
  26. bin_size = os.path.getsize(binary_file)
  27. IDF.log_performance("https_request_bin_size", "{}KB".format(bin_size // 1024))
  28. IDF.check_performance("https_request_bin_size", bin_size // 1024)
  29. # start test
  30. dut1.start_app()
  31. dut1.expect("Connection established...", timeout=30)
  32. dut1.expect("Reading HTTP response...")
  33. dut1.expect(re.compile(r"Completed (\d) requests"))
  34. if __name__ == '__main__':
  35. test_examples_protocol_https_request()