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