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