Skip to content

Commit 6d40977

Browse files
authored
[fuzz] migrate fuzz framework to nexus platform (openthread#11538)
1 parent 1798f3b commit 6d40977

13 files changed

Lines changed: 177 additions & 1272 deletions

tests/fuzz/CMakeLists.txt

Lines changed: 23 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2021, The OpenThread Authors.
2+
# Copyright (c) 2025, The OpenThread Authors.
33
# All rights reserved.
44
#
55
# Redistribution and use in source and binary forms, with or without
@@ -28,105 +28,55 @@
2828

2929
set(COMMON_INCLUDES
3030
${PROJECT_SOURCE_DIR}/include
31+
${PROJECT_SOURCE_DIR}/src
3132
${PROJECT_SOURCE_DIR}/src/core
33+
${PROJECT_SOURCE_DIR}/tests/nexus
3234
)
3335

3436
set(COMMON_COMPILE_OPTIONS
3537
-DOPENTHREAD_FTD=1
3638
-DOPENTHREAD_MTD=0
3739
-DOPENTHREAD_RADIO=0
38-
-DOPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE=1
39-
)
40-
41-
set(COMMON_SOURCES
42-
fuzzer_platform.cpp
4340
)
4441

4542
set(COMMON_LIBS
4643
openthread-ftd
44+
ot-nexus-platform
4745
${OT_MBEDTLS}
4846
$ENV{LIB_FUZZING_ENGINE}
4947
ot-config
5048
)
5149

52-
add_executable(ot-cli-received-fuzzer
53-
cli_received.cpp
54-
${COMMON_SOURCES}
55-
)
56-
57-
target_compile_options(ot-cli-received-fuzzer
58-
PRIVATE
59-
${COMMON_COMPILE_OPTIONS}
60-
)
61-
62-
target_include_directories(ot-cli-received-fuzzer
63-
PRIVATE
64-
${COMMON_INCLUDES}
65-
)
50+
#----------------------------------------------------------------------------------------------------------------------
6651

67-
target_link_libraries(ot-cli-received-fuzzer
68-
PRIVATE
69-
openthread-cli-ftd
70-
${COMMON_LIBS}
71-
)
52+
macro(ot_nexus_test name)
7253

73-
add_executable(ot-ip6-send-fuzzer
74-
ip6_send.cpp
75-
${COMMON_SOURCES}
76-
)
54+
# Macro to add an OpenThread nexus test.
55+
#
56+
# Nexus test name will be `nexus_{name}`. Test source file of
57+
# `test_{name}.cpp` is used. Optional extra arguments can be
58+
# passed to provide additional source files.
7759

78-
target_compile_options(ot-ip6-send-fuzzer
79-
PRIVATE
80-
${COMMON_COMPILE_OPTIONS}
81-
)
60+
add_executable(${name}-fuzzer
61+
${name}.cpp ${ARGN}
62+
)
8263

83-
target_include_directories(ot-ip6-send-fuzzer
64+
target_include_directories(${name}-fuzzer
8465
PRIVATE
8566
${COMMON_INCLUDES}
86-
)
67+
)
8768

88-
target_link_libraries(ot-ip6-send-fuzzer
69+
target_link_libraries(${name}-fuzzer
8970
PRIVATE
9071
${COMMON_LIBS}
91-
)
92-
93-
add_executable(ot-radio-receive-done-fuzzer
94-
radio_receive_done.cpp
95-
${COMMON_SOURCES}
96-
)
72+
)
9773

98-
target_compile_options(ot-radio-receive-done-fuzzer
74+
target_compile_options(${name}-fuzzer
9975
PRIVATE
10076
${COMMON_COMPILE_OPTIONS}
101-
)
77+
)
78+
endmacro()
10279

103-
target_include_directories(ot-radio-receive-done-fuzzer
104-
PRIVATE
105-
${COMMON_INCLUDES}
106-
)
80+
#----------------------------------------------------------------------------------------------------------------------
10781

108-
target_link_libraries(ot-radio-receive-done-fuzzer
109-
PRIVATE
110-
${COMMON_LIBS}
111-
)
112-
113-
add_executable(ot-ncp-hdlc-received-fuzzer
114-
ncp_hdlc_received.cpp
115-
${COMMON_SOURCES}
116-
)
117-
118-
target_compile_options(ot-ncp-hdlc-received-fuzzer
119-
PRIVATE
120-
${COMMON_COMPILE_OPTIONS}
121-
)
122-
123-
target_include_directories(ot-ncp-hdlc-received-fuzzer
124-
PRIVATE
125-
${COMMON_INCLUDES}
126-
)
127-
128-
target_link_libraries(ot-ncp-hdlc-received-fuzzer
129-
PRIVATE
130-
openthread-ncp-ftd
131-
${COMMON_LIBS}
132-
)
82+
ot_nexus_test(radio-one-node)

tests/fuzz/cli_received.cpp

Lines changed: 0 additions & 114 deletions
This file was deleted.
-63 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)