From 1c3628d631e31441cff793275360efbe38289279 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Thu, 3 Mar 2022 16:05:28 +0800 Subject: [PATCH] ci: refactor a few test scripts to pytest --- .../peripherals/i2c_wifi/app_test.py | 18 ---------- .../peripherals/i2c_wifi/pytest_i2c_wifi.py | 11 +++++++ .../phy/phy_multi_init_data_test/app_test.py | 33 ------------------- .../pytest_phy_multi_init_data.py | 19 +++++++++++ 4 files changed, 30 insertions(+), 51 deletions(-) delete mode 100644 tools/test_apps/peripherals/i2c_wifi/app_test.py create mode 100644 tools/test_apps/peripherals/i2c_wifi/pytest_i2c_wifi.py delete mode 100644 tools/test_apps/phy/phy_multi_init_data_test/app_test.py create mode 100644 tools/test_apps/phy/phy_multi_init_data_test/pytest_phy_multi_init_data.py diff --git a/tools/test_apps/peripherals/i2c_wifi/app_test.py b/tools/test_apps/peripherals/i2c_wifi/app_test.py deleted file mode 100644 index 395613a53e..0000000000 --- a/tools/test_apps/peripherals/i2c_wifi/app_test.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python -import tiny_test_fw -import ttfw_idf - - -@ttfw_idf.idf_custom_test(env_tag='Example_GENERIC') -def test_startup(env, _): # type: (tiny_test_fw.Env.Env, None) -> None - # Only test for master usage. - dut = env.get_dut('i2c_wifi', 'tools/test_apps/peripherals/i2c_wifi') - dut.start_app() - - dut.expect('I2C-WIFI test success') - - env.close_dut(dut.name) - - -if __name__ == '__main__': - test_startup() diff --git a/tools/test_apps/peripherals/i2c_wifi/pytest_i2c_wifi.py b/tools/test_apps/peripherals/i2c_wifi/pytest_i2c_wifi.py new file mode 100644 index 0000000000..a678c703fd --- /dev/null +++ b/tools/test_apps/peripherals/i2c_wifi/pytest_i2c_wifi.py @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 + +import pytest +from pytest_embedded_idf.dut import IdfDut + + +@pytest.mark.supported_targets +@pytest.mark.generic +def test_startup(dut: IdfDut) -> None: + dut.expect_exact('I2C-WIFI test success') diff --git a/tools/test_apps/phy/phy_multi_init_data_test/app_test.py b/tools/test_apps/phy/phy_multi_init_data_test/app_test.py deleted file mode 100644 index dbe0d75346..0000000000 --- a/tools/test_apps/phy/phy_multi_init_data_test/app_test.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -# SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: Apache-2.0 -import glob -import os - -import tiny_test_fw -import ttfw_idf -from tiny_test_fw import Utility - - -@ttfw_idf.idf_custom_test(env_tag='Example_GENERIC', group='test-apps') -def test_phy_multi_init_data_bin(env, _): - # type: (tiny_test_fw.Env.Env, None) -> None - config_files = glob.glob(os.path.join(os.path.dirname(__file__), 'sdkconfig.ci.*')) - config_names = [os.path.basename(s).replace('sdkconfig.ci.', '') for s in config_files] - for name in config_names: - dut = env.get_dut('phy_multi_init_data_test', 'tools/test_apps/phy/phy_multi_init_data_test',app_config_name=name) - dut.start_app() - - if 'CONFIG_ESP_PHY_MULTIPLE_INIT_DATA_BIN_EMBED' in dut.app.get_sdkconfig().keys(): - Utility.console_log('multi init data bin embed test') - dut.expect('load embedded multi phy init data') - else: - Utility.console_log('multi init data bin test') - dut.expect('Support multiple PHY init data bins') - - dut.expect('wifi_init finished') - Utility.console_log('Test Success') - - -if __name__ == '__main__': - test_phy_multi_init_data_bin() diff --git a/tools/test_apps/phy/phy_multi_init_data_test/pytest_phy_multi_init_data.py b/tools/test_apps/phy/phy_multi_init_data_test/pytest_phy_multi_init_data.py new file mode 100644 index 0000000000..9f9c914542 --- /dev/null +++ b/tools/test_apps/phy/phy_multi_init_data_test/pytest_phy_multi_init_data.py @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 + +import pytest +from pytest_embedded_idf.dut import IdfDut + + +@pytest.mark.supported_targets +@pytest.mark.generic +@pytest.mark.parametrize('config', [ + 'phy_multiple_init_data', + 'phy_multiple_init_data_embed', +], indirect=True) +def test_phy_multi_init_data_bin(dut: IdfDut, config: str) -> None: + if config == 'phy_multiple_init_data': + dut.expect_exact('Support multiple PHY init data bins') + else: + dut.expect_exact('load embedded multi phy init data') + dut.expect_exact('wifi_init finished')