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