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_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_IP.h" 18 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h" 19 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IPv6.h" 20 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Routing.h" 21 "${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkBufferManagement.h" 22 "${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkInterface.h" 23 "${MODULE_ROOT_DIR}/test/unit-test/${project_name}/IPv4_list_macros.h" 24 ) 25 26set(mock_include_list "") 27# list the directories your mocks need 28list(APPEND mock_include_list 29 . 30 ${TCP_INCLUDE_DIRS} 31 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 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 . 56 ${TCP_INCLUDE_DIRS} 57 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 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) ===================== 65set(test_include_directories "") 66# list the directories your test needs to include 67list(APPEND test_include_directories 68 . 69 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 70 ${CMOCK_DIR}/vendor/unity/src 71 ${TCP_INCLUDE_DIRS} 72 ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources 73 ) 74 75# ============================= (end edit) =================================== 76 77set(mock_name "${project_name}_mock") 78set(real_name "${project_name}_real") 79 80create_mock_list(${mock_name} 81 "${mock_list}" 82 "${MODULE_ROOT_DIR}/test/unit-test/cmock/project.yml" 83 "${mock_include_list}" 84 "${mock_define_list}" 85 ) 86 87create_real_library(${real_name} 88 "${real_source_files}" 89 "${real_include_directories}" 90 "${mock_name}" 91 ) 92 93set( utest_link_list "" ) 94list(APPEND utest_link_list 95 -l${mock_name} 96 lib${real_name}.a 97 ) 98 99list(APPEND utest_dep_list 100 ${real_name} 101 ) 102 103set(utest_name "${project_name}_utest") 104set(utest_source "${project_name}/${project_name}_utest.c") 105 106create_test(${utest_name} 107 ${utest_source} 108 "${utest_link_list}" 109 "${utest_dep_list}" 110 "${test_include_directories}" 111 ) 112