From 8db902c57be6727c8fcb16cd668f5b158cd970f4 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Tue, 13 Dec 2022 20:06:37 +0800 Subject: [PATCH 1/2] gpio: Refactor pytest_gpio to separate cases with labels, and update to use new IdfDut class in pytest_embedded_idf --- .../driver/test_apps/gpio/main/test_gpio.c | 6 +- .../gpio/main/test_sigma_delta_legacy.c | 7 +-- .../driver/test_apps/gpio/pytest_gpio.py | 61 ++++++++++++++++--- components/unity/include/unity_test_runner.h | 11 ---- 4 files changed, 57 insertions(+), 28 deletions(-) diff --git a/components/driver/test_apps/gpio/main/test_gpio.c b/components/driver/test_apps/gpio/main/test_gpio.c index 981912918b..a50aa7fe39 100644 --- a/components/driver/test_apps/gpio/main/test_gpio.c +++ b/components/driver/test_apps/gpio/main/test_gpio.c @@ -677,7 +677,7 @@ static void prompt_to_continue(const char *str) // This case needs the resistance to pull up the voltage or pull down the voltage // Ignored in CI because the voltage needs to be tested with multimeter -TEST_CASE_CI_IGNORE("GPIO_verify_only_the_gpio_with_input_ability_can_be_set_pull/down", "[gpio]") +TEST_CASE("GPIO_verify_only_the_gpio_with_input_ability_can_be_set_pull/down", "[gpio][ignore]") { gpio_config_t output_io = test_init_io(TEST_GPIO_EXT_OUT_IO); gpio_config_t input_io = test_init_io(TEST_GPIO_EXT_IN_IO); @@ -768,7 +768,7 @@ static void drive_capability_set_get(gpio_num_t num, gpio_drive_cap_t capability * * all of these cases should be ignored that it will not run in CI */ -TEST_CASE_CI_IGNORE("GPIO_drive_capability_test", "[gpio]") +TEST_CASE("GPIO_drive_capability_test", "[gpio][ignore]") { printf("weak capability test! please view the current change!\n"); drive_capability_set_get(TEST_GPIO_EXT_OUT_IO, GPIO_DRIVE_CAP_0); @@ -846,7 +846,7 @@ TEST_CASE("GPIO_USB_DP_pin_pullup_disable_test", "[gpio]") #if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32C6) // TODO: IDF-5348 Remove when light sleep is supported on ESP32C6 // Ignored in CI because it needs manually connect TEST_GPIO_INPUT_LEVEL_LOW_PIN to 3.3v to wake up from light sleep -TEST_CASE_CI_IGNORE("GPIO_light_sleep_wake_up_test", "[gpio]") +TEST_CASE("GPIO_light_sleep_wake_up_test", "[gpio][ignore]") { gpio_config_t io_config = test_init_io(TEST_GPIO_INPUT_LEVEL_LOW_PIN); io_config.mode = GPIO_MODE_INPUT; diff --git a/components/driver/test_apps/gpio/main/test_sigma_delta_legacy.c b/components/driver/test_apps/gpio/main/test_sigma_delta_legacy.c index d470deffa5..927b4abef8 100644 --- a/components/driver/test_apps/gpio/main/test_sigma_delta_legacy.c +++ b/components/driver/test_apps/gpio/main/test_sigma_delta_legacy.c @@ -28,7 +28,7 @@ TEST_CASE("SigmaDelta_config_test", "[sigma_delta]") // connect GPIO4 with LED positive pin, and the GND pin connect LED negative pin // logic analyzer help also to see the wave form(more standard and accurate) -TEST_CASE("SigmaDelta_pin_duty_prescale_set", "[sigma_delta][ignore]") +TEST_CASE("SigmaDelta_pin_duty_prescale_set", "[sigma_delta]") { sigmadelta_config_t sigmadelta_cfg = { .channel = 0, @@ -40,7 +40,7 @@ TEST_CASE("SigmaDelta_pin_duty_prescale_set", "[sigma_delta][ignore]") int8_t duty = 0; int inc = 1; - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { sigmadelta_set_duty(sigmadelta_cfg.channel, duty); vTaskDelay(10 / portTICK_PERIOD_MS); @@ -51,7 +51,7 @@ TEST_CASE("SigmaDelta_pin_duty_prescale_set", "[sigma_delta][ignore]") } TEST_ESP_OK(sigmadelta_set_prescale(0, 200)); - for (int i = 0; i < 1000; i++) { + for (int i = 0; i < 100; i++) { sigmadelta_set_duty(sigmadelta_cfg.channel, duty); vTaskDelay(10 / portTICK_PERIOD_MS); @@ -62,5 +62,4 @@ TEST_CASE("SigmaDelta_pin_duty_prescale_set", "[sigma_delta][ignore]") } TEST_ESP_OK(sigmadelta_set_pin(sigmadelta_cfg.channel, 5)); - vTaskDelay(3000 / portTICK_PERIOD_MS); } diff --git a/components/driver/test_apps/gpio/pytest_gpio.py b/components/driver/test_apps/gpio/pytest_gpio.py index 53ee3a2c70..b78c80c2a6 100644 --- a/components/driver/test_apps/gpio/pytest_gpio.py +++ b/components/driver/test_apps/gpio/pytest_gpio.py @@ -2,17 +2,58 @@ # SPDX-License-Identifier: CC0-1.0 import pytest +from pytest_embedded_idf import IdfDut + +CONFIGS = [ + 'iram_safe', + 'release', +] @pytest.mark.supported_targets @pytest.mark.generic -@pytest.mark.parametrize( - 'config', - [ - 'iram_safe', - 'release', - ], - indirect=True, -) -def test_gpio(case_tester) -> None: # type: ignore - case_tester.run_all_cases(timeout=300) +@pytest.mark.parametrize('config', CONFIGS, indirect=True) +def test_gpio(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='gpio') + + +@pytest.mark.esp32c2 +@pytest.mark.esp32c3 +@pytest.mark.esp32c6 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +@pytest.mark.parametrize('config', CONFIGS, indirect=True) +def test_gpio_filter(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='gpio_filter') + + +@pytest.mark.esp32c2 +@pytest.mark.esp32c3 +@pytest.mark.esp32c6 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +@pytest.mark.parametrize('config', CONFIGS, indirect=True) +def test_dedic_gpio(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='dedic_gpio') + + +@pytest.mark.esp32 +@pytest.mark.esp32c3 +@pytest.mark.esp32c6 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +@pytest.mark.parametrize('config', CONFIGS, indirect=True) +def test_sigma_delta(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='sigma_delta') + + +@pytest.mark.esp32 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +@pytest.mark.parametrize('config', CONFIGS, indirect=True) +def test_rtc_io(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='rtcio') diff --git a/components/unity/include/unity_test_runner.h b/components/unity/include/unity_test_runner.h index aea074bbee..9216e0d7a3 100644 --- a/components/unity/include/unity_test_runner.h +++ b/components/unity/include/unity_test_runner.h @@ -149,17 +149,6 @@ void unity_testcase_register(test_desc_t* desc); } -/* - Test case macro to be ignored in CI. - Tests will still be built (to check for compile error) but not linked if CONFIG_IDF_CI_BUILD. - */ -#ifdef CONFIG_IDF_CI_BUILD -#define TEST_CASE_CI_IGNORE(name_, desc_) \ - __attribute__((unused)) static void UNITY_TEST_UID(test_func_) (void) -#else -#define TEST_CASE_CI_IGNORE(name_, desc_) TEST_CASE(name_, desc_) -#endif - /** * Note: initialization of test_desc_t fields above has to be done exactly * in the same order as the fields are declared in the structure. From 4e8eb6864e966f0f2dbdd62db33880016acdc781 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Tue, 13 Dec 2022 20:26:12 +0800 Subject: [PATCH 2/2] pcnt: Re-enable legacy pcnt test for esp32c6 (ledc support completed) --- components/driver/.build-test-rules.yml | 3 --- components/driver/test_apps/legacy_pcnt_driver/README.md | 4 ++-- .../driver/test_apps/legacy_pcnt_driver/pytest_legacy_pcnt.py | 1 + docs/docs_not_updated/esp32c6.txt | 1 - 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/components/driver/.build-test-rules.yml b/components/driver/.build-test-rules.yml index da5ad32373..a8f73d50de 100644 --- a/components/driver/.build-test-rules.yml +++ b/components/driver/.build-test-rules.yml @@ -51,9 +51,6 @@ components/driver/test_apps/legacy_mcpwm_driver: components/driver/test_apps/legacy_pcnt_driver: disable: - if: SOC_PCNT_SUPPORTED != 1 - - if: IDF_TARGET == "esp32c6" - temporary: true - reason: test depends on ledc to be supported on esp32c6 components/driver/test_apps/legacy_rmt_driver: disable: diff --git a/components/driver/test_apps/legacy_pcnt_driver/README.md b/components/driver/test_apps/legacy_pcnt_driver/README.md index b88a9825d9..40eac280e6 100644 --- a/components/driver/test_apps/legacy_pcnt_driver/README.md +++ b/components/driver/test_apps/legacy_pcnt_driver/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C6 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | diff --git a/components/driver/test_apps/legacy_pcnt_driver/pytest_legacy_pcnt.py b/components/driver/test_apps/legacy_pcnt_driver/pytest_legacy_pcnt.py index 8bcfdbd997..c2a1c98270 100644 --- a/components/driver/test_apps/legacy_pcnt_driver/pytest_legacy_pcnt.py +++ b/components/driver/test_apps/legacy_pcnt_driver/pytest_legacy_pcnt.py @@ -8,6 +8,7 @@ from pytest_embedded import Dut @pytest.mark.esp32 @pytest.mark.esp32s2 @pytest.mark.esp32s3 +@pytest.mark.esp32c6 @pytest.mark.generic @pytest.mark.parametrize( 'config', diff --git a/docs/docs_not_updated/esp32c6.txt b/docs/docs_not_updated/esp32c6.txt index 5c5fe68f5f..44700a86a7 100644 --- a/docs/docs_not_updated/esp32c6.txt +++ b/docs/docs_not_updated/esp32c6.txt @@ -101,7 +101,6 @@ api-reference/peripherals/sdspi_host api-reference/peripherals/dac api-reference/peripherals/touch_element api-reference/peripherals/secure_element -api-reference/peripherals/ledc api-reference/peripherals/sdio_slave api-reference/peripherals/clk_tree api-reference/peripherals/touch_pad