diff --git a/cmake/emu/custom.cmake b/cmake/emu/custom.cmake new file mode 100644 index 00000000000..bd4462206a0 --- /dev/null +++ b/cmake/emu/custom.cmake @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# ${ZEPHYR_BASE}/CMakeLists.txt looks for ${ZEPHYR_BASE}/cmake/emu/${EMU_PLATFORM}.cmake +# when building the `run` target. Create this placeholder file so it doesn't complain. +# The real 'run' custom_target should be defined in `board.cmake` instead. +# +# See https://docs.zephyrproject.org/latest/develop/test/twister.html#running-tests-on-custom-emulator +# diff --git a/doc/develop/test/twister.rst b/doc/develop/test/twister.rst index 0c2e81cd48b..a9ecbc98c94 100644 --- a/doc/develop/test/twister.rst +++ b/doc/develop/test/twister.rst @@ -643,6 +643,42 @@ integration keyword in the testcase definition file (testcase.yaml and sample.yaml). +Running tests on custom emulator +******************************** + +Apart from the already supported QEMU and other simulated environments, Twister +supports running any out-of-tree custom emulator defined in the board's :file:`board.cmake`. +To use this type of simulation, add the following properties to +:file:`custom_board/custom_board.yaml`: + +:: + + simulation: custom + simulation_exec: + +This tells Twister that the board is using a custom emulator called ````, +make sure this binary exists in the PATH. + +Then, in :file:`custom_board/board.cmake`, set the supported emulation platforms to ``custom``: + +:: + + set(SUPPORTED_EMU_PLATFORMS custom) + +Finally, implement the ``run_custom`` target in :file:`custom_board/board.cmake`. +It should look something like this: + +:: + + add_custom_target(run_custom + COMMAND + + + WORKING_DIRECTORY ${APPLICATION_BINARY_DIR} + DEPENDS ${logical_target_for_zephyr_elf} + USES_TERMINAL + ) + Running Tests on Hardware ************************* diff --git a/scripts/pylib/twister/twisterlib/handlers.py b/scripts/pylib/twister/twisterlib/handlers.py index 9a74cc2cb5c..a89e82b1bb1 100755 --- a/scripts/pylib/twister/twisterlib/handlers.py +++ b/scripts/pylib/twister/twisterlib/handlers.py @@ -39,7 +39,7 @@ except ImportError as capture_error: logger = logging.getLogger('twister') logger.setLevel(logging.DEBUG) -SUPPORTED_SIMS = ["mdb-nsim", "nsim", "renode", "qemu", "tsim", "armfvp", "xt-sim", "native"] +SUPPORTED_SIMS = ["mdb-nsim", "nsim", "renode", "qemu", "tsim", "armfvp", "xt-sim", "native", "custom"] SUPPORTED_SIMS_IN_PYTEST = ['native', 'qemu'] diff --git a/scripts/schemas/twister/platform-schema.yaml b/scripts/schemas/twister/platform-schema.yaml index 6e94218e69b..6524e5f8769 100644 --- a/scripts/schemas/twister/platform-schema.yaml +++ b/scripts/schemas/twister/platform-schema.yaml @@ -24,7 +24,19 @@ mapping: enum: ["mcu", "qemu", "sim", "unit", "native"] "simulation": type: str - enum: ["qemu", "simics", "xt-sim", "renode", "nsim", "mdb-nsim", "tsim", "armfvp", "native"] + enum: + [ + "qemu", + "simics", + "xt-sim", + "renode", + "nsim", + "mdb-nsim", + "tsim", + "armfvp", + "native", + "custom", + ] "simulation_exec": type: str "arch":