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