1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/tests
2023-05-12 11:03:40 +02:00
..
backtrace
bench tests: move bench_ applications to bench/ subdirectory 2023-05-10 09:49:56 +02:00
board_microbit
build_system tests/build_system/external_board_dirs: fix broken symlink 2023-05-12 11:03:40 +02:00
buttons
core Merge #19565 #19568 #19574 2023-05-11 10:11:37 +00:00
cpu_avr8_xmega_drivers
cpu_cortexm_address_check examples,tests: Drop redundant dependency 2023-04-19 16:58:10 +02:00
cpu_efm32_drivers
cpu_efm32_features
dbgpin
drivers tests: move remaining driver related applications to tests/drivers 2023-05-10 11:58:32 +02:00
embunit
emcute examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
entropy_source
fault_handler
float
gcoap_dns tests: update Makefile.ci where tinyDTLS is used 2023-04-26 10:31:35 +02:00
gcoap_fileserver tests/gcoap_fileserver: set CONFIG_NATIVE_ISOLATE_FS 2023-04-26 00:53:15 +02:00
gnrc_dhcpv6_client examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_dhcpv6_client_6lbr examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_dhcpv6_client_stateless examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_dhcpv6_relay examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_gomach examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
gnrc_ipv6_ext examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_ipv6_ext_frag examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_ipv6_ext_opt examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_ipv6_fwd_w_sub Merge pull request #18635 from benpicco/tests/gnrc_ipv6_nib_iface_up 2022-09-25 14:19:40 +02:00
gnrc_ipv6_nib tests/gnrc_ipv6_nib: up interface on initial initialization 2022-10-12 09:37:26 +02:00
gnrc_ipv6_nib_6ln tests: call gnrc_ipv6_nib_iface_up() after gnrc_ipv6_nib_init_iface() 2022-09-23 17:17:42 +02:00
gnrc_ipv6_nib_dns examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_lorawan examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_lorawan_11 examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_lwmac examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
gnrc_mac_timeout
gnrc_ndp
gnrc_netif examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_netif_ieee802154
gnrc_netif_ipv6_wait_for_global_address
gnrc_rpl examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_rpl_p2p
gnrc_rpl_srh gnrc_rpl_srh: check header fields consistency before substraction 2023-04-21 11:40:47 +02:00
gnrc_sixlowpan codespell: fix remaining issues 2022-09-16 14:00:35 +02:00
gnrc_sixlowpan_frag
gnrc_sixlowpan_frag_minfwd examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_sixlowpan_frag_sfr boards/{bluepill*,blackpill*}: rename and improve doc 2023-01-02 16:23:10 +01:00
gnrc_sixlowpan_frag_sfr_congure examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_sixlowpan_frag_sfr_congure_impl tests: add congure_abe to SFR CongURE test 2023-03-01 20:23:32 +01:00
gnrc_sixlowpan_iphc_w_vrb
gnrc_sock_async_event
gnrc_sock_dns examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_sock_dodtls tests: update Makefile.ci where tinyDTLS is used 2023-04-26 10:31:35 +02:00
gnrc_sock_ip
gnrc_sock_neterr examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_sock_tcp tests: Update Makefile.ci 2023-01-13 13:08:39 +01:00
gnrc_sock_udp examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
gnrc_tcp treewide: s/gnrc_pktbuf_cmd/shell_cmd_gnrc_pktbuf/ 2022-09-24 14:50:43 +02:00
gnrc_tx_sync boards/{bluepill*,blackpill*}: rename and improve doc 2023-01-02 16:23:10 +01:00
gnrc_udp examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
heap_cmd examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
ieee802154_hal examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
ieee802154_security tests/drivers: move all driver tests into own folder 2023-05-04 12:45:07 +02:00
ieee802154_submac tests/ieee802154_submac: add support for MRF24j40 radios 2023-01-19 15:34:16 +01:00
l2util examples,tests: Update Makefile.cis 2023-02-27 12:31:04 +01:00
leds
lwip boards/{bluepill*,blackpill*}: rename and improve doc 2023-01-02 16:23:10 +01:00
lwip_sock_ip Merge pull request #16974 from yarrick/lwip_netif 2022-04-26 23:49:49 +02:00
lwip_sock_tcp boards/{bluepill*,blackpill*}: rename and improve doc 2023-01-02 16:23:10 +01:00
lwip_sock_udp
mcuboot
minimal
mpu_noexec_ram
mpu_stack_guard tests/mpu_stack_guard: Fix compilation on modern GCC (>= 12.x) 2022-11-10 12:49:18 +01:00
nanocoap_cli Merge #19346 #19512 #19513 #19514 2023-04-26 15:40:08 +00:00
netdev_common tests/drivers: move all driver tests into own folder 2023-05-04 12:45:07 +02:00
netdev_test
netstats_l2 examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
netstats_neighbor tests/drivers: move all driver tests into own folder 2023-05-04 12:45:07 +02:00
netutils Merge pull request #17905 from benpicco/GNRC_NETIF_STACKSIZE_DEFAULT 2022-10-13 17:10:43 +02:00
nimble_autoconn_ccnl examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
nimble_autoconn_gnrc examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
nimble_autoconn_gnrc_ext examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
nimble_esp_wifi_coexist cpu/esp_common: use generic WIFI_SSID/WIFI_PASS defines 2023-02-17 15:32:03 +01:00
nimble_ext_adv examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
nimble_l2cap examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
nimble_l2cap_server
nimble_netif_ext examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
nimble_rpble_gnrc examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
nimble_rpble_gnrc_ext examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
nimble_statconn_gnrc examples,tests: Drop redundant dependency 2023-04-19 16:58:10 +02:00
nimble_statconn_gnrc_ext examples,tests: Drop redundant dependency 2023-04-19 16:58:10 +02:00
periph treewide: replace occurrences of tests/periph_ with new path 2023-05-06 15:33:03 +02:00
pkg Merge #19566 #19570 2023-05-10 13:02:19 +00:00
riotboot examples,tests: Drop redundant dependency 2023-04-19 16:58:10 +02:00
riotboot_flashwrite Merge #19485 2023-04-22 06:21:38 +00:00
riotboot_hdr
rust_libs tests: move sys related applications to tests/sys/ subdirectory 2023-05-10 12:02:58 +02:00
rust_minimal Rust: Update riot-wrappers 2023-04-25 09:20:58 +02:00
slip examples,tests: replace deprecated module names by new names 2022-09-16 13:15:46 +02:00
sntp examples,tests: Drop redundant dependency 2023-04-19 16:58:10 +02:00
sock_udp_aux examples,tests: Drop redundant dependency 2023-04-19 16:58:10 +02:00
socket_zep tests/socket_zep: set event_callback before init 2022-10-14 16:07:19 +02:00
ssp
stdin
stm32_bootloader examples,tests: Drop redundant dependency 2023-04-19 16:58:10 +02:00
sys tests/sys: fix E275 missing whitespace after keyword + cleanup a bit 2023-05-10 12:02:59 +02:00
turo
turo_txt
unittests Merge #19368 #19529 #19531 2023-05-02 18:08:42 +00:00
.gitignore examples,tests: ignore core dumps via .gitignore 2022-08-31 15:05:14 +02:00
Makefile.boards.netif tests/Makefile.boards.netif: add lora-e5-dev 2023-04-13 10:55:24 +02:00
Makefile.tests_common tests/drivers: move all driver tests into own folder 2023-05-04 12:45:07 +02:00
README.md tests/doc: reorganization and improvements to tests doc 2022-08-04 03:16:27 -04:00
riot_logo.h
test_print_stack_usage.config
test_utils.config

