diff --git a/.gitmodules b/.gitmodules index 64828e742c..9b3e61bf5b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -86,3 +86,7 @@ [submodule "examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib"] path = examples/peripherals/secure_element/atecc608_ecdsa/components/esp-cryptoauthlib url = ../../espressif/esp-cryptoauthlib.git + +[submodule "components/cmock/CMock"] + path = components/cmock/CMock + url = ../../ThrowTheSwitch/CMock.git diff --git a/components/app_trace/test/CMakeLists.txt b/components/app_trace/test/CMakeLists.txt index d574eb7ba5..f2df0fd7cc 100644 --- a/components/app_trace/test/CMakeLists.txt +++ b/components/app_trace/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity) \ No newline at end of file + PRIV_REQUIRES cmock) diff --git a/components/app_update/test/CMakeLists.txt b/components/app_update/test/CMakeLists.txt index f140cffa0a..92e3da05c3 100644 --- a/components/app_update/test/CMakeLists.txt +++ b/components/app_update/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils app_update bootloader_support nvs_flash - ) \ No newline at end of file + PRIV_REQUIRES cmock test_utils app_update bootloader_support nvs_flash + ) diff --git a/components/bootloader_support/test/CMakeLists.txt b/components/bootloader_support/test/CMakeLists.txt index fb3d925668..ffd8537197 100644 --- a/components/bootloader_support/test/CMakeLists.txt +++ b/components/bootloader_support/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity bootloader_support app_update) + PRIV_REQUIRES cmock bootloader_support app_update) diff --git a/components/bt/test/CMakeLists.txt b/components/bt/test/CMakeLists.txt index 34fac91ea5..27fb94b6e6 100644 --- a/components/bt/test/CMakeLists.txt +++ b/components/bt/test/CMakeLists.txt @@ -1,5 +1,5 @@ if(CONFIG_BT_ENABLED OR CMAKE_BUILD_EARLY_EXPANSION) idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity nvs_flash bt) -endif() \ No newline at end of file + PRIV_REQUIRES cmock nvs_flash bt) +endif() diff --git a/components/cmock/CMakeLists.txt b/components/cmock/CMakeLists.txt new file mode 100644 index 0000000000..3480d7bc04 --- /dev/null +++ b/components/cmock/CMakeLists.txt @@ -0,0 +1,5 @@ +# Although unity is a submodule of cmock, we still depend on the unity component in IDF. +# This is because CI currently doesn't checkout submodules recursively. +idf_component_register(SRCS "CMock/src/cmock.c" + REQUIRES unity + INCLUDE_DIRS "CMock/src") diff --git a/components/cmock/CMock b/components/cmock/CMock new file mode 160000 index 0000000000..eeecc49ce8 --- /dev/null +++ b/components/cmock/CMock @@ -0,0 +1 @@ +Subproject commit eeecc49ce8af123cf8ad40efdb9673e37b56230f diff --git a/components/cmock/Makefile.projbuild b/components/cmock/Makefile.projbuild new file mode 100644 index 0000000000..39d01abd2b --- /dev/null +++ b/components/cmock/Makefile.projbuild @@ -0,0 +1 @@ +CPPFLAGS += -DUNITY_INCLUDE_CONFIG_H diff --git a/components/cmock/component.mk b/components/cmock/component.mk new file mode 100644 index 0000000000..1d4275491c --- /dev/null +++ b/components/cmock/component.mk @@ -0,0 +1,4 @@ +# +# Component Makefile +# + diff --git a/components/console/test/CMakeLists.txt b/components/console/test/CMakeLists.txt index 1356216241..01903c4f1c 100644 --- a/components/console/test/CMakeLists.txt +++ b/components/console/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . - PRIV_REQUIRES unity test_utils console) + PRIV_REQUIRES cmock test_utils console) diff --git a/components/cxx/test/CMakeLists.txt b/components/cxx/test/CMakeLists.txt index d574eb7ba5..f2df0fd7cc 100644 --- a/components/cxx/test/CMakeLists.txt +++ b/components/cxx/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity) \ No newline at end of file + PRIV_REQUIRES cmock) diff --git a/components/driver/test/CMakeLists.txt b/components/driver/test/CMakeLists.txt index 734c10b71e..41bba83e30 100644 --- a/components/driver/test/CMakeLists.txt +++ b/components/driver/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS . param_test touch_sensor_test adc_dma_test dac_dma_test PRIV_INCLUDE_DIRS include param_test/include touch_sensor_test/include - PRIV_REQUIRES unity test_utils driver nvs_flash esp_serial_slave_link infrared_tools esp_adc_cal) \ No newline at end of file + PRIV_REQUIRES cmock test_utils driver nvs_flash esp_serial_slave_link infrared_tools esp_adc_cal) diff --git a/components/efuse/test/CMakeLists.txt b/components/efuse/test/CMakeLists.txt index e31eefc226..34fee33294 100644 --- a/components/efuse/test/CMakeLists.txt +++ b/components/efuse/test/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." "include" PRIV_INCLUDE_DIRS "../private_include" - PRIV_REQUIRES unity test_utils efuse bootloader_support - ) \ No newline at end of file + PRIV_REQUIRES cmock test_utils efuse bootloader_support + ) diff --git a/components/esp32/test/CMakeLists.txt b/components/esp32/test/CMakeLists.txt index 297fa6370f..6aed5f74f2 100644 --- a/components/esp32/test/CMakeLists.txt +++ b/components/esp32/test/CMakeLists.txt @@ -1,7 +1,7 @@ if(IDF_TARGET STREQUAL "esp32") idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . - PRIV_REQUIRES unity test_utils nvs_flash ulp esp_common + PRIV_REQUIRES cmock test_utils nvs_flash ulp esp_common ) target_link_libraries(${COMPONENT_LIB} INTERFACE "-u ld_include_test_dport_xt_highint5") endif() diff --git a/components/esp32s2/test/CMakeLists.txt b/components/esp32s2/test/CMakeLists.txt index 7d5e8e3953..da0006730e 100644 --- a/components/esp32s2/test/CMakeLists.txt +++ b/components/esp32s2/test/CMakeLists.txt @@ -1,7 +1,7 @@ if(IDF_TARGET STREQUAL "esp32s2") idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . - PRIV_REQUIRES unity test_utils nvs_flash ulp esp_common + PRIV_REQUIRES cmock test_utils nvs_flash ulp esp_common ) endif() diff --git a/components/esp_common/test/CMakeLists.txt b/components/esp_common/test/CMakeLists.txt index 10798f8564..e9a94c655a 100644 --- a/components/esp_common/test/CMakeLists.txt +++ b/components/esp_common/test/CMakeLists.txt @@ -1,2 +1,3 @@ idf_component_register(SRC_DIRS . - PRIV_REQUIRES unity test_utils spi_flash) + PRIV_REQUIRES cmock test_utils spi_flash + ) diff --git a/components/esp_eth/test/CMakeLists.txt b/components/esp_eth/test/CMakeLists.txt index 0be5a5e491..94d81cad2d 100644 --- a/components/esp_eth/test/CMakeLists.txt +++ b/components/esp_eth/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . - PRIV_REQUIRES unity test_utils esp_eth esp_http_client + PRIV_REQUIRES cmock test_utils esp_eth esp_http_client ) diff --git a/components/esp_event/test/CMakeLists.txt b/components/esp_event/test/CMakeLists.txt index 2ed9fafa33..44e4b7ec84 100644 --- a/components/esp_event/test/CMakeLists.txt +++ b/components/esp_event/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS . ../private_include - PRIV_REQUIRES unity test_utils esp_event driver) + PRIV_REQUIRES cmock test_utils esp_event driver) diff --git a/components/esp_hid/test/CMakeLists.txt b/components/esp_hid/test/CMakeLists.txt index 48087e3313..75bf32cdcc 100644 --- a/components/esp_hid/test/CMakeLists.txt +++ b/components/esp_hid/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." INCLUDE_DIRS "." - REQUIRES unity test_utils esp_hid) + REQUIRES cmock test_utils esp_hid) diff --git a/components/esp_http_client/test/CMakeLists.txt b/components/esp_http_client/test/CMakeLists.txt index 202d2fed13..1003916af6 100644 --- a/components/esp_http_client/test/CMakeLists.txt +++ b/components/esp_http_client/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils esp_http_client) \ No newline at end of file + PRIV_REQUIRES cmock test_utils esp_http_client) diff --git a/components/esp_http_server/test/CMakeLists.txt b/components/esp_http_server/test/CMakeLists.txt index 06a638c13b..03dad364f4 100644 --- a/components/esp_http_server/test/CMakeLists.txt +++ b/components/esp_http_server/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils esp_http_server) \ No newline at end of file + PRIV_REQUIRES cmock test_utils esp_http_server) \ No newline at end of file diff --git a/components/esp_ipc/test/CMakeLists.txt b/components/esp_ipc/test/CMakeLists.txt index 1e6b4c8b07..1a19ee3a32 100644 --- a/components/esp_ipc/test/CMakeLists.txt +++ b/components/esp_ipc/test/CMakeLists.txt @@ -1,6 +1,6 @@ if(IDF_TARGET STREQUAL "esp32") idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils) + PRIV_REQUIRES cmock test_utils) endif() diff --git a/components/esp_netif/test/CMakeLists.txt b/components/esp_netif/test/CMakeLists.txt index 8efc8936ae..01b0f04330 100644 --- a/components/esp_netif/test/CMakeLists.txt +++ b/components/esp_netif/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "../private_include" "." - PRIV_REQUIRES unity test_utils esp_netif nvs_flash) \ No newline at end of file + PRIV_REQUIRES cmock test_utils esp_netif nvs_flash) \ No newline at end of file diff --git a/components/esp_ringbuf/test/CMakeLists.txt b/components/esp_ringbuf/test/CMakeLists.txt index c117151814..ed052cc07f 100644 --- a/components/esp_ringbuf/test/CMakeLists.txt +++ b/components/esp_ringbuf/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils) \ No newline at end of file + PRIV_REQUIRES cmock test_utils) diff --git a/components/esp_rom/test/CMakeLists.txt b/components/esp_rom/test/CMakeLists.txt index c28ddcca46..82049b5644 100644 --- a/components/esp_rom/test/CMakeLists.txt +++ b/components/esp_rom/test/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . ${CMAKE_CURRENT_BINARY_DIR} - PRIV_REQUIRES unity test_utils) + PRIV_REQUIRES cmock test_utils) if(IDF_TARGET STREQUAL "esp32") add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/test_tjpgd_logo.h" diff --git a/components/esp_timer/test/CMakeLists.txt b/components/esp_timer/test/CMakeLists.txt index f3ffa1f607..218dd6b897 100644 --- a/components/esp_timer/test/CMakeLists.txt +++ b/components/esp_timer/test/CMakeLists.txt @@ -1,7 +1,7 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "../private_include" - PRIV_REQUIRES unity test_utils) + PRIV_REQUIRES cmock test_utils) if(CONFIG_ESP_TIMER_IMPL_FRC2) idf_build_set_property(COMPILE_DEFINITIONS "-DESP_TIMER_DYNAMIC_OVERFLOW_VAL" APPEND) -endif() \ No newline at end of file +endif() diff --git a/components/esp_wifi/test/CMakeLists.txt b/components/esp_wifi/test/CMakeLists.txt index 9cfc6c49f2..32588d6601 100644 --- a/components/esp_wifi/test/CMakeLists.txt +++ b/components/esp_wifi/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . ${CMAKE_CURRENT_BINARY_DIR} - PRIV_REQUIRES unity test_utils nvs_flash ulp esp_common + PRIV_REQUIRES cmock test_utils nvs_flash ulp esp_common ) diff --git a/components/espcoredump/test/CMakeLists.txt b/components/espcoredump/test/CMakeLists.txt index 72841c52d4..4ab14c0fe8 100644 --- a/components/espcoredump/test/CMakeLists.txt +++ b/components/espcoredump/test/CMakeLists.txt @@ -3,5 +3,5 @@ if(TESTS_ALL EQUAL 1) else() idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity nvs_flash) + PRIV_REQUIRES cmock nvs_flash) endif() \ No newline at end of file diff --git a/components/expat/test/CMakeLists.txt b/components/expat/test/CMakeLists.txt index 6e5f5cadd7..d60400be37 100644 --- a/components/expat/test/CMakeLists.txt +++ b/components/expat/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity expat) \ No newline at end of file + PRIV_REQUIRES cmock expat) diff --git a/components/fatfs/test/CMakeLists.txt b/components/fatfs/test/CMakeLists.txt index d1a90750bf..cc3285cee6 100644 --- a/components/fatfs/test/CMakeLists.txt +++ b/components/fatfs/test/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . - PRIV_REQUIRES unity test_utils vfs fatfs + PRIV_REQUIRES cmock test_utils vfs fatfs EMBED_TXTFILES fatfs.img ) \ No newline at end of file diff --git a/components/freertos/test/CMakeLists.txt b/components/freertos/test/CMakeLists.txt index 72b61327d3..fe5e7e2b29 100644 --- a/components/freertos/test/CMakeLists.txt +++ b/components/freertos/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . - PRIV_REQUIRES unity test_utils esp_ipc - ) \ No newline at end of file + PRIV_REQUIRES cmock test_utils esp_ipc + ) diff --git a/components/heap/test/CMakeLists.txt b/components/heap/test/CMakeLists.txt index a04ffe0bbd..6da69a0cbc 100644 --- a/components/heap/test/CMakeLists.txt +++ b/components/heap/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils heap) \ No newline at end of file + PRIV_REQUIRES cmock test_utils heap) diff --git a/components/libsodium/test/CMakeLists.txt b/components/libsodium/test/CMakeLists.txt index 614a03f854..41de273958 100644 --- a/components/libsodium/test/CMakeLists.txt +++ b/components/libsodium/test/CMakeLists.txt @@ -2,7 +2,7 @@ if(TESTS_ALL EQUAL 1) message("not linking libsodium tests, use '-T libsodium' to test it") else() get_filename_component(LS_TESTDIR "${CMAKE_CURRENT_LIST_DIR}/../libsodium/test/default" ABSOLUTE) - + set(TEST_CASES "chacha20;aead_chacha20poly1305;box;box2;ed25519_convert;sign;hash") foreach(test_case ${TEST_CASES}) @@ -12,7 +12,7 @@ else() idf_component_register(SRCS "${TEST_CASES_FILES}" "test_sodium.c" PRIV_INCLUDE_DIRS "." "${LS_TESTDIR}/../quirks" - PRIV_REQUIRES unity libsodium) + PRIV_REQUIRES cmock libsodium) # The libsodium test suite is designed to be run each test case as an executable on a desktop computer and uses # filesytem to write & then compare contents of each file. @@ -33,4 +33,4 @@ else() # this seems odd, but it prevents the libsodium test harness from # trying to write to a file! add_definitions(-DBROWSER_TESTS) -endif() \ No newline at end of file +endif() diff --git a/components/mbedtls/test/CMakeLists.txt b/components/mbedtls/test/CMakeLists.txt index b7239e84a8..dfe3e71c06 100644 --- a/components/mbedtls/test/CMakeLists.txt +++ b/components/mbedtls/test/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils mbedtls libsodium + PRIV_REQUIRES cmock test_utils mbedtls libsodium EMBED_TXTFILES server_cert_chain.pem prvtkey.pem server_cert_bundle) diff --git a/components/mdns/test/CMakeLists.txt b/components/mdns/test/CMakeLists.txt index 516ee0097b..a24aa2433a 100644 --- a/components/mdns/test/CMakeLists.txt +++ b/components/mdns/test/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRC_DIRS "." - PRIV_REQUIRES unity test_utils mdns) \ No newline at end of file + PRIV_REQUIRES cmock test_utils mdns) \ No newline at end of file diff --git a/components/mqtt/test/CMakeLists.txt b/components/mqtt/test/CMakeLists.txt index 867c584485..bbe7825e7f 100644 --- a/components/mqtt/test/CMakeLists.txt +++ b/components/mqtt/test/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRC_DIRS "." - PRIV_REQUIRES unity test_utils mqtt nvs_flash app_update) \ No newline at end of file + PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update) \ No newline at end of file diff --git a/components/newlib/test/CMakeLists.txt b/components/newlib/test/CMakeLists.txt index c117151814..ed052cc07f 100644 --- a/components/newlib/test/CMakeLists.txt +++ b/components/newlib/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils) \ No newline at end of file + PRIV_REQUIRES cmock test_utils) diff --git a/components/nvs_flash/test/CMakeLists.txt b/components/nvs_flash/test/CMakeLists.txt index 3c35870c69..a354cf59cf 100644 --- a/components/nvs_flash/test/CMakeLists.txt +++ b/components/nvs_flash/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils nvs_flash bootloader_support) + PRIV_REQUIRES cmock test_utils nvs_flash bootloader_support) diff --git a/components/openssl/test/CMakeLists.txt b/components/openssl/test/CMakeLists.txt index 28167230df..0fb5bac2c2 100644 --- a/components/openssl/test/CMakeLists.txt +++ b/components/openssl/test/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRC_DIRS "." - PRIV_REQUIRES unity test_utils openssl) \ No newline at end of file + PRIV_REQUIRES cmock test_utils openssl) diff --git a/components/partition_table/test/CMakeLists.txt b/components/partition_table/test/CMakeLists.txt index c117151814..0c4909aa2f 100644 --- a/components/partition_table/test/CMakeLists.txt +++ b/components/partition_table/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils) \ No newline at end of file + PRIV_REQUIRES cmock test_utils) \ No newline at end of file diff --git a/components/perfmon/test/CMakeLists.txt b/components/perfmon/test/CMakeLists.txt index 9e6fa3868b..83721e048b 100644 --- a/components/perfmon/test/CMakeLists.txt +++ b/components/perfmon/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity xtensa perfmon) + PRIV_REQUIRES cmock xtensa perfmon) diff --git a/components/protocomm/test/CMakeLists.txt b/components/protocomm/test/CMakeLists.txt index 48ba9e1367..56659e8270 100644 --- a/components/protocomm/test/CMakeLists.txt +++ b/components/protocomm/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." PRIV_INCLUDE_DIRS "../proto-c/" - PRIV_REQUIRES unity mbedtls protocomm protobuf-c) \ No newline at end of file + PRIV_REQUIRES cmock mbedtls protocomm protobuf-c) diff --git a/components/pthread/test/CMakeLists.txt b/components/pthread/test/CMakeLists.txt index 652f74eb7c..d4abe5f0e9 100644 --- a/components/pthread/test/CMakeLists.txt +++ b/components/pthread/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils pthread) \ No newline at end of file + PRIV_REQUIRES cmock test_utils pthread) diff --git a/components/sdmmc/test/CMakeLists.txt b/components/sdmmc/test/CMakeLists.txt index 6c7d0e1a63..fc3f74d54b 100644 --- a/components/sdmmc/test/CMakeLists.txt +++ b/components/sdmmc/test/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity sdmmc + PRIV_REQUIRES cmock sdmmc ) \ No newline at end of file diff --git a/components/soc/test/CMakeLists.txt b/components/soc/test/CMakeLists.txt index 096f006af6..52491e925a 100644 --- a/components/soc/test/CMakeLists.txt +++ b/components/soc/test/CMakeLists.txt @@ -2,4 +2,4 @@ idf_build_get_property(soc_name IDF_TARGET) idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "${include_dirs}" - PRIV_REQUIRES unity test_utils) + PRIV_REQUIRES cmock test_utils) diff --git a/components/spi_flash/test/CMakeLists.txt b/components/spi_flash/test/CMakeLists.txt index 820b701b6e..17b9e7d719 100644 --- a/components/spi_flash/test/CMakeLists.txt +++ b/components/spi_flash/test/CMakeLists.txt @@ -5,5 +5,5 @@ endif() idf_component_register(SRC_DIRS "." EXCLUDE_SRCS "${exclude_srcs}" PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils spi_flash bootloader_support app_update) + PRIV_REQUIRES cmock test_utils spi_flash bootloader_support app_update) diff --git a/components/spiffs/test/CMakeLists.txt b/components/spiffs/test/CMakeLists.txt index 3c486593d0..ce42e7f4d3 100644 --- a/components/spiffs/test/CMakeLists.txt +++ b/components/spiffs/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils spiffs) \ No newline at end of file + PRIV_REQUIRES cmock test_utils spiffs) \ No newline at end of file diff --git a/components/tcp_transport/test/CMakeLists.txt b/components/tcp_transport/test/CMakeLists.txt index 89846a7538..fa39f1cb9f 100644 --- a/components/tcp_transport/test/CMakeLists.txt +++ b/components/tcp_transport/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "../private_include" "." - PRIV_REQUIRES unity test_utils tcp_transport) \ No newline at end of file + PRIV_REQUIRES cmock test_utils tcp_transport) diff --git a/components/ulp/test/CMakeLists.txt b/components/ulp/test/CMakeLists.txt index fb9240a0a1..b71796927d 100644 --- a/components/ulp/test/CMakeLists.txt +++ b/components/ulp/test/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(SRC_DIRS ${IDF_TARGET} PRIV_INCLUDE_DIRS . -PRIV_REQUIRES unity ulp soc esp_common) +PRIV_REQUIRES cmock ulp soc esp_common) if(IDF_TARGET STREQUAL "esp32") set(ulp_sources "ulp/test_jumps_esp32.S") diff --git a/components/vfs/test/CMakeLists.txt b/components/vfs/test/CMakeLists.txt index 331489b315..ef84a7ff17 100644 --- a/components/vfs/test/CMakeLists.txt +++ b/components/vfs/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS . - PRIV_REQUIRES unity test_utils vfs fatfs spiffs) + PRIV_REQUIRES cmock test_utils vfs fatfs spiffs) diff --git a/components/wear_levelling/test/CMakeLists.txt b/components/wear_levelling/test/CMakeLists.txt index 3d32791af8..cf9bdf4bf3 100644 --- a/components/wear_levelling/test/CMakeLists.txt +++ b/components/wear_levelling/test/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register(SRC_DIRS . PRIV_INCLUDE_DIRS . - PRIV_REQUIRES unity test_utils wear_levelling + PRIV_REQUIRES cmock test_utils wear_levelling EMBED_FILES test_partition_v1.bin ) \ No newline at end of file diff --git a/components/wpa_supplicant/test/CMakeLists.txt b/components/wpa_supplicant/test/CMakeLists.txt index e81bec18b7..39d34fdae5 100644 --- a/components/wpa_supplicant/test/CMakeLists.txt +++ b/components/wpa_supplicant/test/CMakeLists.txt @@ -1,7 +1,7 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." "${CMAKE_CURRENT_BINARY_DIR}" PRIV_INCLUDE_DIRS "../src" - PRIV_REQUIRES unity esp_common test_utils wpa_supplicant mbedtls) + PRIV_REQUIRES cmock esp_common test_utils wpa_supplicant mbedtls) idf_component_get_property(esp_supplicant_dir wpa_supplicant COMPONENT_DIR) diff --git a/docs/en/api-guides/unit-tests.rst b/docs/en/api-guides/unit-tests.rst index f6014907b8..fdcc782fdf 100644 --- a/docs/en/api-guides/unit-tests.rst +++ b/docs/en/api-guides/unit-tests.rst @@ -304,5 +304,26 @@ of time spent on waiting for code/data in case of a cache miss, then subtract th One limitation of the cache compensated timer is that the task that benchmarked functions should be pinned to a core. This is due to each core having its own event counters that are independent of each other. For example, if ``ccomp_timer_start`` gets called on one core, put to sleep by the scheduler, wakes up, and gets rescheduled on the other core, then the corresponding ``ccomp_timer_stop`` will be invalid. -invalid. +Mocks +----------------------------------------- + +ESP-IDF has a component which integrates the CMock mocking framework. +CMock usually uses Unity as a submodule, but due to some Espressif-internal limitations with CI, we still have Unity as an ordinary module in ESP-IDF. +To use the IDF-supplied Unity component which isn't a submodule, the build system needs to pass an environment variable ``UNITY_IDR`` to CMock. +This variable simply contains the path to the Unity directory in IDF, e.g. ``export "UNITY_DIR=${IDF_PATH}/components/unity/unity"``. +Refer to :component_file:`cmock/CMock/lib/cmock_generator.rb` to see how the Unity directory is determined in CMock. + +An example cmake build command to create mocks of a component inside that component's CMakeLists.txt may look like this: + + .. code-block:: cmake + + add_custom_command( + OUTPUT ${MOCK_OUTPUT} + COMMAND ruby ${CMOCK_DIR}/lib/cmock.rb -o${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_config.yaml ${MOCK_HEADERS} + COMMAND ${CMAKE_COMMAND} -E env "UNITY_DIR=${IDF_PATH}/components/unity/unity" ruby ${CMOCK_DIR}/lib/cmock.rb -o${CMAKE_CURRENT_SOURCE_DIR}/mock/mock_config.yaml ${MOCK_HEADERS} + ) + +${MOCK_OUTPUT} contains all CMock generated output files, ${MOCK_HEADERS} contains all headers to be mocked and ${CMOCK_DIR} needs to be set to CMock directory inside IDF. ${CMAKE_COMMAND} is automatically set. + +Refer to :component_file:`cmock/CMock/docs/CMock_Summary.md` for more details on how CMock works and how to create and use mocks. diff --git a/examples/cxx/experimental/experimental_cpp_component/test/CMakeLists.txt b/examples/cxx/experimental/experimental_cpp_component/test/CMakeLists.txt index fcac48d9b9..78b0f5cd52 100644 --- a/examples/cxx/experimental/experimental_cpp_component/test/CMakeLists.txt +++ b/examples/cxx/experimental/experimental_cpp_component/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS . - PRIV_REQUIRES unity test_utils experimental_cpp_component) + PRIV_REQUIRES cmock test_utils experimental_cpp_component) diff --git a/examples/system/unit_test/components/testable/test/CMakeLists.txt b/examples/system/unit_test/components/testable/test/CMakeLists.txt index 33dded71ae..f5b82bc143 100644 --- a/examples/system/unit_test/components/testable/test/CMakeLists.txt +++ b/examples/system/unit_test/components/testable/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." INCLUDE_DIRS "." - REQUIRES unity testable) \ No newline at end of file + REQUIRES cmock testable) diff --git a/tools/ci/check_public_headers_exceptions.txt b/tools/ci/check_public_headers_exceptions.txt index 9f0fe97b10..4b135b1f01 100644 --- a/tools/ci/check_public_headers_exceptions.txt +++ b/tools/ci/check_public_headers_exceptions.txt @@ -85,6 +85,9 @@ components/unity/unity/src/unity_internals.h components/unity/include/unity_config.h components/unity/include/unity_test_runner.h +components/cmock/CMock/src/cmock.h +components/cmock/CMock/src/cmock_internals.h + ### Here are the files that do not compile for some reason # components/app_trace/include/esp_sysview_trace.h diff --git a/tools/gen_esp_err_to_name.py b/tools/gen_esp_err_to_name.py index 9a56be1509..0e23ab3c0d 100755 --- a/tools/gen_esp_err_to_name.py +++ b/tools/gen_esp_err_to_name.py @@ -45,7 +45,7 @@ ignore_files = ['components/mdns/test_afl_fuzz_host/esp32_compat.h', # us ] # add directories here which should not be parsed -ignore_dirs = ('examples') +ignore_dirs = ('examples', 'components/cmock/CMock/test') # macros from here have higher priorities in case of collisions priority_headers = ['components/esp_common/include/esp_err.h'] diff --git a/tools/unit-test-app/components/test_utils/CMakeLists.txt b/tools/unit-test-app/components/test_utils/CMakeLists.txt index 5e7583e5d3..1673d7e1b5 100644 --- a/tools/unit-test-app/components/test_utils/CMakeLists.txt +++ b/tools/unit-test-app/components/test_utils/CMakeLists.txt @@ -5,7 +5,7 @@ idf_component_register(SRCS "ccomp_timer.c" "ccomp_timer_impl.c" INCLUDE_DIRS include PRIV_INCLUDE_DIRS private_include - REQUIRES spi_flash idf_test unity + REQUIRES spi_flash idf_test cmock PRIV_REQUIRES perfmon esp_ipc) diff --git a/tools/unit-test-app/components/test_utils/test/CMakeLists.txt b/tools/unit-test-app/components/test_utils/test/CMakeLists.txt index 46f813b166..1887cad527 100644 --- a/tools/unit-test-app/components/test_utils/test/CMakeLists.txt +++ b/tools/unit-test-app/components/test_utils/test/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES unity test_utils perfmon esp_ipc) + PRIV_REQUIRES cmock test_utils perfmon esp_ipc)