diff --git a/components/esp_system/test_apps/esp_system_unity_tests/main/test_stack_check.c b/components/esp_system/test_apps/esp_system_unity_tests/main/test_stack_check.c index 763f758b3924..d3f3cbaeb8b6 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/main/test_stack_check.c +++ b/components/esp_system/test_apps/esp_system_unity_tests/main/test_stack_check.c @@ -21,7 +21,10 @@ static void recur_and_smash(void) } } - +/* Test is marked as ignore, since we cannot run it as a regular unity test case + Instead we run it in a seperate test case and check output with pytest, + see test_stack_smash_protection in the pytest file. + */ TEST_CASE("stack smashing protection", "[stack_check] [ignore]") { recur_and_smash(); diff --git a/components/esp_system/test_apps/esp_system_unity_tests/pytest_esp_system_unity_tests.py b/components/esp_system/test_apps/esp_system_unity_tests/pytest_esp_system_unity_tests.py index 1c598ca7da9a..4afa08c403fe 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/pytest_esp_system_unity_tests.py +++ b/components/esp_system/test_apps/esp_system_unity_tests/pytest_esp_system_unity_tests.py @@ -16,3 +16,17 @@ ) def test_esp_system(dut: Dut) -> None: dut.run_all_single_board_cases() + + +@pytest.mark.generic +@pytest.mark.parametrize( + 'config', + [ + pytest.param('default', marks=[pytest.mark.supported_targets]), + ] +) +def test_stack_smash_protection(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.write('"stack smashing protection"') + dut.expect_exact('Stack smashing protect failure!') + dut.expect_exact('Rebooting...') diff --git a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.default b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.default index d306fa0e421b..31d50f69086f 100644 --- a/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.default +++ b/components/esp_system/test_apps/esp_system_unity_tests/sdkconfig.ci.default @@ -1 +1,3 @@ # Default configuration +# Used for testing stack smashing protection +CONFIG_COMPILER_STACK_CHECK=y