CI: use ssid password from stdin for pytest cases

This commit is contained in:
Chen Yudong
2022-07-04 16:54:33 +08:00
parent 4313ff4655
commit 692fbc169c
18 changed files with 93 additions and 8 deletions

View File

@@ -9,6 +9,7 @@ import sys
import pexpect import pexpect
import pytest import pytest
from common_test_methods import get_env_config
from pytest_embedded import Dut from pytest_embedded import Dut
@@ -45,6 +46,12 @@ def test_examples_esp_local_ctrl(dut: Dut) -> None:
rel_project_path = os.path.join('examples', 'protocols', 'esp_local_ctrl') rel_project_path = os.path.join('examples', 'protocols', 'esp_local_ctrl')
idf_path = get_sdk_path() idf_path = get_sdk_path()
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_router')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
dut_ip = dut.expect(r'IPv4 address: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')[1].decode() dut_ip = dut.expect(r'IPv4 address: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})')[1].decode()
dut.expect('esp_https_server: Starting server') dut.expect('esp_https_server: Starting server')
dut.expect('esp_https_server: Server listening on port 443') dut.expect('esp_https_server: Server listening on port 443')

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y

View File

@@ -17,6 +17,7 @@ except ModuleNotFoundError:
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools', 'ci', 'python_packages')) sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools', 'ci', 'python_packages'))
from idf_http_server_test import test as client from idf_http_server_test import test as client
from common_test_methods import get_env_config
from pytest_embedded import Dut from pytest_embedded import Dut
# When running on local machine execute the following before running this script # When running on local machine execute the following before running this script
@@ -47,6 +48,12 @@ def test_examples_protocol_http_server_advanced(dut: Dut) -> None:
# Parse IP address of STA # Parse IP address of STA
logging.info('Waiting to connect with AP') logging.info('Waiting to connect with AP')
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_router')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode()
got_port = dut.expect(r"(?:[\s\S]*)Started HTTP server on port: '(\d+)'", timeout=30)[1].decode() got_port = dut.expect(r"(?:[\s\S]*)Started HTTP server on port: '(\d+)'", timeout=30)[1].decode()

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y

View File

@@ -19,6 +19,7 @@ except ModuleNotFoundError:
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools', 'ci', 'python_packages')) sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools', 'ci', 'python_packages'))
from idf_http_server_test import adder as client from idf_http_server_test import adder as client
from common_test_methods import get_env_config
from pytest_embedded import Dut from pytest_embedded import Dut
# When running on local machine execute the following before running this script # When running on local machine execute the following before running this script
@@ -43,6 +44,12 @@ def test_examples_protocol_http_server_persistence(dut: Dut) -> None:
# Parse IP address of STA # Parse IP address of STA
logging.info('Waiting to connect with AP') logging.info('Waiting to connect with AP')
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_router')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode()
got_port = dut.expect(r"(?:[\s\S]*)Starting server on port: '(\d+)'", timeout=30)[1].decode() got_port = dut.expect(r"(?:[\s\S]*)Starting server on port: '(\d+)'", timeout=30)[1].decode()

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y

View File

@@ -23,6 +23,7 @@ except ModuleNotFoundError:
sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools', 'ci', 'python_packages')) sys.path.append(os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'tools', 'ci', 'python_packages'))
from idf_http_server_test import client from idf_http_server_test import client
from common_test_methods import get_env_config
from pytest_embedded import Dut from pytest_embedded import Dut
@@ -75,6 +76,12 @@ def test_examples_protocol_http_server_simple(dut: Dut) -> None:
# Parse IP address of STA # Parse IP address of STA
logging.info('Waiting to connect with AP') logging.info('Waiting to connect with AP')
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_router')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode()
got_port = dut.expect(r"(?:[\s\S]*)Starting server on port: '(\d+)'", timeout=30)[1].decode() got_port = dut.expect(r"(?:[\s\S]*)Starting server on port: '(\d+)'", timeout=30)[1].decode()
@@ -143,6 +150,12 @@ def test_examples_protocol_http_server_lru_purge_enable(dut: Dut) -> None:
# Parse IP address of STA # Parse IP address of STA
logging.info('Waiting to connect with AP') logging.info('Waiting to connect with AP')
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_router')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode()
got_port = dut.expect(r"(?:[\s\S]*)Starting server on port: '(\d+)'", timeout=30)[1].decode() got_port = dut.expect(r"(?:[\s\S]*)Starting server on port: '(\d+)'", timeout=30)[1].decode()

View File

@@ -1 +1,2 @@
CONFIG_EXAMPLE_BASIC_AUTH=y CONFIG_EXAMPLE_BASIC_AUTH=y
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y

