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