Files
Abtin Keshavarzian 86b8bf6de4 [nexus] add support for CLI testing (#13110)
This commit adds support for interacting with nodes via the CLI in the
Nexus simulation framework. This enables writing higher-level
integration tests that verify stack behavior and state through
standard CLI commands.

Key changes:
- Integrated `Cli::Interpreter` into the `Nexus::Node` class.
- Added `Node::InputCli()` to allow sending commands to a node with
  `printf`-style formatting.
- Implemented output capturing logic in `Node::HandleCliOutput()` to
  buffer and parse CLI responses into individual lines, stored in a
  `CliOutputArray`.
- Added helper methods to `CliOutputLine` for matching and validating
  the captured output.
- Added a new `cli_basic` Nexus test to demonstrate and validate the
  CLI interaction functionality.
2026-05-18 13:03:46 -07:00

95 lines
3.2 KiB
CMake

#
# Copyright (c) 2025, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
set(COMMON_INCLUDES
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/core
${PROJECT_SOURCE_DIR}/tests/nexus
${PROJECT_SOURCE_DIR}/tests/nexus/platform
${PROJECT_SOURCE_DIR}/examples/platforms/utils
)
set(COMMON_COMPILE_OPTIONS
-DOPENTHREAD_FTD=1
-DOPENTHREAD_MTD=0
-DOPENTHREAD_RADIO=0
-DOPENTHREAD_CONFIG_USE_STD_NEW=1
)
set(COMMON_LIBS
openthread-cli-ftd
openthread-ftd
ot-nexus-platform
${OT_MBEDTLS}
$ENV{LIB_FUZZING_ENGINE}
ot-config
openthread-cli-ftd
)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_RADIO_LINK_TREL_ENABLE=1")
#----------------------------------------------------------------------------------------------------------------------
macro(ot_nexus_test name)
# Macro to add an OpenThread nexus test.
#
# Nexus test name will be `{name}-fuzzer`. Test source file of
# `fuzz_{name}.cpp` is used. Optional extra arguments can be
# passed to provide additional source files.
add_executable(${name}-fuzzer
fuzz_${name}.cpp ${ARGN}
)
target_include_directories(${name}-fuzzer
PRIVATE
${COMMON_INCLUDES}
)
target_link_libraries(${name}-fuzzer
PRIVATE
${COMMON_LIBS}
)
target_compile_options(${name}-fuzzer
PRIVATE
${COMMON_COMPILE_OPTIONS}
)
endmacro()
#----------------------------------------------------------------------------------------------------------------------
ot_nexus_test(cli)
ot_nexus_test(icmp6)
ot_nexus_test(ip6)
ot_nexus_test(mdns)
ot_nexus_test(radio-one-node)
ot_nexus_test(trel)