From 31ddfbb7a617cdd79634b1b4f687bb133eb0e788 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 12 Jan 2021 23:43:46 +0530 Subject: [PATCH] https_mbedtls_example: Added example test --- .../protocols/https_mbedtls/example_test.py | 51 +++++++++++++++++++ examples/protocols/https_mbedtls/sdkconfig.ci | 11 ++++ 2 files changed, 62 insertions(+) create mode 100644 examples/protocols/https_mbedtls/example_test.py create mode 100644 examples/protocols/https_mbedtls/sdkconfig.ci diff --git a/examples/protocols/https_mbedtls/example_test.py b/examples/protocols/https_mbedtls/example_test.py new file mode 100644 index 0000000000..41f151e30d --- /dev/null +++ b/examples/protocols/https_mbedtls/example_test.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# +# Copyright 2021 Espressif Systems (Shanghai) CO LTD +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import os +import re + +import tiny_test_fw +import ttfw_idf +from tiny_test_fw import Utility + + +@ttfw_idf.idf_example_test(env_tag='Example_EthKitV1') +def test_examples_protocol_https_mbedtls(env, extra_data): # type: (tiny_test_fw.Env.Env, None) -> None # pylint: disable=unused-argument + """ + steps: | + 1. join AP + 2. connect to www.howsmyssl.com:443 + 3. send http request + """ + dut1 = env.get_dut('https_mbedtls', 'examples/protocols/https_mbedtls', dut_class=ttfw_idf.ESP32DUT) + # check and log bin size + binary_file = os.path.join(dut1.app.binary_path, 'https-mbedtls.bin') + bin_size = os.path.getsize(binary_file) + ttfw_idf.log_performance('https_mbedtls_bin_size', '{}KB'.format(bin_size // 1024)) + # start test + dut1.start_app() + dut1.expect('Connected.', timeout=30) + Utility.console_log('TCP connection established with the server\n performing SSL/TLS handshake') + dut1.expect('Performing the SSL/TLS handshake...') + dut1.expect('Certificate verified.') + Utility.console_log('SSL/TLS handshake successful') + dut1.expect('Writing HTTP request...') + dut1.expect('Reading HTTP response...') + dut1.expect(re.compile(r'Completed (\d) requests')) + + +if __name__ == '__main__': + test_examples_protocol_https_mbedtls() # pylint: disable=no-value-for-parameter diff --git a/examples/protocols/https_mbedtls/sdkconfig.ci b/examples/protocols/https_mbedtls/sdkconfig.ci new file mode 100644 index 0000000000..42f4b389e1 --- /dev/null +++ b/examples/protocols/https_mbedtls/sdkconfig.ci @@ -0,0 +1,11 @@ +CONFIG_ESP32_SPIRAM_SUPPORT=y +CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y +CONFIG_EXAMPLE_CONNECT_ETHERNET=y +CONFIG_EXAMPLE_CONNECT_WIFI=n +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