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