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