xref: /FreeRTOS-Plus-TCP-v3.1.0/test/unit-test/FreeRTOS_DHCP/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_DHCP" )
6message( STATUS "${project_name}" )
7# =====================  Create your mock here  (edit)  ========================
8
9set(mock_list "")
10# list the files to mock here
11list(APPEND mock_list
12            "${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/task.h"
13            "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP.h"
14            "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Sockets.h"
15            "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_UDP_IP.h"
16            "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h"
17            "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h"
18            "${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Timers.h"
19            "${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkBufferManagement.h"
20            "${MODULE_ROOT_DIR}/test/unit-test/${project_name}/FreeRTOS_DHCP_mock.h"
21        )
22# list the directories your mocks need
23list(APPEND mock_include_list
24            .
25            ${TCP_INCLUDE_DIRS}
26            ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include
27            ${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles
28        )
29
30#list the definitions of your mocks to control what to be included
31list(APPEND mock_define_list
32            ""
33       )
34
35# ================= Create the library under test here (edit) ==================
36
37# list the files you would like to test here
38list(APPEND real_source_files
39            ${MODULE_ROOT_DIR}/source/FreeRTOS_DHCP.c
40	)
41# list the directories the module under test includes
42list(APPEND real_include_directories
43            .
44            ${TCP_INCLUDE_DIRS}
45            ${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles
46            ${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include
47            ${CMOCK_DIR}/vendor/unity/src
48	)
49
50# =====================  Create UnitTest Code here (edit)  =====================
51
52# list the directories your test needs to include
53list(APPEND test_include_directories
54            .
55            ${CMOCK_DIR}/vendor/unity/src
56            ${TCP_INCLUDE_DIRS}
57            ${MODULE_ROOT_DIR}/test/unit-test/${project_name}
58        )
59
60# =============================  (end edit)  ===================================
61
62set(mock_name "${project_name}_mock")
63set(real_name "${project_name}_real")
64
65create_mock_list(${mock_name}
66                "${mock_list}"
67                "${MODULE_ROOT_DIR}/test/unit-test/cmock/project.yml"
68                "${mock_include_list}"
69                "${mock_define_list}"
70        )
71
72create_real_library(${real_name}
73                    "${real_source_files}"
74                    "${real_include_directories}"
75                    "${mock_name}"
76        )
77
78list(APPEND utest_link_list
79            -l${mock_name}
80            lib${real_name}.a
81        )
82
83list(APPEND utest_dep_list
84            ${real_name}
85        )
86
87set(utest_name "${project_name}_utest")
88set(utest_source "${project_name}/${project_name}_utest.c")
89
90create_test(${utest_name}
91            ${utest_source}
92            "${utest_link_list}"
93            "${utest_dep_list}"
94            "${test_include_directories}"
95        )
96