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