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_UDP_IPv4" ) 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_ARP.h" 18 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DHCP.h" 19 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DNS.h" 20 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Utils.h" 21 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Routing.h" 22 "${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkBufferManagement.h" 23 "${MODULE_ROOT_DIR}/test/unit-test/${project_name}/FreeRTOS_UDP_IPv4_list_macros.h" 24 ) 25 26set(mock_include_list "") 27# list the directories your mocks need 28list(APPEND mock_include_list 29 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 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 ) 36 37set(mock_define_list "") 38#list the definitions of your mocks to control what to be included 39list(APPEND mock_define_list 40 "" 41 ) 42 43# ================= Create the library under test here (edit) ================== 44 45set(real_source_files "") 46 47# list the files you would like to test here 48list(APPEND real_source_files 49 ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/${project_name}.c 50 ) 51 52set(real_include_directories "") 53# list the directories the module under test includes 54list(APPEND real_include_directories 55 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 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 ) 63 64# ===================== Create UnitTest Code here (edit) ===================== 65#set(test_include_directories "") 66# list the directories your test needs to include 67list(APPEND test_include_directories 68 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 69 . 70 ${CMOCK_DIR}/vendor/unity/src 71 ${TCP_INCLUDE_DIRS} 72 ) 73 74# ============================= (end edit) =================================== 75 76set(mock_name "${project_name}_mock") 77set(real_name "${project_name}_real") 78 79create_mock_list(${mock_name} 80 "${mock_list}" 81 "${MODULE_ROOT_DIR}/test/unit-test/cmock/project.yml" 82 "${mock_include_list}" 83 "${mock_define_list}" 84 ) 85 86create_real_library(${real_name} 87 "${real_source_files}" 88 "${real_include_directories}" 89 "${mock_name}" 90 ) 91 92set( utest_link_list "" ) 93list(APPEND utest_link_list 94 -l${mock_name} 95 lib${real_name}.a 96 ) 97 98list(APPEND utest_dep_list 99 ${real_name} 100 ) 101 102set(utest_name "${project_name}_utest") 103set(utest_source "${project_name}/${project_name}_utest.c") 104 105create_test(${utest_name} 106 ${utest_source} 107 "${utest_link_list}" 108 "${utest_dep_list}" 109 "${test_include_directories}" 110 ) 111