1# Include filepaths for source and include. 2include( ${MODULE_ROOT_DIR}/test/unit-test/TCPFilePaths.cmake ) 3 4# ==================== Define your project name (edit) ======================== 5set( project_name "FreeRTOS_IP_Timers" ) 6message( STATUS "${project_name}" ) 7 8# ===================== Create your mock here (edit) ======================== 9set(mock_list "") 10 11# list the files to mock here 12list(APPEND mock_list 13 "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/task.h" 14 "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/list.h" 15 "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/queue.h" 16 "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/event_groups.h" 17 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h" 18 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Utils.h" 19 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_TCP_IP.h" 20 "${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkBufferManagement.h" 21 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Sockets.h" 22 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DNS_Callback.h" 23 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ND.h" 24 "${MODULE_ROOT_DIR}/test/unit-test/${project_name}/IP_Timers_list_macros.h" 25 ) 26 27set(mock_include_list "") 28# list the directories your mocks need 29list(APPEND mock_include_list 30 . 31 ${TCP_INCLUDE_DIRS} 32 ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include 33 ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix 34 ${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles 35 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 36 ) 37 38set(mock_define_list "") 39#list the definitions of your mocks to control what to be included 40list(APPEND mock_define_list 41 "" 42 ) 43 44# ================= Create the library under test here (edit) ================== 45 46set(real_source_files "") 47 48# list the files you would like to test here 49list(APPEND real_source_files 50 ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/${project_name}.c 51 ) 52 53set(real_include_directories "") 54# list the directories the module under test includes 55list(APPEND real_include_directories 56 . 57 ${TCP_INCLUDE_DIRS} 58 ${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles 59 ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include 60 ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix 61 ${CMOCK_DIR}/vendor/unity/src 62 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 63 ) 64 65# ===================== Create UnitTest Code here (edit) ===================== 66set(test_include_directories "") 67# list the directories your test needs to include 68list(APPEND test_include_directories 69 . 70 ${CMOCK_DIR}/vendor/unity/src 71 ${TCP_INCLUDE_DIRS} 72 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 73 ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources 74 ) 75 76# ============================= (end edit) =================================== 77 78set(mock_name "${project_name}_mock") 79set(real_name "${project_name}_real") 80 81create_mock_list(${mock_name} 82 "${mock_list}" 83 "${MODULE_ROOT_DIR}/test/unit-test/cmock/project.yml" 84 "${mock_include_list}" 85 "${mock_define_list}" 86 ) 87 88create_real_library(${real_name} 89 "${real_source_files}" 90 "${real_include_directories}" 91 "${mock_name}" 92 ) 93 94set( utest_link_list "" ) 95list(APPEND utest_link_list 96 -l${mock_name} 97 lib${real_name}.a 98 ) 99 100set( utest_dep_list "" ) 101list(APPEND utest_dep_list 102 ${real_name} 103 ) 104 105set(utest_name "${project_name}_utest") 106set(utest_source "${project_name}/${project_name}_utest.c") 107 108create_test(${utest_name} 109 ${utest_source} 110 "${utest_link_list}" 111 "${utest_dep_list}" 112 "${test_include_directories}" 113 ) 114