xref: /FreeRTOS-Plus-TCP-v3.1.0/test/unit-test/FreeRTOS_TCP_WIN/ut.cmake (revision a4124602cc584fa0658448c229f48a459a84fbb1)
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_TCP_WIN" )
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/list.h"
13            "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/task.h"
14            "${MODULE_ROOT_DIR}/test/unit-test/${project_name}/FreeRTOS_TCP_WIN_list_macros.h"
15            "${CMAKE_BINARY_DIR}/Annexed_TCP/portable.h"
16            "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP.h"
17        )
18# list the directories your mocks need
19set(mock_include_list "")
20list(APPEND mock_include_list
21            .
22            ${TCP_INCLUDE_DIRS}
23            ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include
24            ${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles
25        )
26
27#list the definitions of your mocks to control what to be included
28set(mock_define_list "")
29list(APPEND mock_define_list
30        ""
31        )
32
33# ================= Create the library under test here (edit) ==================
34
35add_compile_options(-Wno-pedantic -Wno-div-by-zero -O0 -ggdb3)
36# list the files you would like to test here
37set(real_source_files "")
38list(APPEND real_source_files
39            ${project_name}/FreeRTOS_TCP_WIN_stubs.c
40            ${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/FreeRTOS_TCP_WIN.c
41	)
42# list the directories the module under test includes
43set(real_include_directories "")
44list(APPEND real_include_directories
45            .
46            ${TCP_INCLUDE_DIRS}
47            ${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles
48            ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include
49            ${CMOCK_DIR}/vendor/unity/src
50	)
51
52# =====================  Create UnitTest Code here (edit)  =====================
53
54# list the directories your test needs to include
55set(test_include_directories "")
56list(APPEND test_include_directories
57            .
58            ${CMOCK_DIR}/vendor/unity/src
59            ${TCP_INCLUDE_DIRS}
60            ${MODULE_ROOT_DIR}/test/unit-test/${project_name}
61        )
62# =============================  (end edit)  ===================================
63
64set(mock_name "${project_name}_mock")
65set(real_name "${project_name}_real")
66
67create_mock_list(${mock_name}
68                "${mock_list}"
69                "${MODULE_ROOT_DIR}/test/unit-test/cmock/project.yml"
70                "${mock_include_list}"
71                "${mock_define_list}"
72        )
73
74create_real_library(${real_name}
75                    "${real_source_files}"
76                    "${real_include_directories}"
77                    "${mock_name}"
78        )
79
80set (utest_link_list "")
81list(APPEND utest_link_list
82            -l${mock_name}
83            lib${real_name}.a
84        )
85
86set (utest_dep_list "")
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
101target_compile_options(${real_name} PUBLIC
102            -include ${MODULE_ROOT_DIR}/test/unit-test/${project_name}/FreeRTOS_TCP_WIN_list_macros.h
103        )
104