README.md
1This folder contains tests meant to be run with BabbleSim's physical layer
2simulation, and therefore cannot be run directly from twister.
3
4The compile.sh and run_parallel.sh scripts are used by the CI system to build
5the needed images and execute these tests in batch.
6
7You can also run them manually if desired, but be sure to call them setting
8the variables they expect. For example, from Zephyr's root folder, you can run:
9
10```
11WORK_DIR=${ZEPHYR_BASE}/bsim_out tests/bsim/compile.sh
12RESULTS_FILE=${ZEPHYR_BASE}/myresults.xml SEARCH_PATH=tests/bsim tests/bsim/run_parallel.sh
13```
14
15Or to run only a specific subset, e.g. host advertising tests:
16
17```
18WORK_DIR=${ZEPHYR_BASE}/bsim_out tests/bsim/bluetooth/host/compile.sh
19RESULTS_FILE=${ZEPHYR_BASE}/myresults.xml \
20SEARCH_PATH=tests/bsim/bluetooth/host/adv tests/bsim/run_parallel.sh
21```
22
23Check the run_parallel.sh help for more options and examples on how to use this script to run these
24tests in batch.
25
26After building the tests' required binaries you can run a test directly with its individual
27test scripts.
28
29For example you can build the required binaries for the networking tests with
30
31```
32WORK_DIR=${ZEPHYR_BASE}/bsim_out tests/bsim/net/compile.sh
33```
34and then directly run one of the tests:
35
36```
37tests/bsim/net/sockets/echo_test/tests_scripts/echo_test_802154.sh
38```
39
40
41Generating coverage reports
42---------------------------
43
44You can use `tests/bsim/generate_coverage_report.sh` to generate a coverage report
45of the BabbleSim tests which have been run. Check its help for more info.
46
47
48Conventions about these tests scripts
49-------------------------------------
50
51Each test is defined by a shell script with the extension `.sh`.
52Scripts starting with an underscore (`_`) are ignored.
53
54Each of these test scripts expects the binaries their require already built, and will execute
55the required simulated devices and physical layer simulation with the required command line
56options.
57
58Tests must return 0 to the invoking shell if the test passes, and not 0 if the test
59fails.
60
61It is recommended to have a single test for each test script.
62
63Each test must have a unique simulation id, to enable running different tests in parallel.
64
65These scripts should not compile the images on their own.
66
67Neither the scripts nor the images should modify the workstation filesystem content beyond the
68`${BSIM_OUT_PATH}/results/<simulation_id>/` or `/tmp/` folders.
69That is, they should not leave straneous files behind.
70
71If these scripts or the test binaries create temporary files, they should preferably do so by
72placing them in the `${BSIM_OUT_PATH}/results/<simulation_id>/` folder.
73Otherwise they should be named as to avoid conflicts with other test scripts which may be running
74in parallel.
75
76When running tests that require several consecutive simulations, for ex. if simulating a device
77pairing, powering off, and powering up after as a new simulation,
78they should strive for using separate simulation ids for each simulation part,
79in that way ensuring that the simulation radio activity of each segment can be inspected a
80posteriori.
81
82
83Conventions about the build scripts
84-----------------------------------
85
86The build scripts (compile.sh) simply build all the required test and sample applications
87for the tests' scripts placed in the subfolders below.
88
89This build scripts use the common compile.source which provide a function (compile) which calls
90cmake and ninja with the provided application, configuration and overlay files.
91
92To speed up compilation for users interested only in a subset of tests, several compile scripts
93exist in several subfolders, where the upper ones call into the lower ones.
94
95Note that cmake and ninja are used directly instead of the `west build` wrapper as west is not
96required, and some Zephyr users do not use or have west, but still use this build and tests scripts.
97