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