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