Running and creating tests

There are a number of tests included in RIOT. They are located in the tests folder. These tests allow basic functionality to be verified as well as provide an example of usage.

Running automated tests

Some tests can be performed automatically. The test automation scripts are defined in the <test_application>/tests/ folder. They are written in python and interact through the serial (typically UART) with the test application code running on a board to do the validation. It is recommended to flash the board with the test just before running it because some platforms cannot be reset while testing.

Running single test

From the test application directory run:

BOARD=<board_of_your_choice> make flash test

An automated way of knowing if a test is available is to execute the 'test/available' target from the test application directory. It executes without error if tests run by 'make test' are present.

make test/available

Running all test for particular board

If you would like execute all tests for given board, you could use dedicated script compile_and_test_for_board.py

Go to main RIOT directory and execute command:

./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py . <board_of_your_choice> --with-test-only --jobs=4

More details concerning other available parameters provided by this tool can be found in README.md file and directly in compile_and_test_for_board.py script.

Running tests that require a preliminary manual configuration

Some tests need active monitoring or manual setup steps but still have some automated scripts. The test automation scripts are defined in the <test_application>/tests-with-config/ folder. For running them, follow the setup or analysis documentation and use the test-with-config target.

Running tests that require root privileges

Some tests require root privileges to launch their automated script. In this case, the test automation scripts are defined in the <test_application>/tests-as-root/ folder. For running them, follow the setup or analysis documentation and use the test-as-root target.

