mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/cmock_component' into 'master'
cmock as component replacing unity See merge request espressif/esp-idf!9859
This commit is contained in:
commit
b6467257b9
4
.gitmodules
vendored
4
.gitmodules
vendored
@ -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
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity)
|
||||
PRIV_REQUIRES cmock)
|
||||
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils app_update bootloader_support nvs_flash
|
||||
PRIV_REQUIRES cmock test_utils app_update bootloader_support nvs_flash
|
||||
)
|
@ -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)
|
||||
|
@ -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)
|
||||
PRIV_REQUIRES cmock nvs_flash bt)
|
||||
endif()
|
5
components/cmock/CMakeLists.txt
Normal file
5
components/cmock/CMakeLists.txt
Normal file
@ -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")
|
1
components/cmock/CMock
Submodule
1
components/cmock/CMock
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit eeecc49ce8af123cf8ad40efdb9673e37b56230f
|
1
components/cmock/Makefile.projbuild
Normal file
1
components/cmock/Makefile.projbuild
Normal file
@ -0,0 +1 @@
|
||||
CPPFLAGS += -DUNITY_INCLUDE_CONFIG_H
|
4
components/cmock/component.mk
Normal file
4
components/cmock/component.mk
Normal file
@ -0,0 +1,4 @@
|
||||
#
|
||||
# Component Makefile
|
||||
#
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS .
|
||||
PRIV_INCLUDE_DIRS .
|
||||
PRIV_REQUIRES unity test_utils console)
|
||||
PRIV_REQUIRES cmock test_utils console)
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity)
|
||||
PRIV_REQUIRES cmock)
|
||||
|
@ -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)
|
||||
PRIV_REQUIRES cmock test_utils driver nvs_flash esp_serial_slave_link infrared_tools esp_adc_cal)
|
||||
|
@ -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
|
||||
PRIV_REQUIRES cmock test_utils efuse bootloader_support
|
||||
)
|
@ -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()
|
||||
|
@ -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()
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
idf_component_register(SRC_DIRS .
|
||||
PRIV_REQUIRES unity test_utils spi_flash)
|
||||
PRIV_REQUIRES cmock test_utils spi_flash
|
||||
)
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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)
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES unity test_utils esp_hid)
|
||||
REQUIRES cmock test_utils esp_hid)
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils esp_http_client)
|
||||
PRIV_REQUIRES cmock test_utils esp_http_client)
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils esp_http_server)
|
||||
PRIV_REQUIRES cmock test_utils esp_http_server)
|
@ -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()
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "../private_include" "."
|
||||
PRIV_REQUIRES unity test_utils esp_netif nvs_flash)
|
||||
PRIV_REQUIRES cmock test_utils esp_netif nvs_flash)
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils)
|
||||
PRIV_REQUIRES cmock test_utils)
|
||||
|
@ -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"
|
||||
|
@ -1,6 +1,6 @@
|
||||
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)
|
||||
|
@ -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
|
||||
)
|
||||
|
@ -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()
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity expat)
|
||||
PRIV_REQUIRES cmock expat)
|
||||
|
@ -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
|
||||
)
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRC_DIRS .
|
||||
PRIV_INCLUDE_DIRS .
|
||||
PRIV_REQUIRES unity test_utils esp_ipc
|
||||
PRIV_REQUIRES cmock test_utils esp_ipc
|
||||
)
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils heap)
|
||||
PRIV_REQUIRES cmock test_utils heap)
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils mdns)
|
||||
PRIV_REQUIRES cmock test_utils mdns)
|
@ -1,2 +1,2 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils mqtt nvs_flash app_update)
|
||||
PRIV_REQUIRES cmock test_utils mqtt nvs_flash app_update)
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils)
|
||||
PRIV_REQUIRES cmock test_utils)
|
||||
|
@ -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)
|
||||
|
@ -1,2 +1,2 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils openssl)
|
||||
PRIV_REQUIRES cmock test_utils openssl)
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils)
|
||||
PRIV_REQUIRES cmock test_utils)
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity xtensa perfmon)
|
||||
PRIV_REQUIRES cmock xtensa perfmon)
|
||||
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "../proto-c/"
|
||||
PRIV_REQUIRES unity mbedtls protocomm protobuf-c)
|
||||
PRIV_REQUIRES cmock mbedtls protocomm protobuf-c)
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils pthread)
|
||||
PRIV_REQUIRES cmock test_utils pthread)
|
||||
|
@ -1,4 +1,4 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity sdmmc
|
||||
PRIV_REQUIRES cmock sdmmc
|
||||
)
|
@ -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)
|
||||
|
@ -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)
|
||||
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "."
|
||||
PRIV_REQUIRES unity test_utils spiffs)
|
||||
PRIV_REQUIRES cmock test_utils spiffs)
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
PRIV_INCLUDE_DIRS "../private_include" "."
|
||||
PRIV_REQUIRES unity test_utils tcp_transport)
|
||||
PRIV_REQUIRES cmock test_utils tcp_transport)
|
||||
|
@ -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")
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
)
|
@ -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)
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -1,3 +1,3 @@
|
||||
idf_component_register(SRC_DIRS "."
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES unity testable)
|
||||
REQUIRES cmock testable)
|
||||
|
@ -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
|
||||
|
@ -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']
|
||||
|
@ -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)
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user