From 985334219458c57b569fdbafcfc6b0d117cc48cf Mon Sep 17 00:00:00 2001 From: Daniel Béreš Date: Thu, 19 Jan 2023 10:19:27 +0100 Subject: libmemif: added tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch provides unit tests for libmemif written in Unity Type: test Signed-off-by: Daniel Béreš Signed-off-by: Mohsin Kazmi Change-Id: I19116def6e6d28efd5f460c93911245474a11321 --- extras/libmemif/CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'extras/libmemif/CMakeLists.txt') diff --git a/extras/libmemif/CMakeLists.txt b/extras/libmemif/CMakeLists.txt index b6b658c2d85..8f057e98f3a 100644 --- a/extras/libmemif/CMakeLists.txt +++ b/extras/libmemif/CMakeLists.txt @@ -18,6 +18,35 @@ set(CMAKE_C_STANDARD 11) include(CheckCCompilerFlag) include(CheckFunctionExists) +find_package(Git REQUIRED) + +include(ExternalProject) +set(UNITY unity_project) + +ExternalProject_Add( + unity_project + GIT_REPOSITORY https://github.com/ThrowTheSwitch/Unity.git + GIT_TAG cf949f45ca6d172a177b00da21310607b97bc7a7 + PREFIX ${PROJECT_BINARY_DIR}/external/${UNITY} + INSTALL_COMMAND cmake --install . --prefix ${PROJECT_BINARY_DIR} + +) +set_source_files_properties( + ${PROJECT_BINARY_DIR}/external/${UNITY}/src/${UNITY}/src/unity.c + ${PROJECT_BINARY_DIR}/external/${UNITY}/src/${UNITY}/extras/fixture/src/unity_fixture.c + ${PROJECT_BINARY_DIR}/external/${UNITY}/src/${UNITY}/extras/memory/src/unity_memory.c + PROPERTIES GENERATED TRUE) +add_library(unity STATIC + ${PROJECT_BINARY_DIR}/external/${UNITY}/src/${UNITY}/src/unity.c + ${PROJECT_BINARY_DIR}/external/${UNITY}/src/${UNITY}/extras/fixture/src/unity_fixture.c + ${PROJECT_BINARY_DIR}/external/${UNITY}/src/${UNITY}/extras/memory/src/unity_memory.c +) +target_include_directories(unity PUBLIC + ${PROJECT_BINARY_DIR}/external/${UNITY}/src/${UNITY}/src/ + ${PROJECT_BINARY_DIR}/external/${UNITY}/src/${UNITY}/extras/fixture/src/ + ${PROJECT_BINARY_DIR}/external/${UNITY}/src/${UNITY}/extras/memory/src/ +) +add_dependencies(unity unity_project) if (NOT CMAKE_BUILD_TYPE) message(STATUS "No build type selected, default to Release") @@ -42,6 +71,9 @@ include_directories(src) add_subdirectory(src) add_subdirectory(examples) +enable_testing() +include(CTest) +add_subdirectory(test) ############################################################################## # Packaging ############################################################################## -- cgit 1.2.3-korg