esp_http_client_test.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import re
  2. import os
  3. import ttfw_idf
  4. @ttfw_idf.idf_example_test(env_tag="Example_EthKitV1")
  5. def test_examples_protocol_esp_http_client(env, extra_data):
  6. """
  7. steps: |
  8. 1. join AP
  9. 2. Send HTTP request to httpbin.org
  10. """
  11. dut1 = env.get_dut("esp_http_client", "examples/protocols/esp_http_client", dut_class=ttfw_idf.ESP32DUT)
  12. # check and log bin size
  13. binary_file = os.path.join(dut1.app.binary_path, "esp-http-client-example.bin")
  14. bin_size = os.path.getsize(binary_file)
  15. ttfw_idf.log_performance("esp_http_client_bin_size", "{}KB".format(bin_size // 1024))
  16. ttfw_idf.check_performance("esp_http_client_bin_size", bin_size // 1024)
  17. # start test
  18. dut1.start_app()
  19. dut1.expect("Connected to AP, begin http example", timeout=30)
  20. dut1.expect(re.compile(r"HTTP GET Status = 200, content_length = (\d)"))
  21. dut1.expect(re.compile(r"HTTP POST Status = 200, content_length = (\d)"))
  22. dut1.expect(re.compile(r"HTTP PUT Status = 200, content_length = (\d)"))
  23. dut1.expect(re.compile(r"HTTP PATCH Status = 200, content_length = (\d)"))
  24. dut1.expect(re.compile(r"HTTP DELETE Status = 200, content_length = (\d)"))
  25. dut1.expect(re.compile(r"HTTP HEAD Status = 200, content_length = (\d)"))
  26. dut1.expect(re.compile(r"HTTP Basic Auth Status = 200, content_length = (\d)"))
  27. dut1.expect(re.compile(r"HTTP Basic Auth redirect Status = 200, content_length = (\d)"))
  28. dut1.expect(re.compile(r"HTTP Digest Auth Status = 200, content_length = (\d)"))
  29. dut1.expect(re.compile(r"HTTPS Status = 200, content_length = (\d)"))
  30. dut1.expect(re.compile(r"HTTPS Status = 200, content_length = (\d)"))
  31. dut1.expect(re.compile(r"HTTP chunk encoding Status = 200, content_length = (-?\d)"))
  32. # content-len for chunked encoding is typically -1, could be a positive length in some cases
  33. dut1.expect(re.compile(r"HTTP Stream reader Status = 200, content_length = (\d)"))
  34. dut1.expect(re.compile(r"Last esp error code: 0x8001"))
  35. dut1.expect("Finish http example")
  36. if __name__ == '__main__':
  37. test_examples_protocol_esp_http_client()