View File

@@ -9,6 +9,7 @@ import logging
import os import os
import pytest import pytest
from common_test_methods import get_env_config
from pytest_embedded import Dut from pytest_embedded import Dut
try: try:
@@ -62,6 +63,12 @@ def test_examples_protocol_http_ws_echo_server(dut: Dut) -> None:
# Parse IP address of STA # Parse IP address of STA
logging.info('Waiting to connect with AP') logging.info('Waiting to connect with AP')
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_router')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode()
got_port = dut.expect(r"Starting server on port: '(\d+)'", timeout=30)[1].decode() got_port = dut.expect(r"Starting server on port: '(\d+)'", timeout=30)[1].decode()

View File

@@ -1 +1,2 @@
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y

View File

@@ -9,6 +9,7 @@ import os
import ssl import ssl
import pytest import pytest
from common_test_methods import get_env_config
from pytest_embedded import Dut from pytest_embedded import Dut
server_cert_pem = '-----BEGIN CERTIFICATE-----\n'\ server_cert_pem = '-----BEGIN CERTIFICATE-----\n'\
@@ -106,11 +107,16 @@ def test_examples_protocol_https_server_simple(dut: Dut) -> None:
bin_size = os.path.getsize(binary_file) bin_size = os.path.getsize(binary_file)
logging.info('https_server_simple_bin_size : {}KB'.format(bin_size // 1024)) logging.info('https_server_simple_bin_size : {}KB'.format(bin_size // 1024))
# start test # start test
logging.info('Waiting to connect with AP')
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_router')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
# Parse IP address and port of the server # Parse IP address and port of the server
dut.expect(r'Starting server') dut.expect(r'Starting server')
got_port = int(dut.expect(r'Server listening on port (\d+)', timeout=30)[1].decode()) got_port = int(dut.expect(r'Server listening on port (\d+)', timeout=30)[1].decode())
logging.info('Waiting to connect with AP')
got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode()
# Expected logs # Expected logs
@@ -174,11 +180,16 @@ def test_examples_protocol_https_server_simple_dynamic_buffers(dut: Dut) -> None
# Test with mbedTLS dynamic buffer feature # Test with mbedTLS dynamic buffer feature
# start test # start test
logging.info('Waiting to connect with AP')
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_router')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
# Parse IP address and port of the server # Parse IP address and port of the server
dut.expect(r'Starting server') dut.expect(r'Starting server')
got_port = int(dut.expect(r'Server listening on port (\d+)', timeout=30)[1].decode()) got_port = int(dut.expect(r'Server listening on port (\d+)', timeout=30)[1].decode())
logging.info('Waiting to connect with AP')
got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode()
# Expected logs # Expected logs

View File

@@ -1,2 +1,3 @@
CONFIG_ESP_HTTPS_SERVER_ENABLE=y CONFIG_ESP_HTTPS_SERVER_ENABLE=y
CONFIG_EXAMPLE_ENABLE_HTTPS_USER_CALLBACK=y CONFIG_EXAMPLE_ENABLE_HTTPS_USER_CALLBACK=y
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y

View File

@@ -1,5 +1,6 @@
CONFIG_ESP_HTTPS_SERVER_ENABLE=y CONFIG_ESP_HTTPS_SERVER_ENABLE=y
CONFIG_EXAMPLE_ENABLE_HTTPS_USER_CALLBACK=y CONFIG_EXAMPLE_ENABLE_HTTPS_USER_CALLBACK=y
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT=y CONFIG_MBEDTLS_DYNAMIC_FREE_CA_CERT=y

View File

@@ -14,6 +14,7 @@ from typing import Any, Optional
import pytest import pytest
import websocket import websocket
from common_test_methods import get_env_config
from pytest_embedded import Dut from pytest_embedded import Dut
OPCODE_TEXT = 0x1 OPCODE_TEXT = 0x1
@@ -119,10 +120,15 @@ def test_examples_protocol_https_wss_server(dut: Dut) -> None:
logging.info('Starting wss_server test app') logging.info('Starting wss_server test app')
logging.info('Waiting to connect with AP')
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_router')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
# Parse IP address of STA # Parse IP address of STA
got_port = int(dut.expect(r'Server listening on port (\d+)', timeout=30)[1].decode()) got_port = int(dut.expect(r'Server listening on port (\d+)', timeout=30)[1].decode())
logging.info('Waiting to connect with AP')
got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode() got_ip = dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)[1].decode()
logging.info('Got IP : {}'.format(got_ip)) logging.info('Got IP : {}'.format(got_ip))

View File

@@ -0,0 +1 @@
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y

View File

@@ -4,6 +4,7 @@ import logging
import os import os
import pytest import pytest
from common_test_methods import get_env_config
from pytest_embedded import Dut from pytest_embedded import Dut
@@ -11,7 +12,7 @@ from pytest_embedded import Dut
@pytest.mark.esp32c3 @pytest.mark.esp32c3
@pytest.mark.esp32s2 @pytest.mark.esp32s2
@pytest.mark.esp32s3 @pytest.mark.esp32s3
@pytest.mark.wifi_router @pytest.mark.wifi_nearby
def test_examples_protocol_https_x509_bundle(dut: Dut) -> None: def test_examples_protocol_https_x509_bundle(dut: Dut) -> None:
""" """
steps: | steps: |
@@ -23,6 +24,14 @@ def test_examples_protocol_https_x509_bundle(dut: Dut) -> None:
binary_file = os.path.join(dut.app.binary_path, 'https_x509_bundle.bin') binary_file = os.path.join(dut.app.binary_path, 'https_x509_bundle.bin')
bin_size = os.path.getsize(binary_file) bin_size = os.path.getsize(binary_file)
logging.info('https_x509_bundle_bin_size : {}KB'.format(bin_size // 1024)) logging.info('https_x509_bundle_bin_size : {}KB'.format(bin_size // 1024))
# Connect to AP
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_nearby')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)
# start test # start test
num_URLS = int(dut.expect(r'Connecting to (\d+) URLs', timeout=30)[1].decode()) num_URLS = int(dut.expect(r'Connecting to (\d+) URLs', timeout=30)[1].decode())
dut.expect(r'Connection established to ([\s\S]*)', timeout=30) dut.expect(r'Connection established to ([\s\S]*)', timeout=30)
@@ -33,7 +42,7 @@ def test_examples_protocol_https_x509_bundle(dut: Dut) -> None:
@pytest.mark.esp32c3 @pytest.mark.esp32c3
@pytest.mark.esp32s2 @pytest.mark.esp32s2
@pytest.mark.esp32s3 @pytest.mark.esp32s3
@pytest.mark.wifi_router @pytest.mark.wifi_nearby
@pytest.mark.parametrize('config', ['ssldyn',], indirect=True) @pytest.mark.parametrize('config', ['ssldyn',], indirect=True)
def test_examples_protocol_https_x509_bundle_dynamic_buffer(dut: Dut) -> None: def test_examples_protocol_https_x509_bundle_dynamic_buffer(dut: Dut) -> None:
# test mbedtls dynamic resource # test mbedtls dynamic resource
@@ -41,6 +50,14 @@ def test_examples_protocol_https_x509_bundle_dynamic_buffer(dut: Dut) -> None:
binary_file = os.path.join(dut.app.binary_path, 'https_x509_bundle.bin') binary_file = os.path.join(dut.app.binary_path, 'https_x509_bundle.bin')
bin_size = os.path.getsize(binary_file) bin_size = os.path.getsize(binary_file)
logging.info('https_x509_bundle_bin_size : {}KB'.format(bin_size // 1024)) logging.info('https_x509_bundle_bin_size : {}KB'.format(bin_size // 1024))
# Connect to AP
if dut.app.sdkconfig.get('EXAMPLE_WIFI_SSID_PWD_FROM_STDIN') is True:
env_config = get_env_config('wifi_nearby')
ap_ssid = env_config['ap_ssid']
ap_password = env_config['ap_password']
dut.expect('Please input ssid password:')
dut.write(' '.join([ap_ssid, ap_password]))
dut.expect(r'IPv4 address: (\d+\.\d+\.\d+\.\d+)', timeout=30)
# start test # start test
num_URLS = int(dut.expect(r'Connecting to (\d+) URLs', timeout=30)[1].decode()) num_URLS = int(dut.expect(r'Connecting to (\d+) URLs', timeout=30)[1].decode())
dut.expect(r'Connection established to ([\s\S]*)', timeout=30) dut.expect(r'Connection established to ([\s\S]*)', timeout=30)

View File

@@ -1,3 +1,4 @@
CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE=y
CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE=y
CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certs" CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certs"
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y

View File

@@ -4,3 +4,4 @@ CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH="certs"
CONFIG_MBEDTLS_DYNAMIC_BUFFER=y CONFIG_MBEDTLS_DYNAMIC_BUFFER=y
CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y CONFIG_MBEDTLS_DYNAMIC_FREE_PEER_CERT=y
CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
CONFIG_EXAMPLE_WIFI_SSID_PWD_FROM_STDIN=y