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