diff --git a/.gitmodules b/.gitmodules index e944b5da37..ef0542f4e4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -81,11 +81,11 @@ [submodule "components/unity/unity"] path = components/unity/unity url = ../../ThrowTheSwitch/Unity.git - sbom-version = v2.4.3-51-g7d2bf62b7e6a + sbom-version = v2.6.0-RC1 sbom-supplier = Organization: ThrowTheSwitch community sbom-url = https://github.com/ThrowTheSwitch/Unity sbom-description = Simple Unit Testing for C - sbom-hash = 7d2bf62b7e6afaf38153041a9d53c21aeeca9a25 + sbom-hash = bf560290f6020737eafaa8b5cbd2177c3956c03f [submodule "components/bt/host/nimble/nimble"] path = components/bt/host/nimble/nimble diff --git a/components/esp_eth/test_apps/main/esp_eth_test_apps.c b/components/esp_eth/test_apps/main/esp_eth_test_apps.c index 9a58b7b5fe..91fe20fa33 100644 --- a/components/esp_eth/test_apps/main/esp_eth_test_apps.c +++ b/components/esp_eth/test_apps/main/esp_eth_test_apps.c @@ -303,7 +303,7 @@ TEST_CASE("ethernet io speed/duplex/autonegotiation", "[ethernet]") static SemaphoreHandle_t loopback_test_case_data_received; static esp_err_t loopback_test_case_incoming_handler(esp_eth_handle_t eth_handle, uint8_t *buffer, uint32_t length, void *priv) { - TEST_ASSERT(memcmp(priv, buffer, LOOPBACK_TEST_PACKET_SIZE) == 0) + TEST_ASSERT(memcmp(priv, buffer, LOOPBACK_TEST_PACKET_SIZE) == 0); xSemaphoreGive(loopback_test_case_data_received); free(buffer); return ESP_OK; diff --git a/components/esp_http_server/test_apps/main/test_http_server.c b/components/esp_http_server/test_apps/main/test_http_server.c index 0acb8c9ed4..586539d1e0 100644 --- a/components/esp_http_server/test_apps/main/test_http_server.c +++ b/components/esp_http_server/test_apps/main/test_http_server.c @@ -92,7 +92,7 @@ httpd_handle_t test_httpd_start(uint16_t id) config.max_uri_handlers = HTTPD_TEST_MAX_URI_HANDLERS; config.server_port += id; config.ctrl_port += id; - TEST_ASSERT(httpd_start(&hd, &config) == ESP_OK) + TEST_ASSERT(httpd_start(&hd, &config) == ESP_OK); return hd; } diff --git a/components/freertos/test_apps/freertos/kernel/queue/test_freertos_backported_functions.c b/components/freertos/test_apps/freertos/kernel/queue/test_freertos_backported_functions.c index 17a73c3525..2ca77ad31e 100644 --- a/components/freertos/test_apps/freertos/kernel/queue/test_freertos_backported_functions.c +++ b/components/freertos/test_apps/freertos/kernel/queue/test_freertos_backported_functions.c @@ -184,7 +184,7 @@ TEST_CASE("Test FreeRTOS static task allocation", "[freertos]") (StaticTask_t *)&task_buffer, core); vTaskDelay(5); //Allow for static task to run, delete, and idle to clean up TEST_ASSERT_NOT_EQUAL(NULL, handle); //Check static task was successfully allocated - TEST_ASSERT_TRUE(has_run[core]) //Check static task has run + TEST_ASSERT_TRUE(has_run[core]); //Check static task has run } } diff --git a/components/freertos/test_apps/freertos/kernel/queue/test_freertos_debug_functions.c b/components/freertos/test_apps/freertos/kernel/queue/test_freertos_debug_functions.c index 491f035aa5..964c7bae49 100644 --- a/components/freertos/test_apps/freertos/kernel/queue/test_freertos_debug_functions.c +++ b/components/freertos/test_apps/freertos/kernel/queue/test_freertos_debug_functions.c @@ -77,7 +77,7 @@ TEST_CASE("Test FreeRTOS Queue Registry", "[freertos]") } for(int i = 0; i < NO_OF_QUEUES_TOTAL; i++){ const char *addr = pcQueueGetName(handles[i]); - TEST_ASSERT(addr == names[i]) //Check vQueueAddToRegistry was successful + TEST_ASSERT(addr == names[i]); //Check vQueueAddToRegistry was successful } portDISABLE_INTERRUPTS(); @@ -90,7 +90,7 @@ TEST_CASE("Test FreeRTOS Queue Registry", "[freertos]") } for(int i = 0; i < NO_OF_QUEUES_TOTAL; i++){ const char *addr = pcQueueGetName(handles[i]); - TEST_ASSERT(addr == NULL) //Check vQueueUnregisterQueue was successful + TEST_ASSERT(addr == NULL); //Check vQueueUnregisterQueue was successful handles[i] = NULL; } diff --git a/components/freertos/test_apps/freertos/kernel/tasks/test_freertos_trace_utilities.c b/components/freertos/test_apps/freertos/kernel/tasks/test_freertos_trace_utilities.c index bce8992127..116504dd37 100644 --- a/components/freertos/test_apps/freertos/kernel/tasks/test_freertos_trace_utilities.c +++ b/components/freertos/test_apps/freertos/kernel/tasks/test_freertos_trace_utilities.c @@ -47,13 +47,13 @@ void task_test_trace_utilities(void *arg) //Tests on this core TEST_ASSERT(uxTaskGetTaskNumber(task_handles[core]) == (0x0F << (core))); TEST_ASSERT(uxQueueGetQueueNumber(test_queues[core]) == (0x0F << (core))); - TEST_ASSERT(ucQueueGetQueueType(test_queues[core]) == BIN_SEM_QUEUE_TYPE) + TEST_ASSERT(ucQueueGetQueueType(test_queues[core]) == BIN_SEM_QUEUE_TYPE); //Test on other core #ifndef CONFIG_FREERTOS_UNICORE TEST_ASSERT(uxTaskGetTaskNumber(task_handles[!core]) == (0x0F << (!core))); TEST_ASSERT(uxQueueGetQueueNumber(test_queues[!core]) == (0x0F << (!core))); - TEST_ASSERT(ucQueueGetQueueType(test_queues[!core]) == BIN_SEM_QUEUE_TYPE) + TEST_ASSERT(ucQueueGetQueueType(test_queues[!core]) == BIN_SEM_QUEUE_TYPE); #endif xSemaphoreGive(test_queues[core]); //Signal done diff --git a/components/unity/CMakeLists.txt b/components/unity/CMakeLists.txt index c70df0fad6..ef7ee00cd2 100644 --- a/components/unity/CMakeLists.txt +++ b/components/unity/CMakeLists.txt @@ -1,7 +1,9 @@ idf_build_get_property(target IDF_TARGET) set(srcs - "unity/src/unity.c") + "unity/src/unity.c" + "unity_compat.c" +) set(includes "include" diff --git a/components/unity/include/unity_config.h b/components/unity/include/unity_config.h index 32f9719008..0d75508f91 100644 --- a/components/unity/include/unity_config.h +++ b/components/unity/include/unity_config.h @@ -7,6 +7,7 @@ #include #include +#include #include "sdkconfig.h" #ifdef CONFIG_UNITY_ENABLE_FLOAT @@ -29,6 +30,18 @@ #define UNITY_OUTPUT_COLOR #endif +#ifndef __cplusplus +#define UNITY_IS_NAN isnan +#define UNITY_IS_INF isinf +#else +#define UNITY_IS_NAN std::isnan +#define UNITY_IS_INF std::isinf +#endif + +// Note, using __noreturn__ rather than noreturn +// https://github.com/espressif/esp-idf/issues/11339 +#define UNITY_NORETURN __attribute__((__noreturn__)) + #define UNITY_EXCLUDE_TIME_H void unity_flush(void); @@ -51,6 +64,10 @@ uint32_t unity_exec_time_get_ms(void); #endif //CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER #ifdef CONFIG_UNITY_ENABLE_FIXTURE +// Two separate "extras" options here: +// 1. Disable memory allocation wrappers in Unity Fixture +#define UNITY_FIXTURE_NO_EXTRAS +// 2. Add IDF-specific additions to Unity Fixture #include "unity_fixture_extras.h" #endif // CONFIG_UNITY_ENABLE_FIXTURE diff --git a/components/unity/unity b/components/unity/unity index 7d2bf62b7e..bf560290f6 160000 --- a/components/unity/unity +++ b/components/unity/unity @@ -1 +1 @@ -Subproject commit 7d2bf62b7e6afaf38153041a9d53c21aeeca9a25 +Subproject commit bf560290f6020737eafaa8b5cbd2177c3956c03f diff --git a/components/unity/unity_compat.c b/components/unity/unity_compat.c new file mode 100644 index 0000000000..0cc215d09a --- /dev/null +++ b/components/unity/unity_compat.c @@ -0,0 +1,28 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include "unity.h" + +// Unity 2.6.0 has removed weak definitions of setUp, tearDown, suiteSetUp and suiteTearDown. +// (https://github.com/ThrowTheSwitch/Unity/pull/454) +// We need to provide them here to avoid breaking the existing test applications. + +__attribute__((weak)) void setUp(void) +{ +} + +__attribute__((weak)) void tearDown(void) +{ +} + + +__attribute__((weak)) void suiteSetUp(void) +{ +} + +__attribute__((weak)) int suiteTearDown(int num_failures) +{ + return num_failures; +} diff --git a/components/wpa_supplicant/test_apps/main/test_sae.c b/components/wpa_supplicant/test_apps/main/test_sae.c index 67b6d7fe9f..bb1e36728d 100644 --- a/components/wpa_supplicant/test_apps/main/test_sae.c +++ b/components/wpa_supplicant/test_apps/main/test_sae.c @@ -162,7 +162,7 @@ TEST_CASE("Test SAE functionality with ECC group", "[wpa3_sae]") TEST_ASSERT(sae.tmp->sae_rand != NULL); TEST_ASSERT(mask != NULL); - TEST_ASSERT(crypto_bignum_add(sae.tmp->sae_rand, mask, sae.tmp->own_commit_scalar) == 0) + TEST_ASSERT(crypto_bignum_add(sae.tmp->sae_rand, mask, sae.tmp->own_commit_scalar) == 0); TEST_ASSERT(crypto_bignum_mod(sae.tmp->own_commit_scalar, sae.tmp->order, sae.tmp->own_commit_scalar) == 0); TEST_ASSERT(crypto_ec_point_mul(sae.tmp->ec, sae.tmp->pwe_ecc, mask, sae.tmp->own_commit_element_ecc) == 0); TEST_ASSERT(crypto_ec_point_invert(sae.tmp->ec, sae.tmp->own_commit_element_ecc) == 0); @@ -176,7 +176,7 @@ TEST_CASE("Test SAE functionality with ECC group", "[wpa3_sae]") TEST_ASSERT(os_memcmp(wpabuf_head(buf), local_commit, sizeof(local_commit)) == 0); TEST_ASSERT(sae_parse_commit(&sae, peer_commit, sizeof(peer_commit), NULL, NULL, NULL, 0) == 0); - TEST_ASSERT(sae_process_commit(&sae) == 0) + TEST_ASSERT(sae_process_commit(&sae) == 0); ESP_LOGI("SAE TEST", "### Compare derived KCK,PMK,PMKID with predefined vectors ###"); ESP_LOG_BUFFER_HEXDUMP("SAE: Derived KCK ", sae.tmp->kck, SAE_KCK_LEN, ESP_LOG_INFO); @@ -214,7 +214,7 @@ TEST_CASE("Test SAE functionality with ECC group", "[wpa3_sae]") ESP_LOG_BUFFER_HEXDUMP("SAE: Derived SAE: PT.y ", bin + prime_len, prime_len, ESP_LOG_INFO); ESP_LOG_BUFFER_HEXDUMP("SAE: Predefined SAE: PT.y ", pwe_19_y, prime_len, ESP_LOG_INFO); - TEST_ASSERT(os_memcmp(pwe_19_y, bin + prime_len, prime_len) == 0) + TEST_ASSERT(os_memcmp(pwe_19_y, bin + prime_len, prime_len) == 0); crypto_ec_point_deinit(pwe, 1); sae_deinit_pt(pt_info); diff --git a/docs/en/COPYRIGHT.rst b/docs/en/COPYRIGHT.rst index 24a30dcf83..8f022e98ad 100644 --- a/docs/en/COPYRIGHT.rst +++ b/docs/en/COPYRIGHT.rst @@ -71,7 +71,7 @@ These third party libraries can be included into the application (firmware) prod * `CMock`_ Mock/stub generator for C, Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams, is licensed under MIT license as described in :component_file:`LICENSE file `. -* `Unity`_ Simple Unit Testing library, Copyright (c) 2007-23 Mike Karlesky, Mark VanderVoord, Greg Williams, is licensed under MIT license as described in :component_file:`LICENSE file `. +* `Unity`_ Simple Unit Testing library, Copyright (c) 2007-23 Mike Karlesky, Mark VanderVoord, Greg Williams, is licensed under MIT license as described in :component_file:`LICENSE file `. Documentation ------------- diff --git a/docs/en/migration-guides/release-5.x/5.3/system.rst b/docs/en/migration-guides/release-5.x/5.3/system.rst index 32c4f08b69..1b11c2a839 100644 --- a/docs/en/migration-guides/release-5.x/5.3/system.rst +++ b/docs/en/migration-guides/release-5.x/5.3/system.rst @@ -6,4 +6,19 @@ System Power Management ----------------------- -* ``esp_sleep_enable_ext1_wakeup_with_level_mask`` is deprecated, use ``esp_sleep_enable_ext1_wakeup_io`` and ``esp_sleep_disable_ext1_wakeup_io`` instead. +* ``esp_sleep_enable_ext1_wakeup_with_level_mask`` is deprecated, use :cpp:func:`esp_sleep_enable_ext1_wakeup_io` and :cpp:func:`esp_sleep_disable_ext1_wakeup_io` instead. + +Unit Testing +----------------------- + +In the past versions of Unity framework, it was possible to omit a semicolon at the end of a ``TEST_ASSERT_*`` macro statement. This is no longer the case in the newer version of Unity, used in IDF v5.3. + +For example, the following code: + +.. code-block:: c + + TEST_ASSERT(some_func() == ESP_OK) + +will now result in a compilation error. To fix this, add a semicolon at the end of the statement: + + TEST_ASSERT(some_func() == ESP_OK);