system/test: use TEST_ESP_OK instead of ESP_ERROR_CHECK

This commit is contained in:
jingli
2023-03-06 11:56:56 +08:00
parent 38c25ebceb
commit cb64ff74fc

View File

@@ -531,10 +531,10 @@ static void trigger_deepsleep(void)
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
// NVS partition was truncated and needs to be erased // NVS partition was truncated and needs to be erased
// Retry nvs_flash_init // Retry nvs_flash_init
ESP_ERROR_CHECK(nvs_flash_erase()); TEST_ESP_OK(nvs_flash_erase());
err = nvs_flash_init(); err = nvs_flash_init();
} }
ESP_ERROR_CHECK(err); TEST_ESP_OK(err);
nvs_handle_t nvs_handle; nvs_handle_t nvs_handle;
err = nvs_open("storage", NVS_READWRITE, &nvs_handle); err = nvs_open("storage", NVS_READWRITE, &nvs_handle);
@@ -557,12 +557,12 @@ static void trigger_deepsleep(void)
// Save start time. Deep sleep. // Save start time. Deep sleep.
gettimeofday(&start, NULL); gettimeofday(&start, NULL);
ESP_ERROR_CHECK(nvs_set_i32(nvs_handle, "start_sec", start.tv_sec)); TEST_ESP_OK(nvs_set_i32(nvs_handle, "start_sec", start.tv_sec));
ESP_ERROR_CHECK(nvs_set_i32(nvs_handle, "start_usec", start.tv_usec)); TEST_ESP_OK(nvs_set_i32(nvs_handle, "start_usec", start.tv_usec));
ESP_ERROR_CHECK(nvs_commit(nvs_handle)); TEST_ESP_OK(nvs_commit(nvs_handle));
nvs_close(nvs_handle); nvs_close(nvs_handle);
// Deinit NVS to prevent Unity from complaining "The test leaked too much memory" // Deinit NVS to prevent Unity from complaining "The test leaked too much memory"
ESP_ERROR_CHECK(nvs_flash_deinit()); TEST_ESP_OK(nvs_flash_deinit());
esp_sleep_enable_timer_wakeup(1000); esp_sleep_enable_timer_wakeup(1000);
// In function esp_deep_sleep_start() uses function esp_sync_timekeeping_timers() // In function esp_deep_sleep_start() uses function esp_sync_timekeeping_timers()
@@ -579,10 +579,10 @@ static void check_time_deepsleep(void)
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
// NVS partition was truncated and needs to be erased // NVS partition was truncated and needs to be erased
// Retry nvs_flash_init // Retry nvs_flash_init
ESP_ERROR_CHECK(nvs_flash_erase()); TEST_ESP_OK(nvs_flash_erase());
err = nvs_flash_init(); err = nvs_flash_init();
} }
ESP_ERROR_CHECK(err); TEST_ESP_OK(err);
nvs_handle_t nvs_handle; nvs_handle_t nvs_handle;
err = nvs_open("storage", NVS_READWRITE, &nvs_handle); err = nvs_open("storage", NVS_READWRITE, &nvs_handle);
@@ -593,11 +593,11 @@ static void check_time_deepsleep(void)
} }
// Get start time of deep sleep // Get start time of deep sleep
ESP_ERROR_CHECK(nvs_get_i32(nvs_handle, "start_sec", (int32_t *)&start.tv_sec)); TEST_ESP_OK(nvs_get_i32(nvs_handle, "start_sec", (int32_t *)&start.tv_sec));
ESP_ERROR_CHECK(nvs_get_i32(nvs_handle, "start_usec", (int32_t *)&start.tv_usec)); TEST_ESP_OK(nvs_get_i32(nvs_handle, "start_usec", (int32_t *)&start.tv_usec));
nvs_close(nvs_handle); nvs_close(nvs_handle);
// Deinit NVS to prevent Unity from complaining "The test leaked too much memory" // Deinit NVS to prevent Unity from complaining "The test leaked too much memory"
ESP_ERROR_CHECK(nvs_flash_deinit()); TEST_ESP_OK(nvs_flash_deinit());
// Reset must be caused by deep sleep // Reset must be caused by deep sleep
soc_reset_reason_t reason = esp_rom_get_reset_reason(0); soc_reset_reason_t reason = esp_rom_get_reset_reason(0);