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