From 93153bdfe110294d5fb8ad7a89d46ca816d270bb Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Mon, 3 Oct 2022 16:11:15 +0200 Subject: [PATCH] ulp: add all 'ignore' tests to pytest framework This commit adds a way to run all 'ignore' tests for ulp using the pytest framework. --- .../ulp/test_apps/ulp_fsm/main/test_ulp.c | 10 ++-- .../test_apps/ulp_fsm/pytest_ulp_fsm_app.py | 53 ++++++++++++++++++- .../test_apps/ulp_riscv/main/test_ulp_riscv.c | 2 +- .../test_apps/ulp_riscv/pytest_ulp_riscv.py | 13 ++++- 4 files changed, 70 insertions(+), 8 deletions(-) diff --git a/components/ulp/test_apps/ulp_fsm/main/test_ulp.c b/components/ulp/test_apps/ulp_fsm/main/test_ulp.c index e3386e584f..7f1efad04a 100644 --- a/components/ulp/test_apps/ulp_fsm/main/test_ulp.c +++ b/components/ulp/test_apps/ulp_fsm/main/test_ulp.c @@ -205,7 +205,7 @@ TEST_CASE("ULP FSM light-sleep wakeup test", "[ulp]") TEST_ASSERT(esp_sleep_get_wakeup_cause() == ESP_SLEEP_WAKEUP_ULP); } -TEST_CASE("ULP FSM deep-sleep wakeup test", "[ulp][reset=SW_CPU_RESET][ignore]") +TEST_CASE("ULP FSM deep-sleep wakeup test", "[ulp][ulp_deep_sleep_wakeup]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); @@ -389,7 +389,7 @@ TEST_CASE("ULP FSM I_WR_REG instruction test", "[ulp]") } -TEST_CASE("ULP FSM controls RTC_IO", "[ulp][ignore]") +TEST_CASE("ULP FSM controls RTC_IO", "[ulp][ulp_deep_sleep_wakeup]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); @@ -455,7 +455,7 @@ TEST_CASE("ULP FSM controls RTC_IO", "[ulp][ignore]") UNITY_TEST_FAIL(__LINE__, "Should not get here!"); } -TEST_CASE("ULP FSM power consumption in deep sleep", "[ulp][ignore]") +TEST_CASE("ULP FSM power consumption in deep sleep", "[ulp][ulp_deep_sleep_wakeup]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 4 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); @@ -555,7 +555,7 @@ TEST_CASE("ULP FSM timer setting", "[ulp]") } #if !DISABLED_FOR_TARGETS(ESP32) -TEST_CASE("ULP FSM can use temperature sensor (TSENS) in deep sleep", "[ulp][ignore]") +TEST_CASE("ULP FSM can use temperature sensor (TSENS) in deep sleep", "[ulp][ulp_deep_sleep_wakeup]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); @@ -622,7 +622,7 @@ TEST_CASE("ULP FSM can use temperature sensor (TSENS) in deep sleep", "[ulp][ign } #endif //#if !DISABLED_FOR_TARGETS(ESP32) -TEST_CASE("ULP FSM can use ADC in deep sleep", "[ulp][ignore]") +TEST_CASE("ULP FSM can use ADC in deep sleep", "[ulp][ulp_deep_sleep_wakeup]") { assert(CONFIG_ULP_COPROC_RESERVE_MEM >= 260 && "this test needs ULP_COPROC_RESERVE_MEM option set in menuconfig"); diff --git a/components/ulp/test_apps/ulp_fsm/pytest_ulp_fsm_app.py b/components/ulp/test_apps/ulp_fsm/pytest_ulp_fsm_app.py index c6f683587a..0377e470e6 100644 --- a/components/ulp/test_apps/ulp_fsm/pytest_ulp_fsm_app.py +++ b/components/ulp/test_apps/ulp_fsm/pytest_ulp_fsm_app.py @@ -11,5 +11,56 @@ from pytest_embedded import Dut @pytest.mark.generic def test_ulp_fsm(dut: Dut) -> None: dut.expect('Press ENTER to see the list of tests') - dut.write('![ignore]') + dut.write('![ulp_deep_sleep_wakeup]') dut.expect_unity_test_output() + + +# Run all deepsleep wakeup tests one after the other instead of running them all with the `ulp_deep_sleep_wakeup` tag. +# This makes sure that all tests are run even after one test causes a system reset. +@pytest.mark.esp32 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +def test_ulp_fsm_deep_sleep_wakeup(dut: Dut) -> None: + dut.expect('Press ENTER to see the list of tests') + dut.write('"ULP FSM deep-sleep wakeup test"') + dut.expect('rst:0x5') + + +@pytest.mark.esp32 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +def test_ulp_fsm_rtc_io(dut: Dut) -> None: + dut.expect('Press ENTER to see the list of tests') + dut.write('"ULP FSM controls RTC_IO"') + dut.expect('rst:0x5') + + +@pytest.mark.esp32 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +def test_ulp_fsm_deep_sleep_power_consumption(dut: Dut) -> None: + dut.expect('Press ENTER to see the list of tests') + dut.write('"ULP FSM power consumption in deep sleep"') + dut.expect('rst:0x5') + + +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +def test_ulp_fsm_tsens(dut: Dut) -> None: + dut.expect('Press ENTER to see the list of tests') + dut.write('"ULP FSM can use temperature sensor (TSENS) in deep sleep"') + dut.expect('rst:0x5') + + +@pytest.mark.esp32 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +def test_ulp_fsm_adc(dut: Dut) -> None: + dut.expect('Press ENTER to see the list of tests') + dut.write('"ULP FSM can use ADC in deep sleep"') + dut.expect('rst:0x5') diff --git a/components/ulp/test_apps/ulp_riscv/main/test_ulp_riscv.c b/components/ulp/test_apps/ulp_riscv/main/test_ulp_riscv.c index 4f49eb7596..95484f13bb 100644 --- a/components/ulp/test_apps/ulp_riscv/main/test_ulp_riscv.c +++ b/components/ulp/test_apps/ulp_riscv/main/test_ulp_riscv.c @@ -184,7 +184,7 @@ TEST_CASE("ULP-RISC-V can stop itself and be resumed from the main CPU", "[ulp]" * Keep this test case as the last test case in this suite as a CPU reset occurs. * Add new test cases above in order to ensure they run when all test cases are run together. */ -TEST_CASE("ULP-RISC-V is able to wakeup main CPU from deep sleep", "[ulp][reset=SW_CPU_RESET][ignore]") +TEST_CASE("ULP-RISC-V is able to wakeup main CPU from deep sleep", "[ulp][ulp_deep_sleep_wakeup]") { /* Load ULP RISC-V firmware and start the ULP RISC-V Coprocessor */ load_and_start_ulp_firmware(); diff --git a/components/ulp/test_apps/ulp_riscv/pytest_ulp_riscv.py b/components/ulp/test_apps/ulp_riscv/pytest_ulp_riscv.py index b006e0f341..692c6d55ec 100644 --- a/components/ulp/test_apps/ulp_riscv/pytest_ulp_riscv.py +++ b/components/ulp/test_apps/ulp_riscv/pytest_ulp_riscv.py @@ -10,5 +10,16 @@ from pytest_embedded import Dut @pytest.mark.generic def test_ulp_riscv(dut: Dut) -> None: dut.expect('Press ENTER to see the list of tests') - dut.write('![ignore]') + dut.write('![ulp_deep_sleep_wakeup]') dut.expect_unity_test_output() + + +# Run all deepsleep wakeup tests one after the other instead of running them all with the `ulp_deep_sleep_wakeup` tag. +# This makes sure that all tests are run even after one test causes a system reset. +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +def test_ulp_deep_sleep_wakeup(dut: Dut) -> None: + dut.expect('Press ENTER to see the list of tests') + dut.write('"ULP-RISC-V is able to wakeup main CPU from deep sleep"') + dut.expect('rst:0x5')