1.. _twister_script: 2 3Test Runner (Twister) 4##################### 5 6Twister scans for the set of test applications in the git repository 7and attempts to execute them. By default, it tries to build each test 8application on boards marked as default in the board definition file. 9 10The default options will build the majority of the test applications on a 11defined set of boards and will run in an emulated environment if available for 12the architecture or configuration being tested. 13 14Because of the limited test execution coverage, twister 15cannot guarantee local changes will succeed in the full build 16environment, but it does sufficient testing by building samples and 17tests for different boards and different configurations to help keep the 18complete code tree buildable. 19 20When using (at least) one ``-v`` option, twister's console output 21shows for every test application how the test is run (qemu, native_sim, etc.) or 22whether the binary was just built. The resultant 23:ref:`status <twister_statuses>` 24of a test is likewise reported in the ``twister.json`` and other report files. 25There are a few reasons why twister only builds a test and doesn't run it: 26 27- The test is marked as ``build_only: true`` in its ``.yaml`` 28 configuration file. 29- The test configuration has defined a ``harness`` but you don't have 30 it or haven't set it up. 31- The target device is not connected and not available for flashing 32- You or some higher level automation invoked twister with 33 ``--build-only``. 34 35To run the script in the local tree, follow the steps below: 36 37.. tabs:: 38 39 .. group-tab:: Linux 40 41 .. code-block:: bash 42 43 $ source zephyr-env.sh 44 $ ./scripts/twister 45 46 .. group-tab:: Windows 47 48 .. code-block:: bat 49 50 zephyr-env.cmd 51 python .\scripts\twister 52 53 54If you have a system with a large number of cores and plenty of free storage space, 55you can build and run all possible tests using the following options: 56 57.. tabs:: 58 59 .. group-tab:: Linux 60 61 .. code-block:: bash 62 63 $ ./scripts/twister --all --enable-slow 64 65 .. group-tab:: Windows 66 67 .. code-block:: bat 68 69 python .\scripts\twister --all --enable-slow 70 71This will build for all available boards and run all applicable tests in 72a simulated (for example QEMU) environment. 73 74If you want to run tests on one or more specific platforms, you can use 75the ``--platform`` option, it is a platform filter for testing, with this 76option, test suites will only be built/run on the platforms specified. 77This option also supports different revisions of one same board, 78you can use ``--platform board@revision`` to test on a specific revision. 79 80The list of command line options supported by twister can be viewed using: 81 82.. tabs:: 83 84 .. group-tab:: Linux 85 86 .. code-block:: bash 87 88 $ ./scripts/twister --help 89 90 .. group-tab:: Windows 91 92 .. code-block:: bat 93 94 python .\scripts\twister --help 95 96 97Board Configuration 98******************* 99 100To build tests for a specific board and to execute some of the tests on real 101hardware or in an emulation environment such as QEMU a board configuration file 102is required which is generic enough to be used for other tasks that require a 103board inventory with details about the board and its configuration that is only 104available during build time otherwise. 105 106The board metadata file is located in the board directory and is structured 107using the YAML markup language. The example below shows a board with a data 108required for best test coverage for this specific board: 109 110.. code-block:: yaml 111 112 identifier: frdm_k64f 113 name: NXP FRDM-K64F 114 type: mcu 115 arch: arm 116 toolchain: 117 - zephyr 118 - gnuarmemb 119 - xtools 120 supported: 121 - arduino_gpio 122 - arduino_i2c 123 - netif:eth 124 - adc 125 - i2c 126 - nvs 127 - spi 128 - gpio 129 - usb_device 130 - watchdog 131 - can 132 - pwm 133 testing: 134 default: true 135 136 137identifier: 138 A string that matches how the board is defined in the build system. This same 139 string is used when building, for example when calling ``west build`` or 140 ``cmake``: 141 142 .. code-block:: console 143 144 # with west 145 west build -b reel_board 146 # with cmake 147 cmake -DBOARD=reel_board .. 148 149name: 150 The actual name of the board as it appears in marketing material. 151type: 152 Type of the board or configuration, currently we support 2 types: mcu, qemu 153simulation: 154 Simulator(s) used to simulate the platform, e.g. qemu. 155 156 .. code-block:: yaml 157 158 simulation: 159 - name: qemu 160 - name: armfvp 161 exec: FVP_Some_Platform 162 - name: custom 163 exec: AnotherBinary 164 165 By default, tests will be executed using the first entry in the simulation array. Another 166 simulation can be selected with ``--simulation <simulation_name>``. 167 The ``exec`` attribute is optional. If it is set but the required simulator is not available, the 168 tests will be built only. 169 If it is not set and the required simulator is not available the tests will fail to run. 170 The simulation name must match one of the element of ``SUPPORTED_EMU_PLATFORMS``. 171arch: 172 Architecture of the board 173toolchain: 174 The list of supported toolchains that can build this board. This should match 175 one of the values used for :envvar:`ZEPHYR_TOOLCHAIN_VARIANT` when building on the command line 176ram: 177 Available RAM on the board (specified in KB). This is used to match test scenario 178 requirements. If not specified we default to 128KB. 179flash: 180 Available FLASH on the board (specified in KB). This is used to match test scenario 181 requirements. If not specified we default to 512KB. 182supported: 183 A list of features this board supports. This can be specified as a single word 184 feature or as a variant of a feature class. For example: 185 186 .. code-block:: yaml 187 188 supported: 189 - pci 190 191 This indicates the board does support PCI. You can make a test scenario build or 192 run only on such boards, or: 193 194 .. code-block:: yaml 195 196 supported: 197 - netif:eth 198 - sensor:bmi16 199 200 A test scenario can depend on 'eth' to only test ethernet or on 'netif' to run 201 on any board with a networking interface. 202 203testing: 204 testing relating keywords to provide best coverage for the features of this 205 board. 206 207.. _twister_default_testing_board: 208 209 binaries: 210 A list of custom binaries to be kept for device testing. 211 default: [True|False]: 212 This is a default board, it will tested with the highest priority and is 213 covered when invoking the simplified twister without any additional 214 arguments. 215 ignore_tags: 216 Do not attempt to build (and therefore run) tests marked with this list of 217 tags. 218 only_tags: 219 Only execute tests with this list of tags on a specific platform. 220 221 .. _twister_board_timeout_multiplier: 222 223 timeout_multiplier: <float> (default 1) 224 Multiply each test scenario timeout by specified ratio. This option allows to tune timeouts only 225 for required platform. It can be useful in case naturally slow platform I.e.: HW board with 226 power-efficient but slow CPU or simulation platform which can perform instruction accurate 227 simulation but does it slowly. 228 229env: 230 A list of environment variables. Twister will check if all these environment variables are set, 231 and otherwise skip this platform. This allows the user to define a platform which should be 232 used, for example, only if some required software or hardware is present, and to signal that 233 presence to twister using these environment variables. 234 235.. _twister_tests_long_version: 236 237Tests 238****** 239 240Tests are detected by the presence of a ``testcase.yaml`` or a ``sample.yaml`` 241files in the application's project directory. This test application 242configuration file may contain one or more entries in the ``tests:`` section each 243identifying a Test Scenario. 244 245.. _twister_test_project_diagram: 246 247.. figure:: figures/twister_test_project.svg 248 :alt: Twister and a Test application project. 249 :figclass: align-center 250 251 Twister and a Test application project. 252 253 254Test application configurations are written using the YAML syntax and share the 255same structure as samples. 256 257A Test Scenario is a set of conditions and variables defined in a Test Scenario 258entry, under which a set of Test Suites will be built and executed. 259 260A Test Suite is a collection of Test Cases which are intended to be used to test 261a software program to ensure it meets certain requirements. The Test Cases in a 262Test Suite are either related or meant to be executed together. 263 264Test Scenario, Test Suite, and Test Case names must follow to these basic rules: 265 266#. The format of the Test Scenario identifier shall be a string without any spaces or 267 special characters (allowed characters: alphanumeric and [\_=]) consisting 268 of multiple sections delimited with a dot (``.``). 269 270#. Each Test Scenario identifier shall start with a section name followed by a 271 subsection names delimited with a dot (``.``). For example, a test scenario 272 that covers semaphores in the kernel shall start with ``kernel.semaphore``. 273 274#. All Test Scenario identifiers within a Test Configuration (``testcase.yaml`` file) 275 need to be unique. 276 For example a ``testcase.yaml`` file covering semaphores in the kernel can have: 277 278 * ``kernel.semaphore``: For general semaphore tests 279 * ``kernel.semaphore.stress``: Stress testing semaphores in the kernel. 280 281#. The full canonical name of a Test Suite is: 282 ``<Test Application Project path>/<Test Scenario identifier>`` 283 284#. Depending on the Test Suite implementation, its Test Case identifiers consist 285 of **at least three sections** delimited with a dot (``.``): 286 287 * **Ztest tests**: 288 a Test Scenario identifier from the corresponding ``testcase.yaml`` file, 289 a Ztest suite name, and a Ztest test name: 290 ``<Test Scenario identifier>.<Ztest suite name>.<Ztest test name>`` 291 292 * **Standalone tests and samples**: 293 a Test Scenario identifier from the corresponding ``testcase.yaml`` (or 294 ``sample.yaml``) file where the last section signifies the standalone 295 Test Case name, for example: ``debug.coredump.logging_backend``. 296 297 298The ``--no-detailed-test-id`` command line option modifies the above rules in this way: 299 300#. A Test Suite name has only ``<Test Scenario identifier>`` component. 301 Its Application Project path can be found in ``twister.json`` report as ``path:`` property. 302 303#. With short Test Suite names in this mode, all corresponding Test Scenario names 304 must be unique for the Twister execution scope. 305 306#. **Ztest** Test Case names have only Ztest components ``<Ztest suite name>.<Ztest test name>``. 307 Its parent Test Suite name equals to the corresponding Test Scenario identifier. 308 309 310The following is an example test configuration with a few options that are 311explained in this document. 312 313 314 .. code-block:: yaml 315 316 tests: 317 bluetooth.gatt: 318 build_only: true 319 platform_allow: qemu_cortex_m3 qemu_x86 320 tags: bluetooth 321 bluetooth.gatt.br: 322 build_only: true 323 extra_args: CONF_FILE="prj_br.conf" 324 filter: not CONFIG_DEBUG 325 platform_exclude: up_squared 326 platform_allow: qemu_cortex_m3 qemu_x86 327 tags: bluetooth 328 329 330A sample with tests will have the same structure with additional information 331related to the sample and what is being demonstrated: 332 333 .. code-block:: yaml 334 335 sample: 336 name: hello world 337 description: Hello World sample, the simplest Zephyr application 338 tests: 339 sample.basic.hello_world: 340 build_only: true 341 tags: tests 342 min_ram: 16 343 sample.basic.hello_world.singlethread: 344 build_only: true 345 extra_args: CONF_FILE=prj_single.conf 346 filter: not CONFIG_BT 347 tags: tests 348 min_ram: 16 349 350A Test Scenario entry in the ``tests:`` YAML dictionary has its Test Scenario 351identifier as a key. 352 353Each Test Scenario entry in the Test Application configuration can define the 354following key/value pairs: 355 356.. _test_config_args: 357 358tags: <list of tags> (required) 359 A set of string tags for the test scenario. Usually pertains to 360 functional domains but can be anything. Command line invocations 361 of this script can filter the set of tests to run based on tag. 362 363skip: <True|False> (default False) 364 skip test scenario unconditionally. This can be used for broken tests for 365 example. 366 367slow: <True|False> (default False) 368 Don't run this test scenario unless ``--enable-slow`` or ``--enable-slow-only`` was 369 passed in on the command line. Intended for time-consuming test scenarios that 370 are only run under certain circumstances, like daily builds. These test 371 scenarios are still compiled. 372 373extra_args: <list of extra arguments> 374 Extra arguments to pass to build tool when building or running the 375 test scenario. 376 377 Using namespacing, it is possible to apply extra_args only to some 378 hardware. Currently architectures/platforms/simulation are supported: 379 380 .. code-block:: yaml 381 382 common: 383 tags: drivers adc 384 tests: 385 test: 386 depends_on: adc 387 test_async: 388 extra_args: 389 - arch:x86:CONFIG_ADC_ASYNC=y 390 - platform:qemu_x86:CONFIG_DEBUG=y 391 - platform:mimxrt1060_evk:SHIELD=rk043fn66hs_ctg 392 - simulation:qemu:CONFIG_MPU=y 393 394extra_configs: <list of extra configurations> 395 Extra configuration options to be merged with a main prj.conf 396 when building or running the test scenario. For example: 397 398 .. code-block:: yaml 399 400 common: 401 tags: drivers adc 402 tests: 403 test: 404 depends_on: adc 405 test_async: 406 extra_configs: 407 - CONFIG_ADC_ASYNC=y 408 409 Using namespacing, it is possible to apply a configuration only to some 410 hardware. Currently both architectures and platforms are supported: 411 412 .. code-block:: yaml 413 414 common: 415 tags: drivers adc 416 tests: 417 test: 418 depends_on: adc 419 test_async: 420 extra_configs: 421 - arch:x86:CONFIG_ADC_ASYNC=y 422 - platform:qemu_x86:CONFIG_DEBUG=y 423 424 425build_only: <True|False> (default False) 426 If true, twister will not try to run the test even if the test is runnable 427 on the platform. 428 429 This keyword is reserved for tests that are used to test if some code 430 actually builds. A ``build_only`` test is not designed to be run in any 431 environment and should not be testing any functionality, it only verifies 432 that the code builds. 433 434 This option is often used to test drivers and the fact that they are correctly 435 enabled in Zephyr and that the code builds, for example sensor drivers. Such 436 test shall not be used to verify the functionality of the driver. 437 438build_on_all: <True|False> (default False) 439 If true, attempt to build test scenario on all available platforms. This is mostly 440 used in CI for increased coverage. Do not use this flag in new tests. 441 442depends_on: <list of features> 443 A board or platform can announce what features it supports, this option 444 will enable the test only those platforms that provide this feature. 445 446levels: <list of levels> 447 Test levels this test should be part of. If a level is present, this 448 test will be selectable using the command line option ``--level <level name>`` 449 450min_ram: <integer> 451 estimated minimum amount of RAM in KB needed for this test to build and run. This is 452 compared with information provided by the board metadata. 453 454min_flash: <integer> 455 estimated minimum amount of ROM in KB needed for this test to build and run. This is 456 compared with information provided by the board metadata. 457 458.. _twister_test_case_timeout: 459 460timeout: <number of seconds> 461 Length of time to run test before automatically killing it. 462 Default to 60 seconds. 463 464arch_allow: <list of arches, such as x86, arm, arc> 465 Set of architectures that this test scenario should only be run for. 466 467arch_exclude: <list of arches, such as x86, arm, arc> 468 Set of architectures that this test scenario should not run on. 469 470vendor_allow: <list of vendors> 471 Set of platform vendors that this test scenario should only be run for. The 472 vendor is defined as part of the board definition. Boards associated with 473 this vendors will be included. Other boards, including those without a 474 vendor will be excluded. 475 476vendor_exclude: <list of vendors> 477 Set of platform vendors that this test scenario should not run on. 478 The vendor is defined as part of the board. Boards associated with this 479 vendors will be excluded. 480 481platform_allow: <list of platforms> 482 Set of platforms that this test scenario should only be run for. Do not use 483 this option to limit testing or building in CI due to time or resource 484 constraints, this option should only be used if the test or sample can 485 only be run on the allowed platform and nothing else. 486 487integration_platforms: <YML list of platforms/boards> 488 This option limits the scope to the listed platforms when twister is 489 invoked with the ``--integration`` option. Use this instead of 490 platform_allow if the goal is to limit scope due to timing or 491 resource constraints. 492 493platform_exclude: <list of platforms> 494 Set of platforms that this test scenario should not run on. 495 496extra_sections: <list of extra binary sections> 497 When computing sizes, twister will report errors if it finds 498 extra, unexpected sections in the Zephyr binary unless they are named 499 here. They will not be included in the size calculation. 500 501sysbuild: <True|False> (default False) 502 Build the project using sysbuild infrastructure. Only the main project's 503 generated devicetree and Kconfig will be used for filtering tests. 504 on device testing must use the hardware map, or west flash to load 505 the images onto the target. The ``--erase`` option of west flash is 506 not supported with this option. Usage of unsupported options will result 507 in tests requiring sysbuild support being skipped. 508 509harness: <string> 510 A harness keyword in the ``testcase.yaml`` file identifies a Twister 511 harness needed to run a test successfully. A harness is a feature of 512 Twister and implemented by Twister, some harnesses are defined as 513 placeholders and have no implementation yet. 514 515 A harness can be seen as the handler that needs to be implemented in 516 Twister to be able to evaluate if a test passes criteria. For example, a 517 keyboard harness is set on tests that require keyboard interaction to reach 518 verdict on whether a test has passed or failed, however, Twister lack this 519 harness implementation at the moment. 520 521 Supported harnesses: 522 523 - ztest 524 - test 525 - console 526 - pytest 527 - gtest 528 - robot 529 530 Harnesses ``ztest``, ``gtest`` and ``console`` are based on parsing of the 531 output and matching certain phrases. ``ztest`` and ``gtest`` harnesses look 532 for pass/fail/etc. frames defined in those frameworks. Use ``gtest`` 533 harness if you've already got tests written in the gTest framework and do 534 not wish to update them to zTest. The ``console`` harness tells Twister to 535 parse a test's text output for a regex defined in the test's YAML file. 536 The ``robot`` harness is used to execute Robot Framework test suites 537 in the Renode simulation framework. 538 539 Some widely used harnesses that are not supported yet: 540 541 - keyboard 542 - net 543 - bluetooth 544 545 Harness ``bsim`` is implemented in limited way - it helps only to copy the 546 final executable (``zephyr.exe``) from build directory to BabbleSim's 547 ``bin`` directory (``${BSIM_OUT_PATH}/bin``). This action is useful to allow 548 BabbleSim's tests to directly run after. By default, the executable file 549 name is (with dots and slashes replaced by underscores): 550 ``bs_<platform_name>_<test_path>_<test_scenario_name>``. 551 This name can be overridden with the ``bsim_exe_name`` option in 552 ``harness_config`` section. 553 554platform_key: <list of platform attributes> 555 Often a test needs to only be built and run once to qualify as passing. 556 Imagine a library of code that depends on the platform architecture where 557 passing the test on a single platform for each arch is enough to qualify the 558 tests and code as passing. The platform_key attribute enables doing just 559 that. 560 561 For example to key on (arch, simulation) to ensure a test is run once 562 per arch and simulation (as would be most common): 563 564 .. code-block:: yaml 565 566 platform_key: 567 - arch 568 - simulation 569 570 Adding platform (board) attributes to include things such as soc name, 571 soc family, and perhaps sets of IP blocks implementing each peripheral 572 interface would enable other interesting uses. For example, this could enable 573 building and running SPI tests once for each unique IP block. 574 575harness_config: <harness configuration options> 576 Extra harness configuration options to be used to select a board and/or 577 for handling generic Console with regex matching. Config can announce 578 what features it supports. This option will enable the test to run on 579 only those platforms that fulfill this external dependency. 580 581 The following options are currently supported: 582 583 type: <one_line|multi_line> (required) 584 Depends on the regex string to be matched 585 586 regex: <list of regular expressions> (required) 587 Strings with regular expressions to match with the test's output 588 to confirm the test runs as expected. 589 590 ordered: <True|False> (default False) 591 Check the regular expression strings in orderly or randomly fashion 592 593 record: <recording options> (optional) 594 regex: <regular expression> (required) 595 The regular expression with named subgroups to match data fields 596 at the test's output lines where the test provides some custom data 597 for further analysis. These records will be written into the build 598 directory ``recording.csv`` file as well as ``recording`` property 599 of the test suite object in ``twister.json``. 600 601 For example, to extract three data fields ``metric``, ``cycles``, 602 ``nanoseconds``: 603 604 .. code-block:: yaml 605 606 record: 607 regex: "(?P<metric>.*):(?P<cycles>.*) cycles, (?P<nanoseconds>.*) ns" 608 609 as_json: <list of regex subgroup names> (optional) 610 Data fields, extracted by the regular expression into named subgroups, 611 which will be additionally parsed as JSON encoded strings and written 612 into ``twister.json`` as nested ``recording`` object properties. 613 The corresponding ``recording.csv`` columns will contain strings as-is. 614 615 Using this option, a test log can convey layered data structures 616 passed from the test image for further analysis with summary results, 617 traces, statistics, etc. 618 619 For example, this configuration: 620 621 .. code-block:: yaml 622 623 record: 624 regex: "RECORD:(?P<type>.*):DATA:(?P<metrics>.*)" 625 as_json: [metrics] 626 627 when matched to a test log string: 628 629 .. code-block:: none 630 631 RECORD:jitter_drift:DATA:{"rollovers":0, "mean_us":1000.0} 632 633 will be reported in ``twister.json`` as: 634 635 .. code-block:: json 636 637 "recording":[ 638 { 639 "type":"jitter_drift", 640 "metrics":{ 641 "rollovers":0, 642 "mean_us":1000.0 643 } 644 } 645 ] 646 647 fixture: <expression> 648 Specify a test scenario dependency on an external device(e.g., sensor), 649 and identify setups that fulfill this dependency. It depends on 650 specific test setup and board selection logic to pick the particular 651 board(s) out of multiple boards that fulfill the dependency in an 652 automation setup based on ``fixture`` keyword. Some sample fixture names 653 are i2c_hts221, i2c_bme280, i2c_FRAM, ble_fw and gpio_loop. 654 655 Only one fixture can be defined per test scenario and the fixture name has to 656 be unique across all tests in the test suite. 657 658.. _pytest_root: 659 660 pytest_root: <list of pytest testpaths> (default pytest) 661 Specify a list of pytest directories, files or subtests that need to be 662 executed when a test scenario begins to run. The default pytest directory is 663 ``pytest``. After the pytest run is finished, Twister will check if 664 the test scenario passed or failed according to the pytest report. 665 As an example, a list of valid pytest roots is presented below: 666 667 .. code-block:: yaml 668 669 harness_config: 670 pytest_root: 671 - "pytest/test_shell_help.py" 672 - "../shell/pytest/test_shell.py" 673 - "/tmp/test_shell.py" 674 - "~/tmp/test_shell.py" 675 - "$ZEPHYR_BASE/samples/subsys/testsuite/pytest/shell/pytest/test_shell.py" 676 - "pytest/test_shell_help.py::test_shell2_sample" # select pytest subtest 677 - "pytest/test_shell_help.py::test_shell2_sample[param_a]" # select pytest parametrized subtest 678 679.. _pytest_args: 680 681 pytest_args: <list of arguments> (default empty) 682 Specify a list of additional arguments to pass to ``pytest`` e.g.: 683 ``pytest_args: [‘-k=test_method’, ‘--log-level=DEBUG’]``. Note that 684 ``--pytest-args`` can be passed multiple times to pass several arguments 685 to the pytest. 686 687.. _pytest_dut_scope: 688 689 pytest_dut_scope: <function|class|module|package|session> (default function) 690 The scope for which ``dut`` and ``shell`` pytest fixtures are shared. 691 If the scope is set to ``function``, DUT is launched for every test case 692 in python script. For ``session`` scope, DUT is launched only once. 693 694 robot_testsuite: <robot file path> (default empty) 695 Specify one or more paths to a file containing a Robot Framework test suite to be run. 696 697 robot_option: <robot option> (default empty) 698 One or more options to be send to robotframework. 699 700 bsim_exe_name: <string> 701 If provided, the executable filename when copying to BabbleSim's bin 702 directory, will be ``bs_<platform_name>_<bsim_exe_name>`` instead of the 703 default based on the test path and scenario name. 704 705 The following is an example yaml file with a few harness_config options. 706 707 .. code-block:: yaml 708 709 sample: 710 name: HTS221 Temperature and Humidity Monitor 711 common: 712 tags: sensor 713 harness: console 714 harness_config: 715 type: multi_line 716 ordered: false 717 regex: 718 - "Temperature:(.*)C" 719 - "Relative Humidity:(.*)%" 720 fixture: i2c_hts221 721 tests: 722 test: 723 tags: sensors 724 depends_on: i2c 725 726 The following is an example yaml file with pytest harness_config options, 727 default pytest_root name "pytest" will be used if pytest_root not specified. 728 please refer the examples in samples/subsys/testsuite/pytest/. 729 730 .. code-block:: yaml 731 732 common: 733 harness: pytest 734 tests: 735 pytest.example.directories: 736 harness_config: 737 pytest_root: 738 - pytest_dir1 739 - $ENV_VAR/samples/test/pytest_dir2 740 pytest.example.files_and_subtests: 741 harness_config: 742 pytest_root: 743 - pytest/test_file_1.py 744 - test_file_2.py::test_A 745 - test_file_2.py::test_B[param_a] 746 747 The following is an example yaml file with robot harness_config options. 748 749 .. code-block:: yaml 750 751 tests: 752 robot.example: 753 harness: robot 754 harness_config: 755 robot_testsuite: [robot file path] 756 757 It can be more than one test suite using a list. 758 759 .. code-block:: yaml 760 761 tests: 762 robot.example: 763 harness: robot 764 harness_config: 765 robot_testsuite: 766 - [robot file path 1] 767 - [robot file path 2] 768 - [robot file path n] 769 770 One or more options can be passed to robotframework. 771 772 .. code-block:: yaml 773 774 tests: 775 robot.example: 776 harness: robot 777 harness_config: 778 robot_testsuite: [robot file path] 779 robot_option: 780 - --exclude tag 781 - --stop-on-error 782 783filter: <expression> 784 Filter whether the test scenario should be run by evaluating an expression 785 against an environment containing the following values: 786 787 .. code-block:: none 788 789 { ARCH : <architecture>, 790 PLATFORM : <platform>, 791 <all CONFIG_* key/value pairs in the test's generated defconfig>, 792 *<env>: any environment variable available 793 } 794 795 Twister will first evaluate the expression to find if a "limited" cmake call, i.e. using package_helper cmake script, 796 can be done. Existence of "dt_*" entries indicates devicetree is needed. 797 Existence of "CONFIG*" entries indicates kconfig is needed. 798 If there are no other types of entries in the expression a filtration can be done without creating a complete build system. 799 If there are entries of other types a full cmake is required. 800 801 The grammar for the expression language is as follows: 802 803 .. code-block:: antlr 804 805 expression : expression 'and' expression 806 | expression 'or' expression 807 | 'not' expression 808 | '(' expression ')' 809 | symbol '==' constant 810 | symbol '!=' constant 811 | symbol '<' NUMBER 812 | symbol '>' NUMBER 813 | symbol '>=' NUMBER 814 | symbol '<=' NUMBER 815 | symbol 'in' list 816 | symbol ':' STRING 817 | symbol 818 ; 819 820 list : '[' list_contents ']'; 821 822 list_contents : constant (',' constant)*; 823 824 constant : NUMBER | STRING; 825 826 For the case where ``expression ::= symbol``, it evaluates to ``true`` 827 if the symbol is defined to a non-empty string. 828 829 Operator precedence, starting from lowest to highest: 830 831 * or (left associative) 832 * and (left associative) 833 * not (right associative) 834 * all comparison operators (non-associative) 835 836 ``arch_allow``, ``arch_exclude``, ``platform_allow``, ``platform_exclude`` 837 are all syntactic sugar for these expressions. For instance: 838 839 .. code-block:: none 840 841 arch_exclude = x86 arc 842 843 Is the same as: 844 845 .. code-block:: none 846 847 filter = not ARCH in ["x86", "arc"] 848 849 The ``:`` operator compiles the string argument as a regular expression, 850 and then returns a true value only if the symbol's value in the environment 851 matches. For example, if ``CONFIG_SOC="stm32f107xc"`` then 852 853 .. code-block:: none 854 855 filter = CONFIG_SOC : "stm.*" 856 857 Would match it. 858 859required_snippets: <list of needed snippets> 860 :ref:`Snippets <snippets>` are supported in twister for test scenarios that 861 require them. As with normal applications, twister supports using the base 862 zephyr snippet directory and test application directory for finding 863 snippets. Listed snippets will filter supported tests for boards (snippets 864 must be compatible with a board for the test to run on them, they are not 865 optional). 866 867 The following is an example yaml file with 2 required snippets. 868 869 .. code-block:: yaml 870 871 tests: 872 snippet.example: 873 required_snippets: 874 - cdc-acm-console 875 - user-snippet-example 876 877The set of test scenarios that actually run depends on directives in the test scenario 878filed and options passed in on the command line. If there is any confusion, 879running with ``-v`` or examining the discard report 880(:file:`twister_discard.csv`) can help show why particular test scenarios were 881skipped. 882 883Metrics (such as pass/fail state and binary size) for the last code 884release are stored in ``scripts/release/twister_last_release.csv``. 885To update this, pass the ``--all --release`` options. 886 887To load arguments from a file, add ``+`` before the file name, e.g., 888``+file_name``. File content must be one or more valid arguments separated by 889line break instead of white spaces. 890 891Most everyday users will run with no arguments. 892 893Selecting platform scope 894************************ 895 896One of the key features of Twister is its ability to decide on which platforms a given 897test scenario should run. This behavior has its roots in Twister being developed as 898a test runner for Zephyr's CI. With hundreds of available platforms and thousands of 899tests, the testing tools should be able to adapt the scope and select/filter out what 900is relevant and what is not. 901 902Twister always prepares an initial list of platforms in scope for a given test, 903based on command line arguments and the :ref:`test's configuration <test_config_args>`. Then, 904platforms that don't fulfill the conditions required in the configuration yaml 905(e.g. minimum ram) are filtered out from the scope. 906Using ``--force-platform`` allows to override filtering caused by ``platform_allow``, 907``platform_exclude``, ``arch_allow`` and ``arch_exclude`` keys in test configuration 908files. 909 910Command line arguments define the initial scope in the following way: 911 912* ``-p/--platform <platform_name>`` (can be used multiple times): only platforms 913 passed with this argument; 914* ``-l/--all``: all available platforms; 915* ``-G/--integration``: all platforms from an ``integration_platforms`` list in 916 a given test configuration file. If a test has no ``integration_platforms`` 917 *"scope presumption"* will happen; 918* No scope argument: *"scope presumption"* will happen. 919 920*"Scope presumption"*: A list of Twister's :ref:`default platforms <twister_default_testing_board>` 921is used as the initial list. If nothing is left after the filtration, the ``platform_allow`` list 922is used as the initial scope. 923 924Managing tests timeouts 925*********************** 926 927There are several parameters which control tests timeouts on various levels: 928 929* ``timeout`` option in each test scenario. See :ref:`here <twister_test_case_timeout>` for more 930 details. 931* ``timeout_multiplier`` option in board configuration. See 932 :ref:`here <twister_board_timeout_multiplier>` for more details. 933* ``--timeout-multiplier`` twister option which can be used to adjust timeouts in exact twister run. 934 It can be useful in case of simulation platform as simulation time may depend on the host 935 speed & load or we may select different simulation method (i.e. cycle accurate but slower 936 one), etc... 937 938Overall test scenario timeout is a multiplication of these three parameters. 939 940Running in Integration Mode 941*************************** 942 943This mode is used in continuous integration (CI) and other automated 944environments used to give developers fast feedback on changes. The mode can 945be activated using the ``--integration`` option of twister and narrows down 946the scope of builds and tests if applicable to platforms defined under the 947integration keyword in the test configuration file (``testcase.yaml`` and 948``sample.yaml``). 949 950 951Running tests on custom emulator 952******************************** 953 954Apart from the already supported QEMU and other simulated environments, Twister 955supports running any out-of-tree custom emulator defined in the board's :file:`board.cmake`. 956To use this type of simulation, add the following properties to 957:file:`custom_board/custom_board.yaml`: 958 959.. code-block:: yaml 960 961 simulation: 962 - name: custom 963 exec: <name_of_emu_binary> 964 965This tells Twister that the board is using a custom emulator called ``<name_of_emu_binary>``, 966make sure this binary exists in the PATH. 967 968Then, in :file:`custom_board/board.cmake`, set the supported emulation platforms to ``custom``: 969 970.. code-block:: cmake 971 972 set(SUPPORTED_EMU_PLATFORMS custom) 973 974Finally, implement the ``run_custom`` target in :file:`custom_board/board.cmake`. 975It should look something like this: 976 977.. code-block:: cmake 978 979 add_custom_target(run_custom 980 COMMAND 981 <name_of_emu_binary to invoke during 'run'> 982 <any args to be passed to the command, i.e. ${BOARD}, ${APPLICATION_BINARY_DIR}/zephyr/zephyr.elf> 983 WORKING_DIRECTORY ${APPLICATION_BINARY_DIR} 984 DEPENDS ${logical_target_for_zephyr_elf} 985 USES_TERMINAL 986 ) 987 988Running Tests on Hardware 989************************* 990 991Beside being able to run tests in QEMU and other simulated environments, 992twister supports running most of the tests on real devices and produces 993reports for each run with detailed FAIL/PASS results. 994 995 996Executing tests on a single device 997=================================== 998 999To use this feature on a single connected device, run twister with 1000the following new options: 1001 1002.. tabs:: 1003 1004 .. group-tab:: Linux 1005 1006 .. code-block:: bash 1007 1008 scripts/twister --device-testing --device-serial /dev/ttyACM0 \ 1009 --device-serial-baud 115200 -p frdm_k64f -T tests/kernel 1010 1011 .. group-tab:: Windows 1012 1013 .. code-block:: bat 1014 1015 python .\scripts\twister --device-testing --device-serial COM1 \ 1016 --device-serial-baud 115200 -p frdm_k64f -T tests/kernel 1017 1018The ``--device-serial`` option denotes the serial device the board is connected to. 1019This needs to be accessible by the user running twister. You can run this on 1020only one board at a time, specified using the ``--platform`` option. 1021 1022The ``--device-serial-baud`` option is only needed if your device does not run at 1023115200 baud. 1024 1025To support devices without a physical serial port, use the ``--device-serial-pty`` 1026option. In this cases, log messages are captured for example using a script. 1027In this case you can run twister with the following options: 1028 1029.. tabs:: 1030 1031 .. group-tab:: Linux 1032 1033 .. code-block:: bash 1034 1035 scripts/twister --device-testing --device-serial-pty "script.py" \ 1036 -p intel_adsp/cavs25 -T tests/kernel 1037 1038 .. group-tab:: Windows 1039 1040 .. note:: 1041 1042 Not supported on Windows OS 1043 1044The script is user-defined and handles delivering the messages which can be 1045used by twister to determine the test execution status. 1046 1047The ``--device-flash-timeout`` option allows to set explicit timeout on the 1048device flash operation, for example when device flashing takes significantly 1049large time. 1050 1051The ``--device-flash-with-test`` option indicates that on the platform 1052the flash operation also executes a test scenario, so the flash timeout is 1053increased by a test scenario timeout. 1054 1055Executing tests on multiple devices 1056=================================== 1057 1058To build and execute tests on multiple devices connected to the host PC, a 1059hardware map needs to be created with all connected devices and their 1060details such as the serial device, baud and their IDs if available. 1061Run the following command to produce the hardware map: 1062 1063.. tabs:: 1064 1065 .. group-tab:: Linux 1066 1067 .. code-block:: bash 1068 1069 ./scripts/twister --generate-hardware-map map.yml 1070 1071 .. group-tab:: Windows 1072 1073 .. code-block:: bat 1074 1075 python .\scripts\twister --generate-hardware-map map.yml 1076 1077The generated hardware map file (map.yml) will have the list of connected 1078devices, for example: 1079 1080.. tabs:: 1081 1082 .. group-tab:: Linux 1083 1084 .. code-block:: yaml 1085 1086 - connected: true 1087 id: OSHW000032254e4500128002ab98002784d1000097969900 1088 platform: unknown 1089 product: DAPLink CMSIS-DAP 1090 runner: pyocd 1091 serial: /dev/cu.usbmodem146114202 1092 - connected: true 1093 id: 000683759358 1094 platform: unknown 1095 product: J-Link 1096 runner: unknown 1097 serial: /dev/cu.usbmodem0006837593581 1098 1099 .. group-tab:: Windows 1100 1101 .. code-block:: yaml 1102 1103 - connected: true 1104 id: OSHW000032254e4500128002ab98002784d1000097969900 1105 platform: unknown 1106 product: unknown 1107 runner: unknown 1108 serial: COM1 1109 - connected: true 1110 id: 000683759358 1111 platform: unknown 1112 product: unknown 1113 runner: unknown 1114 serial: COM2 1115 1116 1117Any options marked as ``unknown`` need to be changed and set with the correct 1118values, in the above example the platform names, the products and the runners need 1119to be replaced with the correct values corresponding to the connected hardware. 1120In this example we are using a reel_board and an nrf52840dk/nrf52840: 1121 1122.. tabs:: 1123 1124 .. group-tab:: Linux 1125 1126 .. code-block:: yaml 1127 1128 - connected: true 1129 id: OSHW000032254e4500128002ab98002784d1000097969900 1130 platform: reel_board 1131 product: DAPLink CMSIS-DAP 1132 runner: pyocd 1133 serial: /dev/cu.usbmodem146114202 1134 baud: 9600 1135 - connected: true 1136 id: 000683759358 1137 platform: nrf52840dk/nrf52840 1138 product: J-Link 1139 runner: nrfjprog 1140 serial: /dev/cu.usbmodem0006837593581 1141 baud: 9600 1142 1143 .. group-tab:: Windows 1144 1145 .. code-block:: yaml 1146 1147 - connected: true 1148 id: OSHW000032254e4500128002ab98002784d1000097969900 1149 platform: reel_board 1150 product: DAPLink CMSIS-DAP 1151 runner: pyocd 1152 serial: COM1 1153 baud: 9600 1154 - connected: true 1155 id: 000683759358 1156 platform: nrf52840dk/nrf52840 1157 product: J-Link 1158 runner: nrfjprog 1159 serial: COM2 1160 baud: 9600 1161 1162The baud entry is only needed if not running at 115200. 1163 1164If the map file already exists, then new entries are added and existing entries 1165will be updated. This way you can use one single master hardware map and update 1166it for every run to get the correct serial devices and status of the devices. 1167 1168With the hardware map ready, you can run any tests by pointing to the map 1169 1170.. tabs:: 1171 1172 .. group-tab:: Linux 1173 1174 .. code-block:: bash 1175 1176 ./scripts/twister --device-testing --hardware-map map.yml -T samples/hello_world/ 1177 1178 .. group-tab:: Windows 1179 1180 .. code-block:: bat 1181 1182 python .\scripts\twister --device-testing --hardware-map map.yml -T samples\hello_world 1183 1184The above command will result in twister building tests for the platforms 1185defined in the hardware map and subsequently flashing and running the tests 1186on those platforms. 1187 1188.. note:: 1189 1190 Currently only boards with support for pyocd, nrfjprog, jlink, openocd, or dediprog 1191 are supported with the hardware map features. Boards that require other runners to flash the 1192 Zephyr binary are still work in progress. 1193 1194Hardware map allows to set ``--device-flash-timeout`` and ``--device-flash-with-test`` 1195command line options as ``flash-timeout`` and ``flash-with-test`` fields respectively. 1196These hardware map values override command line options for the particular platform. 1197 1198Serial PTY support using ``--device-serial-pty`` can also be used in the 1199hardware map: 1200 1201.. code-block:: yaml 1202 1203 - connected: true 1204 id: None 1205 platform: intel_adsp/cavs25 1206 product: None 1207 runner: intel_adsp 1208 serial_pty: path/to/script.py 1209 runner_params: 1210 - --remote-host=remote_host_ip_addr 1211 - --key=/path/to/key.pem 1212 1213 1214The runner_params field indicates the parameters you want to pass to the 1215west runner. For some boards the west runner needs some extra parameters to 1216work. It is equivalent to following west and twister commands. 1217 1218.. tabs:: 1219 1220 .. group-tab:: Linux 1221 1222 .. code-block:: bash 1223 1224 west flash --remote-host remote_host_ip_addr --key /path/to/key.pem 1225 1226 twister -p intel_adsp/cavs25 --device-testing --device-serial-pty script.py 1227 --west-flash="--remote-host=remote_host_ip_addr,--key=/path/to/key.pem" 1228 1229 .. group-tab:: Windows 1230 1231 .. note:: 1232 1233 Not supported on Windows OS 1234 1235.. note:: 1236 1237 For serial PTY, the "--generate-hardware-map" option cannot scan it out 1238 and generate a correct hardware map automatically. You have to edit it 1239 manually according to above example. This is because the serial port 1240 of the PTY is not fixed and being allocated in the system at runtime. 1241 1242Fixtures 1243+++++++++ 1244 1245Some tests require additional setup or special wiring specific to the test. 1246Running the tests without this setup or test fixture may fail. A test scenario can 1247specify the fixture it needs which can then be matched with hardware capability 1248of a board and the fixtures it supports via the command line or using the hardware 1249map file. 1250 1251Fixtures are defined in the hardware map file as a list: 1252 1253.. code-block:: yaml 1254 1255 - connected: true 1256 fixtures: 1257 - gpio_loopback 1258 id: 0240000026334e450015400f5e0e000b4eb1000097969900 1259 platform: frdm_k64f 1260 product: DAPLink CMSIS-DAP 1261 runner: pyocd 1262 serial: /dev/ttyACM9 1263 1264When running ``twister`` with ``--device-testing``, the configured fixture 1265in the hardware map file will be matched to test scenarios requesting the same fixtures 1266and these tests will be executed on the boards that provide this fixture. 1267 1268.. figure:: figures/fixtures.svg 1269 :figclass: align-center 1270 1271Fixtures can also be provided via twister command option ``--fixture``, this option 1272can be used multiple times and all given fixtures will be appended as a list. And the 1273given fixtures will be assigned to all boards, this means that all boards set by 1274current twister command can run those test scenarios which request the same fixtures. 1275 1276Some fixtures allow for configuration strings to be appended, separated from the 1277fixture name by a ``:``. Only the fixture name is matched against the fixtures 1278requested by test scenarios. 1279 1280Notes 1281+++++ 1282 1283It may be useful to annotate board descriptions in the hardware map file 1284with additional information. Use the ``notes`` keyword to do this. For 1285example: 1286 1287.. code-block:: yaml 1288 1289 - connected: false 1290 fixtures: 1291 - gpio_loopback 1292 id: 000683290670 1293 notes: An nrf5340dk/nrf5340 is detected as an nrf52840dk/nrf52840 with no serial 1294 port, and three serial ports with an unknown platform. The board id of the serial 1295 ports is not the same as the board id of the development kit. If you regenerate 1296 this file you will need to update serial to reference the third port, and platform 1297 to nrf5340dk/nrf5340/cpuapp or another supported board target. 1298 platform: nrf52840dk/nrf52840 1299 product: J-Link 1300 runner: jlink 1301 serial: null 1302 1303Overriding Board Identifier 1304+++++++++++++++++++++++++++ 1305 1306When (re-)generated the hardware map file will contain an ``id`` keyword 1307that serves as the argument to ``--board-id`` when flashing. In some 1308cases the detected ID is not the correct one to use, for example when 1309using an external J-Link probe. The ``probe_id`` keyword overrides the 1310``id`` keyword for this purpose. For example: 1311 1312.. code-block:: yaml 1313 1314 - connected: false 1315 id: 0229000005d9ebc600000000000000000000000097969905 1316 platform: mimxrt1060_evk 1317 probe_id: 000609301751 1318 product: DAPLink CMSIS-DAP 1319 runner: jlink 1320 serial: null 1321 1322Using Single Board For Multiple Variants 1323++++++++++++++++++++++++++++++++++++++++ 1324 1325 The ``platform`` attribute can be a list of names or a string 1326 with names separated by spaces. This allows to run tests for 1327 different platform variants on the same physical board, without 1328 re-configuring the hardware map file for each variant. For example: 1329 1330.. code-block:: yaml 1331 1332 - connected: true 1333 id: '001234567890' 1334 platform: 1335 - nrf5340dk/nrf5340/cpuapp 1336 - nrf5340dk/nrf5340/cpuapp/ns 1337 product: J-Link 1338 runner: nrfjprog 1339 serial: /dev/ttyACM1 1340 1341Quarantine 1342++++++++++ 1343 1344Twister allows user to provide configuration files defining a list of tests or 1345platforms to be put under quarantine. Such tests will be skipped and marked 1346accordingly in the output reports. This feature is especially useful when 1347running larger test suits, where a failure of one test can affect the execution 1348of other tests (e.g. putting the physical board in a corrupted state). 1349 1350To use the quarantine feature one has to add the argument 1351``--quarantine-list <PATH_TO_QUARANTINE_YAML>`` to a twister call. 1352Multiple quarantine files can be used. 1353The current status of tests on the quarantine list can also be verified by adding 1354``--quarantine-verify`` to the above argument. This will make twister skip all tests 1355which are not on the given list. 1356 1357A quarantine yaml has to be a sequence of dictionaries. Each dictionary has to have 1358``scenarios`` and ``platforms`` entries listing combinations of scenarios and platforms 1359to put under quarantine. In addition, an optional entry ``comment`` can be used, where 1360some more details can be given (e.g. link to a reported issue). These comments will also 1361be added to the output reports. 1362 1363When quarantining a class of tests or many scenarios in a single testsuite or 1364when dealing with multiple issues within a subsystem, it is possible to use 1365regular expressions, for example, **kernel.*** would quarantine 1366all kernel tests. 1367 1368An example of entries in a quarantine yaml: 1369 1370.. code-block:: yaml 1371 1372 - scenarios: 1373 - sample.basic.helloworld 1374 comment: "Link to the issue: https://github.com/zephyrproject-rtos/zephyr/pull/33287" 1375 1376 - scenarios: 1377 - kernel.common 1378 - kernel.common.(misra|tls) 1379 - kernel.common.nano64 1380 platforms: 1381 - .*_cortex_.* 1382 - native_sim 1383 1384To exclude a platform, use the following syntax: 1385 1386.. code-block:: yaml 1387 1388 - platforms: 1389 - qemu_x86 1390 comment: "broken qemu" 1391 1392Additionally you can quarantine entire architectures or a specific simulator for executing tests. 1393 1394Test Configuration 1395****************** 1396 1397A test configuration can be used to customize various aspects of twister 1398and the default enabled options and features. This allows tweaking the filtering 1399capabilities depending on the environment and makes it possible to adapt and 1400improve coverage when targeting different sets of platforms. 1401 1402The test configuration also adds support for test levels and the ability to 1403assign a specific test to one or more levels. Using command line options of 1404twister it is then possible to select a level and just execute the tests 1405included in this level. 1406 1407Additionally, the test configuration allows defining level 1408dependencies and additional inclusion of tests into a specific level if 1409the test itself does not have this information already. 1410 1411In the configuration file you can include complete components using 1412regular expressions and you can specify which test level to import from 1413the same file, making management of levels easier. 1414 1415To help with testing outside of upstream CI infrastructure, additional 1416options are available in the configuration file, which can be hosted 1417locally. As of now, those options are available: 1418 1419- Ability to ignore default platforms as defined in board definitions 1420 (Those are mostly emulation platforms used to run tests in upstream 1421 CI) 1422- Option to specify your own list of default platforms overriding what 1423 upstream defines. 1424- Ability to override ``build_on_all`` options used in some test scenarios. 1425 This will treat tests or sample as any other just build for default 1426 platforms you specify in the configuration file or on the command line. 1427- Ignore some logic in twister to expand platform coverage in cases where 1428 default platforms are not in scope. 1429 1430 1431Platform Configuration 1432====================== 1433 1434The following options control platform filtering in twister: 1435 1436- ``override_default_platforms``: override default key a platform sets in board 1437 configuration and instead use the list of platforms provided in the 1438 configuration file as the list of default platforms. This option is set to 1439 False by default. 1440- ``increased_platform_scope``: This option is set to True by default, when 1441 disabled, twister will not increase platform coverage automatically and will 1442 only build and run tests on the specified platforms. 1443- ``default_platforms``: A list of additional default platforms to add. This list 1444 can either be used to replace the existing default platforms or can extend it 1445 depending on the value of ``override_default_platforms``. 1446 1447And example platforms configuration: 1448 1449.. code-block:: yaml 1450 1451 platforms: 1452 override_default_platforms: true 1453 increased_platform_scope: false 1454 default_platforms: 1455 - qemu_x86 1456 1457 1458Test Level Configuration 1459======================== 1460 1461The test configuration allows defining test levels, level dependencies and 1462additional inclusion of tests into a specific test level if the test itself 1463does not have this information already. 1464 1465In the configuration file you can include complete components using 1466regular expressions and you can specify which test level to import from 1467the same file, making management of levels simple. 1468 1469And example test level configuration: 1470 1471.. code-block:: yaml 1472 1473 levels: 1474 - name: my-test-level 1475 description: > 1476 my custom test level 1477 adds: 1478 - kernel.threads.* 1479 - kernel.timer.behavior 1480 - arch.interrupt 1481 - boards.* 1482 1483 1484Combined configuration 1485====================== 1486 1487To mix the Platform and level configuration, you can take an example as below: 1488 1489An example platforms plus level configuration: 1490 1491.. code-block:: yaml 1492 1493 platforms: 1494 override_default_platforms: true 1495 default_platforms: 1496 - frdm_k64f 1497 levels: 1498 - name: smoke 1499 description: > 1500 A plan to be used verifying basic zephyr features. 1501 - name: unit 1502 description: > 1503 A plan to be used verifying unit test. 1504 - name: integration 1505 description: > 1506 A plan to be used verifying integration. 1507 - name: acceptance 1508 description: > 1509 A plan to be used verifying acceptance. 1510 - name: system 1511 description: > 1512 A plan to be used verifying system. 1513 - name: regression 1514 description: > 1515 A plan to be used verifying regression. 1516 1517 1518To run with above test_config.yaml file, only default_platforms with given test level 1519test scenarios will run. 1520 1521.. tabs:: 1522 1523 .. group-tab:: Linux 1524 1525 .. code-block:: bash 1526 1527 scripts/twister --test-config=<path to>/test_config.yaml 1528 -T tests --level="smoke" 1529 1530 1531 1532Running in Tests in Random Order 1533******************************** 1534Enable ZTEST framework's :kconfig:option:`CONFIG_ZTEST_SHUFFLE` config option to 1535run your tests in random order. This can be beneficial for identifying 1536dependencies between test cases. For native_sim platforms, you can provide 1537the seed to the random number generator by providing ``-seed=value`` as an 1538argument to twister. See :ref:`Shuffling Test Sequence <ztest_shuffle>` for more 1539details. 1540 1541Robot Framework Tests 1542********************* 1543Zephyr supports `Robot Framework <https://robotframework.org/>`_ as one of solutions for automated testing. 1544 1545Robot files allow you to express interactive test scenarios in human-readable text format and execute them in simulation or against hardware. 1546At this moment Zephyr integration supports running Robot tests in the `Renode <https://renode.io/>`_ simulation framework. 1547 1548To execute a Robot test suite with twister, run the following command: 1549 1550.. tabs:: 1551 1552 .. group-tab:: Linux 1553 1554 .. code-block:: bash 1555 1556 $ ./scripts/twister --platform hifive1 --test samples/subsys/shell/shell_module/sample.shell.shell_module.robot 1557 1558 .. group-tab:: Windows 1559 1560 .. code-block:: bat 1561 1562 python .\scripts\twister --platform hifive1 --test samples/subsys/shell/shell_module/sample.shell.shell_module.robot 1563 1564Writing Robot tests 1565=================== 1566 1567For the list of keywords provided by the Robot Framework itself, refer to `the official Robot documentation <https://robotframework.org/robotframework/>`_. 1568 1569Information on writing and running Robot Framework tests in Renode can be found in `the testing section <https://renode.readthedocs.io/en/latest/introduction/testing.html>`_ of Renode documentation. 1570It provides a list of the most commonly used keywords together with links to the source code where those are defined. 1571 1572It's possible to extend the framework by adding new keywords expressed directly in Robot test suite files, as an external Python library or, like Renode does it, dynamically via XML-RPC. 1573For details see the `extending Robot Framework <https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#extending-robot-framework>`_ section in the official Robot documentation. 1574 1575Running a single testsuite 1576========================== 1577 1578To run a single testsuite instead of a whole group of test you can run: 1579 1580.. code-block:: bash 1581 1582 $ twister -p qemu_riscv32 -s tests/kernel/interrupt/arch.shared_interrupt 1583