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