gpio: Refactor pytest_gpio to separate cases with labels, and update to use new IdfDut class in pytest_embedded_idf

pull/10469/head
Song Ruo Jing 2022-12-13 20:06:37 +08:00
rodzic 11dee5d27f
commit 8db902c57b
4 zmienionych plików z 57 dodań i 28 usunięć

Wyświetl plik

@ -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;

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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')

Wyświetl plik

@ -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.