Explorar el Código

Fixed unity fixture for ESP32/S2

* Created compile switch for UNITY_MAIN
  since it was using exit() syscall leading to
  abort() on ESP
Jakob Hasse hace 5 años
padre
commit
40d80b981a

+ 2 - 0
components/esp_netif/test_app/CMakeLists.txt

@@ -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)

+ 2 - 1
components/esp_netif/test_app/main/CMakeLists.txt

@@ -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)

+ 4 - 3
components/esp_netif/test_app/main/esp_netif_test.c

@@ -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)
 }

+ 14 - 0
components/unity/include/unity_fixture_extras.h

@@ -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

+ 2 - 0
tools/ci/check_public_headers_exceptions.txt

@@ -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
 

+ 1 - 0
tools/unit-test-app/components/test_utils/test_runner.c

@@ -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"