resume wifi init test on esp32s2

This commit is contained in:
morris 2020-02-24 14:03:25 +08:00
parent 237f6448d3
commit 2227e2505b

View File

@ -13,7 +13,6 @@
#define EVENT_HANDLER_FLAG_DO_NOT_AUTO_RECONNECT 0x00000001
#define EMPH_STR(s) "****** "s" ******"
#if !TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2)
static const char* TAG = "test_wifi_init";
static uint32_t wifi_event_handler_flag;
static EventGroupHandle_t wifi_events;
@ -67,11 +66,18 @@ static esp_err_t event_init(void)
return ESP_OK;
}
static esp_err_t event_deinit(void)
{
ESP_ERROR_CHECK(esp_event_handler_unregister(WIFI_EVENT,ESP_EVENT_ANY_ID,&wifi_event_handler));
ESP_ERROR_CHECK(esp_event_handler_unregister(IP_EVENT,ESP_EVENT_ANY_ID,&ip_event_handler));
ESP_ERROR_CHECK(esp_event_loop_delete_default());
return ESP_OK;
}
static void wifi_driver_can_start_on_APP_CPU_task(void* arg)
{
SemaphoreHandle_t *sema = (SemaphoreHandle_t *) arg;
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
//init nvs
ESP_LOGI(TAG, EMPH_STR("nvs_flash_init"));
esp_err_t r = nvs_flash_init();
if (r == ESP_ERR_NVS_NO_FREE_PAGES || r == ESP_ERR_NVS_NEW_VERSION_FOUND) {
@ -80,18 +86,18 @@ static void wifi_driver_can_start_on_APP_CPU_task(void* arg)
r = nvs_flash_init();
}
TEST_ESP_OK(r);
//init event loop
ESP_LOGI(TAG, EMPH_STR("event_init"));
event_init();
unity_reset_leak_checks();
TEST_ESP_OK(event_init());
ESP_LOGI(TAG, EMPH_STR("esp_wifi_init"));
TEST_ESP_OK(esp_wifi_init(&cfg));
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit..."));
TEST_ESP_OK(esp_wifi_deinit());
ESP_LOGI(TAG, EMPH_STR("event_deinit"));
TEST_ESP_OK(event_deinit());
ESP_LOGI(TAG, EMPH_STR("nvs_flash_deinit..."));
nvs_flash_deinit();
ESP_LOGI(TAG, "test passed...");
TEST_ESP_OK(nvs_flash_deinit());
xSemaphoreGive(*sema);
ESP_LOGI(TAG, "exit task...");
vTaskDelete(NULL);
}
@ -108,14 +114,12 @@ TEST_CASE("wifi driver can start on APP CPU", "[wifi_init]")
xSemaphoreTake(sema, portMAX_DELAY);
vSemaphoreDelete(sema);
sema = NULL;
TEST_IGNORE_MESSAGE("this test case is ignored due to the event_loop.");
}
static void wifi_start_stop_task(void* arg)
{
SemaphoreHandle_t *sema = (SemaphoreHandle_t *) arg;
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
//init nvs
ESP_LOGI(TAG, EMPH_STR("nvs_flash_init"));
esp_err_t r = nvs_flash_init();
if (r == ESP_ERR_NVS_NO_FREE_PAGES || r == ESP_ERR_NVS_NEW_VERSION_FOUND) {
@ -125,22 +129,21 @@ static void wifi_start_stop_task(void* arg)
}
TEST_ESP_OK(r);
//init tcpip stack
ESP_LOGI(TAG, EMPH_STR("esp_netif_init"));
esp_netif_init();
//init event loop
test_case_uses_tcpip();
ESP_LOGI(TAG, EMPH_STR("event_init"));
event_init();
unity_reset_leak_checks();
TEST_ESP_OK(event_init());
ESP_LOGI(TAG, EMPH_STR("esp_wifi_init"));
TEST_ASSERT(esp_wifi_init(&cfg) == ESP_OK);
TEST_ESP_OK(esp_wifi_init(&cfg));
ESP_LOGI(TAG, EMPH_STR("esp_wifi_start"));
TEST_ASSERT(esp_wifi_start() == ESP_OK);
TEST_ESP_OK(esp_wifi_start());
ESP_LOGI(TAG, EMPH_STR("esp_wifi_stop"));
TEST_ASSERT(esp_wifi_stop() == ESP_OK);
TEST_ESP_OK(esp_wifi_stop());
ESP_LOGI(TAG, EMPH_STR("esp_wifi_stop"));
TEST_ASSERT(esp_wifi_stop() == ESP_OK);
TEST_ESP_OK(esp_wifi_stop());
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit"));
TEST_ASSERT(esp_wifi_deinit() == ESP_OK);
TEST_ESP_OK(esp_wifi_deinit());
ESP_LOGI(TAG, EMPH_STR("event_deinit"));
TEST_ESP_OK(event_deinit());
ESP_LOGI(TAG, EMPH_STR("nvs_flash_deinit..."));
nvs_flash_deinit();
ESP_LOGI(TAG, "test passed...");
@ -161,14 +164,12 @@ TEST_CASE("Calling esp_wifi_stop() with start", "[wifi_init]")
xSemaphoreTake(sema, portMAX_DELAY);
vSemaphoreDelete(sema);
sema = NULL;
TEST_IGNORE_MESSAGE("this test case is ignored due to the critical memory leak of tcpip_adapter and event_loop.");
}
static void wifi_stop_task(void* arg)
{
SemaphoreHandle_t *sema = (SemaphoreHandle_t *) arg;
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
//init nvs
ESP_LOGI(TAG, EMPH_STR("nvs_flash_init"));
esp_err_t r = nvs_flash_init();
if (r == ESP_ERR_NVS_NO_FREE_PAGES || r == ESP_ERR_NVS_NEW_VERSION_FOUND) {
@ -177,18 +178,18 @@ static void wifi_stop_task(void* arg)
r = nvs_flash_init();
}
TEST_ESP_OK(r);
//init event loop
ESP_LOGI(TAG, EMPH_STR("event_init"));
event_init();
unity_reset_leak_checks();
TEST_ESP_OK(event_init());
ESP_LOGI(TAG, EMPH_STR("esp_wifi_init"));
TEST_ASSERT(esp_wifi_init(&cfg) == ESP_OK);
TEST_ESP_OK(esp_wifi_init(&cfg));
ESP_LOGI(TAG, EMPH_STR("esp_wifi_stop"));
TEST_ASSERT(esp_wifi_stop() == ESP_OK);
TEST_ESP_OK(esp_wifi_stop());
ESP_LOGI(TAG, EMPH_STR("esp_wifi_stop"));
TEST_ASSERT(esp_wifi_stop() == ESP_OK);
TEST_ESP_OK(esp_wifi_stop());
ESP_LOGI(TAG, EMPH_STR("esp_wifi_deinit"));
TEST_ASSERT(esp_wifi_deinit() == ESP_OK);
TEST_ESP_OK(esp_wifi_deinit());
ESP_LOGI(TAG, EMPH_STR("event_deinit"));
TEST_ESP_OK(event_deinit());
ESP_LOGI(TAG, EMPH_STR("nvs_flash_deinit..."));
nvs_flash_deinit();
ESP_LOGI(TAG, "test passed...");
@ -209,6 +210,4 @@ TEST_CASE("Calling esp_wifi_stop() without start", "[wifi_init]")
xSemaphoreTake(sema, portMAX_DELAY);
vSemaphoreDelete(sema);
sema = NULL;
TEST_IGNORE_MESSAGE("this test case is ignored due to the event_loop.");
}
#endif //!TEMPORARY_DISABLED_FOR_TARGETS(ESP32S2)