feat(mbedtls): add dynamic buffer and local resource managment to decrease SSL heap cost
This commit is contained in:
@@ -39,6 +39,35 @@ def test_examples_protocol_esp_http_client(env, extra_data):
|
||||
dut1.expect(re.compile(r"Last esp error code: 0x8001"))
|
||||
dut1.expect("Finish http example")
|
||||
|
||||
# test mbedtls dynamic resource
|
||||
dut1 = env.get_dut("esp_http_client", "examples/protocols/esp_http_client", dut_class=ttfw_idf.ESP32DUT, app_config_name='ssldyn')
|
||||
# check and log bin size
|
||||
binary_file = os.path.join(dut1.app.binary_path, "esp-http-client-example.bin")
|
||||
bin_size = os.path.getsize(binary_file)
|
||||
ttfw_idf.log_performance("esp_http_client_bin_size", "{}KB".format(bin_size // 1024))
|
||||
ttfw_idf.check_performance("esp_http_client_bin_size", bin_size // 1024, dut1.TARGET)
|
||||
# start test
|
||||
dut1.start_app()
|
||||
dut1.expect("Connected to AP, begin http example", timeout=30)
|
||||
dut1.expect(re.compile(r"HTTP GET Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP POST Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP PUT Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP PATCH Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP DELETE Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP HEAD Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP Basic Auth Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP Basic Auth redirect Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP Digest Auth Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP Relative path redirect Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP Absolute path redirect Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTPS Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"HTTP redirect to HTTPS Status = 200, content_length = (\d)"), timeout=10)
|
||||
dut1.expect(re.compile(r"HTTP chunk encoding Status = 200, content_length = (-?\d)"))
|
||||
# content-len for chunked encoding is typically -1, could be a positive length in some cases
|
||||
dut1.expect(re.compile(r"HTTP Stream reader Status = 200, content_length = (\d)"))
|
||||
dut1.expect(re.compile(r"Last esp error code: 0x8001"))
|
||||
dut1.expect("Finish http example")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_protocol_esp_http_client()
|
||||
|
||||
12
examples/protocols/esp_http_client/sdkconfig.ci.ssldyn
Normal file
12
examples/protocols/esp_http_client/sdkconfig.ci.ssldyn
Normal file
@@ -0,0 +1,12 @@
|
||||
CONFIG_EXAMPLE_CONNECT_ETHERNET=y
|
||||
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
|
||||
CONFIG_EXAMPLE_ETH_PHY_IP101=y
|
||||
CONFIG_EXAMPLE_ETH_MDC_GPIO=23
|
||||
CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
|
||||
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5
|
||||
CONFIG_EXAMPLE_ETH_PHY_ADDR=1
|
||||
CONFIG_EXAMPLE_CONNECT_IPV6=y
|
||||
CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
|
||||
@@ -24,6 +24,19 @@ def test_examples_protocol_https_request(env, extra_data):
|
||||
dut1.expect("Reading HTTP response...")
|
||||
dut1.expect(re.compile(r"Completed (\d) requests"))
|
||||
|
||||
# test mbedtls dynamic resource
|
||||
dut1 = env.get_dut("https_request", "examples/protocols/https_request", dut_class=ttfw_idf.ESP32DUT, app_config_name='ssldyn')
|
||||
# check and log bin size
|
||||
binary_file = os.path.join(dut1.app.binary_path, "https_request.bin")
|
||||
bin_size = os.path.getsize(binary_file)
|
||||
ttfw_idf.log_performance("https_request_bin_size", "{}KB".format(bin_size // 1024))
|
||||
ttfw_idf.check_performance("https_request_bin_size", bin_size // 1024, dut1.TARGET)
|
||||
# start test
|
||||
dut1.start_app()
|
||||
dut1.expect("Connection established...", timeout=30)
|
||||
dut1.expect("Reading HTTP response...")
|
||||
dut1.expect(re.compile(r"Completed (\d) requests"))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_protocol_https_request()
|
||||
|
||||
13
examples/protocols/https_request/sdkconfig.ci.ssldyn
Normal file
13
examples/protocols/https_request/sdkconfig.ci.ssldyn
Normal file
@@ -0,0 +1,13 @@
|
||||
CONFIG_ESP32_SPIRAM_SUPPORT=y
|
||||
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
|
||||
CONFIG_EXAMPLE_CONNECT_ETHERNET=y
|
||||
CONFIG_EXAMPLE_USE_INTERNAL_ETHERNET=y
|
||||
CONFIG_EXAMPLE_ETH_PHY_IP101=y
|
||||
CONFIG_EXAMPLE_ETH_MDC_GPIO=23
|
||||
CONFIG_EXAMPLE_ETH_MDIO_GPIO=18
|
||||
CONFIG_EXAMPLE_ETH_PHY_RST_GPIO=5
|
||||
CONFIG_EXAMPLE_ETH_PHY_ADDR=1
|
||||
CONFIG_EXAMPLE_CONNECT_IPV6=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
|
||||
@@ -23,6 +23,19 @@ def test_examples_protocol_https_x509_bundle(env, extra_data):
|
||||
dut1.expect(re.compile(r"Connection established to ([\s\S]*)"), timeout=30)
|
||||
dut1.expect("Completed {} connections".format(num_URLS[0]), timeout=60)
|
||||
|
||||
# test mbedtls dynamic resource
|
||||
dut1 = env.get_dut("https_x509_bundle", "examples/protocols/https_x509_bundle", app_config_name='ssldyn')
|
||||
# check and log bin size
|
||||
binary_file = os.path.join(dut1.app.binary_path, "https_x509_bundle.bin")
|
||||
bin_size = os.path.getsize(binary_file)
|
||||
ttfw_idf.log_performance("https_x509_bundle_bin_size", "{}KB".format(bin_size // 1024))
|
||||
ttfw_idf.check_performance("https_x509_bundle_bin_size", bin_size // 1024, dut1.TARGET)
|
||||
# start test
|
||||
dut1.start_app()
|
||||
num_URLS = dut1.expect(re.compile(r"Connecting to (\d+) URLs"), timeout=30)
|
||||
dut1.expect(re.compile(r"Connection established to ([\s\S]*)"), timeout=30)
|
||||
dut1.expect("Completed {} connections".format(num_URLS[0]), timeout=60)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
test_examples_protocol_https_x509_bundle()
|
||||
|
||||
3
examples/protocols/https_x509_bundle/sdkconfig.ci
Normal file
3
examples/protocols/https_x509_bundle/sdkconfig.ci
Normal file
@@ -0,0 +1,3 @@
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y
|
||||
CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y
|
||||
CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certs"
|
||||
6
examples/protocols/https_x509_bundle/sdkconfig.ci.ssldyn
Normal file
6
examples/protocols/https_x509_bundle/sdkconfig.ci.ssldyn
Normal file
@@ -0,0 +1,6 @@
|
||||
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y
|
||||
CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y
|
||||
CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certs"
|
||||
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y
|
||||
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
|
||||
Reference in New Issue
Block a user