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_IPv6" ) 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/NetworkBufferManagement.h" 18 "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IPv6_Utils.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/ConfigFiles 29 ${MODULE_ROOT_DIR}/test/unit-test/${project_name} 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/${project_name}.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/unit-test/${project_name} 67 ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources 68 ) 69 70# ============================= (end edit) =================================== 71 72set(mock_name "${project_name}_mock") 73set(real_name "${project_name}_real") 74 75create_mock_list(${mock_name} 76 "${mock_list}" 77 "${MODULE_ROOT_DIR}/test/unit-test/cmock/project.yml" 78 "${mock_include_list}" 79 "${mock_define_list}" 80 ) 81 82create_real_library(${real_name} 83 "${real_source_files}" 84 "${real_include_directories}" 85 "${mock_name}" 86 ) 87 88set( utest_link_list "" ) 89list(APPEND utest_link_list 90 -l${mock_name} 91 lib${real_name}.a 92 ) 93 94list(APPEND utest_dep_list 95 ${real_name} 96 ) 97 98set(utest_name "${project_name}_utest") 99set(utest_source "${project_name}/${project_name}_utest.c") 100 101create_test(${utest_name} 102 ${utest_source} 103 "${utest_link_list}" 104 "${utest_dep_list}" 105 "${test_include_directories}" 106 ) 107