Merge branch 'bugfix/lp_core_tests_race_condition_v5.3' into 'release/v5.3'

fix(lp_core_test): fixed race-condition in lp core tests (v5.3)

See merge request espressif/esp-idf!30931
This commit is contained in:
Marius Vikhammer 2024-05-20 12:12:49 +08:00
commit 95cfd3987b
2 changed files with 10 additions and 8 deletions

View File

@ -71,11 +71,9 @@ void handle_commands(lp_core_test_commands_t cmd)
break;
case LP_CORE_NO_COMMAND:
main_cpu_reply = LP_CORE_COMMAND_NOK;
break;
default:
main_cpu_reply = LP_CORE_COMMAND_NOK;
break;
}
}

View File

@ -47,6 +47,12 @@ static void load_and_start_lp_core_firmware(ulp_lp_core_cfg_t* cfg, const uint8_
}
static void clear_test_cmds(void)
{
ulp_main_cpu_command = LP_CORE_NO_COMMAND;
ulp_command_resp = LP_CORE_NO_COMMAND;
}
TEST_CASE("LP core and main CPU are able to exchange data", "[lp_core]")
{
const uint32_t test_data = 0x12345678;
@ -76,9 +82,7 @@ TEST_CASE("LP core and main CPU are able to exchange data", "[lp_core]")
printf("data out: 0x%" PRIx32 ", expected: 0x%" PRIx32 " \n", ulp_test_data_out, test_data);
TEST_ASSERT(test_data == ulp_test_data_out);
/* Clear test data */
ulp_main_cpu_command = LP_CORE_NO_COMMAND;
ulp_command_resp = LP_CORE_NO_COMMAND;
clear_test_cmds();
}
TEST_CASE("Test LP core delay", "[lp_core]")
@ -113,9 +117,7 @@ TEST_CASE("Test LP core delay", "[lp_core]")
printf("Waited for %" PRIi64 "us, expected: %" PRIi32 "us\n", diff, delay_period_us);
TEST_ASSERT_INT_WITHIN(delta_us, delay_period_us, diff);
/* Clear test data */
ulp_main_cpu_command = LP_CORE_NO_COMMAND;
ulp_command_resp = LP_CORE_NO_COMMAND;
clear_test_cmds();
}
#define LP_TIMER_TEST_DURATION_S (5)
@ -210,6 +212,8 @@ static void check_reset_reason_and_sleep_duration(void)
printf("CPU slept for %"PRIi64" ms, expected it to sleep approx %"PRIi64" ms\n", sleep_duration, expected_sleep_duration_ms);
/* Rough estimate, as CPU spends quite some time waking up, but will test if lp core is waking up way too often etc */
TEST_ASSERT_INT_WITHIN_MESSAGE(1000, expected_sleep_duration_ms, sleep_duration, "LP Core did not wake up the expected number of times");
clear_test_cmds();
}
TEST_CASE_MULTIPLE_STAGES("LP Timer can wakeup lp core periodically during deep sleep", "[ulp]",