1
0
mirror of https://github.com/FreeRTOS/FreeRTOS-Plus-TCP synced 2025-10-23 18:38:33 +08:00
Files
FreeRTOS-Plus-TCP/test/unit-test/FreeRTOS_DHCPv6/ut.cmake
ActoryOu 8c86e2be02 [IPv6] Add Unit Test for FreeRTOS_DHCPv6. (#857)
* Basic DHCPv6 UT framework.

* Add test cases for eGetDHCPv6State

* Add reset test case

* Add test cases for solicit happy path.

* Refine test flow

* Add test cases for advertise.

* Add final timeout & test case on waiting reply.

* Add DHCP address lease unit test case

* Add test case for socket creation failed.

* Disable debug print

* Fix coverage scan

* Add test cases for wrong msg type & transaction ID.

* Add more error handling case.

* Add test cases for prvIsOptionLengthValid

* Rename test case

* Add test case for prvDHCPv6_handleStatusCode

* Add test cases for vDHCPv6ProcessEndPoint_HandleReply

* Add test case for xDHCPv6ProcessEndPoint_HandleAdvertise

* Add test case for xDHCPv6ProcessEndPoint_HandleState

* Refine again.

* Refine again.

* Remove fall back function, not implemented for IPv6.

* Remove unnecessary check

* Add expect state mismatch test.

* Add test cases for create/close sockets.

* Add error handling and UT

* Ignore unknown sub-option.

* Add coverage for prvStateName

* Fix corner case for sub-option.

* Fix spelling & build

* Code beautify and remove unnecessary define

* Remove list_macros.h in DHCPv6 unit test.
2023-05-17 14:33:58 +08:00

117 lines
4.1 KiB
CMake

# Include filepaths for source and include.
include( ${MODULE_ROOT_DIR}/test/unit-test/TCPFilePaths.cmake )
# ==================== Define your project name (edit) ========================
set( project_name "FreeRTOS_DHCPv6" )
message( STATUS "${project_name}" )
# ===================== Create your mock here (edit) ========================
set(mock_list "")
# list the files to mock here
list(APPEND mock_list
"${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/task.h"
"${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/list.h"
"${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/queue.h"
"${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include/event_groups.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_ARP.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_BitConfig.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_DHCP.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IPv6.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Timers.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_IP_Private.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Routing.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/FreeRTOS_Sockets.h"
"${CMAKE_BINARY_DIR}/Annexed_TCP/NetworkBufferManagement.h"
)
set(mock_include_list "")
# list the directories your mocks need
list(APPEND mock_include_list
.
${TCP_INCLUDE_DIRS}
${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include
${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix
${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles
${MODULE_ROOT_DIR}/test/unit-test/${project_name}
)
set(mock_define_list "")
#list the definitions of your mocks to control what to be included
list(APPEND mock_define_list
""
)
# ================= Create the library under test here (edit) ==================
set(real_source_files "")
# list the files you would like to test here
list(APPEND real_source_files
${CMAKE_BINARY_DIR}/Annexed_TCP_Sources/${project_name}.c
${MODULE_ROOT_DIR}/test/unit-test/${project_name}/${project_name}_stubs.c
)
set(real_include_directories "")
# list the directories the module under test includes
list(APPEND real_include_directories
.
${TCP_INCLUDE_DIRS}
${MODULE_ROOT_DIR}/test/unit-test/${project_name}
${MODULE_ROOT_DIR}/test/unit-test/ConfigFiles
${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/include
${MODULE_ROOT_DIR}/test/FreeRTOS-Kernel/portable/ThirdParty/GCC/Posix
${CMOCK_DIR}/vendor/unity/src
)
# ===================== Create UnitTest Code here (edit) =====================
set(test_include_directories "")
# list the directories your test needs to include
list(APPEND test_include_directories
.
${CMOCK_DIR}/vendor/unity/src
${TCP_INCLUDE_DIRS}
${MODULE_ROOT_DIR}/test/unit-test/${project_name}
${CMAKE_BINARY_DIR}/Annexed_TCP_Sources
)
# ============================= (end edit) ===================================
set(mock_name "${project_name}_mock")
set(real_name "${project_name}_real")
create_mock_list(${mock_name}
"${mock_list}"
"${MODULE_ROOT_DIR}/test/unit-test/cmock/project.yml"
"${mock_include_list}"
"${mock_define_list}"
)
create_real_library(${real_name}
"${real_source_files}"
"${real_include_directories}"
"${mock_name}"
)
set( utest_link_list "" )
list(APPEND utest_link_list
-l${mock_name}
lib${real_name}.a
)
set( utest_dep_list "" )
list(APPEND utest_dep_list
${real_name}
)
set(utest_name "${project_name}_utest")
set(utest_source "${project_name}/${project_name}_utest.c")
create_test(${utest_name}
${utest_source}
"${utest_link_list}"
"${utest_dep_list}"
"${test_include_directories}"
)