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