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_Utils_DiffConfig" ) 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_Timers.h" 18 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP.h" 19 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h" 20 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ICMP.h" 21 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DNS.h" 22 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Sockets.h" 23 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DHCP.h" 24 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Stream_Buffer.h" 25 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_TCP_WIN.h" 26 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_TCP_IP.h" 27 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_UDP_IP.h" 28 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h" 29 "${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkBufferManagement.h" 30 "${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkInterface.h" 31 "${MODULE_ROOT_DIR}/test/unit-test/${project_name}/IP_Utils_DiffConfig_list_macros.h" 32 ) 33 34set(mock_include_list "") 35# list the directories your mocks need 36list(APPEND mock_include_list 37 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 38 . 39 ${TCP_INCLUDE_DIRS} 40 ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include 41 ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix 42 ${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles 43 ) 44 45set(mock_define_list "") 46#list the definitions of your mocks to control what to be included 47list(APPEND mock_define_list 48 "" 49 ) 50 51# ================= Create the library under test here (edit) ================== 52 53set(real_source_files "") 54 55# list the files you would like to test here 56list(APPEND real_source_files 57 ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/FreeRTOS_IP_Utils.c 58 ${MODULE_ROOT_DIR}/test/unit-test/${project_name}/${project_name}_stubs.c 59 ) 60 61set(real_include_directories "") 62# list the directories the module under test includes 63list(APPEND real_include_directories 64 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 65 . 66 ${TCP_INCLUDE_DIRS} 67 ${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles 68 ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include 69 ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix 70 ${CMOCK_DIR}/vendor/unity/src 71 ) 72 73# ===================== Create UnitTest Code here (edit) ===================== 74set(test_include_directories "") 75# list the directories your test needs to include 76list(APPEND test_include_directories 77 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 78 . 79 ${CMOCK_DIR}/vendor/unity/src 80 ${TCP_INCLUDE_DIRS} 81 ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources 82 ) 83 84# ============================= (end edit) =================================== 85 86set(mock_name "${project_name}_mock") 87set(real_name "${project_name}_real") 88 89create_mock_list(${mock_name} 90 "${mock_list}" 91 "${MODULE_ROOT_DIR}/test/unit-test/cmock/project.yml" 92 "${mock_include_list}" 93 "${mock_define_list}" 94 ) 95 96create_real_library(${real_name} 97 "${real_source_files}" 98 "${real_include_directories}" 99 "${mock_name}" 100 ) 101 102set( utest_link_list "" ) 103list(APPEND utest_link_list 104 -l${mock_name} 105 lib${real_name}.a 106 ) 107 108set( utest_dep_list "" ) 109list(APPEND utest_dep_list 110 ${real_name} 111 ) 112 113set(utest_name "${project_name}_utest") 114set(utest_source "${project_name}/${project_name}_utest.c") 115 116create_test(${utest_name} 117 ${utest_source} 118 "${utest_link_list}" 119 "${utest_dep_list}" 120 "${test_include_directories}" 121 ) 122