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