Merge branch 'bugfix/esp_timer_test_fail' into 'master'

fix(esp_timer): Force test to go light sleep ignoring ESP_ERR_SLEEP_REJECT

Closes IDFCI-2091, IDFCI-2092, and IDFCI-2093

See merge request espressif/esp-idf!29814
This commit is contained in:
Konstantin Kondrashov
2024-03-26 22:22:48 +08:00

View File

@@ -36,17 +36,19 @@ TEST_CASE("Test the periodic timer does not handle lost events during light slee
int period_cb_ms = 10; int period_cb_ms = 10;
int interval_ms = 50; int interval_ms = 50;
TEST_ESP_OK(esp_timer_start_periodic(periodic_timer, period_cb_ms * 1000));
TEST_ESP_OK(esp_sleep_enable_timer_wakeup(interval_ms * 1000));
printf("Run light sleep\n"); printf("Run light sleep\n");
printf("count_calls should be around = %d\n", interval_ms / period_cb_ms); printf("count_calls should be around = %d\n", interval_ms / period_cb_ms);
TEST_ESP_OK(esp_sleep_enable_timer_wakeup(interval_ms * 1000));
TEST_ESP_OK(esp_timer_start_periodic(periodic_timer, period_cb_ms * 1000));
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
count_calls = 0; do {
TEST_ESP_OK(esp_light_sleep_start()); count_calls = 0;
} while (esp_light_sleep_start() != ESP_OK);
esp_rom_delay_us(interval_ms * 1000); esp_rom_delay_us(interval_ms * 1000);
printf("count_calls = %d\n", count_calls); int saved_count_calls = count_calls;
TEST_ASSERT_INT_WITHIN(2, interval_ms / period_cb_ms, count_calls); printf("count_calls = %d\n", saved_count_calls);
TEST_ESP_OK(esp_timer_dump(stdout)); TEST_ESP_OK(esp_timer_dump(stdout));
TEST_ASSERT_INT_WITHIN(2, interval_ms / period_cb_ms, saved_count_calls);
} }
TEST_ESP_OK(esp_timer_stop(periodic_timer)); TEST_ESP_OK(esp_timer_stop(periodic_timer));
// times_skipped is about 12 (4 from each sleep time). // times_skipped is about 12 (4 from each sleep time).
@@ -54,4 +56,4 @@ TEST_CASE("Test the periodic timer does not handle lost events during light slee
TEST_ESP_OK(esp_timer_delete(periodic_timer)); TEST_ESP_OK(esp_timer_delete(periodic_timer));
} }
#endif // SOC_SLEEP_SUPPORTED #endif // SOC_LIGHT_SLEEP_SUPPORTED