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