Fixed unity fixture for ESP32/S2

* Created compile switch for UNITY_MAIN
  since it was using exit() syscall leading to
  abort() on ESP
This commit is contained in:
Jakob Hasse 2020-07-23 14:32:06 +08:00 committed by Fu Hanxi
parent f789380e19
commit 40d80b981a
6 changed files with 25 additions and 4 deletions

View File

@ -1,5 +1,7 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp_netif_test)

View File

@ -1,4 +1,5 @@
idf_component_register(SRCS "esp_netif_test.c"
REQUIRES test_utils
INCLUDE_DIRS "."
PRIV_INCLUDE_DIRS "../../private_include" "."
PRIV_INCLUDE_DIRS "$ENV{IDF_PATH}/components/esp_netif/private_include" "."
PRIV_REQUIRES unity esp_netif nvs_flash)

View File

@ -6,9 +6,9 @@
#include "esp_wifi.h"
#include "nvs_flash.h"
#include "esp_wifi_netif.h"
/* Fixme: re-add test_utils.h */
static void test_case_uses_tcpip(void) {}
#include "sdkconfig.h"
#include "lwip/sockets.h"
#include "test_utils.h"
TEST_GROUP(esp_netif);
@ -276,6 +276,7 @@ TEST_GROUP_RUNNER(esp_netif)
RUN_TEST_CASE(esp_netif, create_delete_multiple_netifs)
RUN_TEST_CASE(esp_netif, dhcp_client_state_transitions_wifi_sta)
RUN_TEST_CASE(esp_netif, dhcp_server_state_transitions_wifi_ap)
RUN_TEST_CASE(esp_netif, dhcp_server_state_transitions_mesh)
RUN_TEST_CASE(esp_netif, create_custom_wifi_interfaces)
RUN_TEST_CASE(esp_netif, get_set_hostname)
}

View File

@ -1,6 +1,8 @@
/* IDF-specific additions to "Unity Fixture" */
#pragma once
#ifndef CONFIG_IDF_TARGET
/* A shorthand for running one test group from the main function */
#define UNITY_MAIN(group_) do { \
const char* argv[] = { "test", "-v" }; \
@ -9,3 +11,15 @@
printf("\nTests finished, rc=%d\n", rc); \
exit(rc); \
} while(0)
#else // CONFIG_IDF_TARGET
/* A shorthand for running one test group from the main function */
#define UNITY_MAIN(group_) do { \
const char* argv[] = { "test", "-v" }; \
const int argc = sizeof(argv)/sizeof(argv[0]); \
int rc = UnityMain(argc, argv, TEST_ ## group_ ## _GROUP_RUNNER); \
printf("\nTests finished, rc=%d\n", rc); \
} while(0)
#endif // CONFIG_IDF_TARGET

View File

@ -82,6 +82,8 @@ components/libsodium/
components/spiffs/include/spiffs_config.h
components/unity/unity/src/unity_internals.h
components/unity/unity/extras/
components/unity/include/unity_fixture_extras.h
components/unity/include/unity_config.h
components/unity/include/unity_test_runner.h

View File

@ -18,6 +18,7 @@
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "unity.h"
#include "unity_test_runner.h"
#include "test_utils.h"
#include "esp_newlib.h"