Cleaning intermediate files

After test execution intermediate files are not automatically deleted. Execution of multiple tests, especially all for particular board could generate many files. For example, after execution of all test for stm32f469i-disco board (more than 230 tests) around 7.5 GB of intermediate files are created.

There are few methods for cleaning intermediate files.

If you would like to clean intermediate file only for particular board you should go to main RIOT directory and execute one from these commands:

./dist/tools/compile_and_test_for_board/compile_and_test_for_board.py . <board_of_your_choice> --compile-targets clean

or

make BOARD=<board_of_your_choice> clean

If you would like to clean intermediate files for all boards go to main RIOT directory and use this command.

@warning This command cleans all local files, for example, pkg downloads and locally generared docs.

make distclean

Implementing automated tests

The goal is to be able to run all tests in a sequential way for as many targets as possible.

As some board can't be reset without a manual trigger tests should be implemented with some kind of synchronization. This can be done in two ways:

  • use test_utils_interactive_sync when uart input/output does not need to be disabled for the test. This is enabled by default.
  • set up the test in a loop so the test script will be able so sync with some kind of start condition in the test.

The module for the first option is test_utils_interactive_sync and is set as a default module in Makefile.tests_common. It can be disabled by setting in the application makefile DISABLE_MODULE += test_utils_interactive_sync. The python test script will adapt to it automatically.

When using the shell module, test_utils_interactive_sync will use the shell itself to synchronize, and will not use test_utils_interactive_sync(); function to synchronize. Some times you will want to synchronize before the start of the script and use test_utils_interactive_sync(); function (e.g.: tests/ps_schedstatistics). For these cases you can disable test_utils_interactive_sync_shell module in the application Makefile: DISABLE_MODULE += test_utils_interactive_sync_shell.

Automated Tests Guidelines

When using pexpect $ is useless for matching the end of a line, instead use \r\n(pexpect end-of-line).

Beware of + and * at the end of patterns. These patterns will always get a minimal match (non-greedy).(pexpect end-of-patterns) This can be an issue when matching groups and using the matched groups to verify some kind of behavior since * could return an empty match and + only a subset.

This is especially prevalent since printf() is buffered so the output might not arrive in a single read to pexpect.

To avoid this make sure to match a non-ambiguous character at the end of the pattern like \r\n, \s, \), etc..

don't:

    child.expect(r'some string: (\d+)')

do:

    child.expect(r'some string: (\d+)\r\n')
    child.expect(r'some string: (\d+)\s')
    child.expect(r'some string: (\d+) ,')

Use expect() instead of assert()

In order to make a test application functional in all cases, use expect() instead of assert(). The former works like the latter, but will still be compiled in if NDEBUG is defined. This is useful to keep a test application working even when compiling with -DNDEBUG, allowing for the code-under-test to be compiled with that flag. Otherwise, the application would force compiling all tested code with assertions enabled. expect() is defined in the header test_utils/expect.h.

Interaction through the uart

Tests implemented with testrunner use the cleanterm target that provides an interaction without adding extra text output or input handling. It can currently be expected to have unmodified line based interaction with the board.

The expected behavior is verified with the test in tests/test_tools.

Tests cannot rely on having on all boards and terminal programs:

  • unbuffered input
  • allowing sending special characters like ctrl+c/ctrl+d