1.. _bsim: 2 3BabbleSim 4######### 5 6BabbleSim and Zephyr 7******************** 8 9In the Zephyr project we use the `Babblesim`_ simulator to test some of the Zephyr radio protocols, 10including the BLE stack, 802.15.4, and some of the networking stack. 11 12BabbleSim_ is a physical layer simulator, which in combination with the Zephyr 13:ref:`bsim boards<bsim boards>` 14can be used to simulate a network of BLE and 15.4 devices. 15When we build Zephyr targeting an :ref:`nrf52_bsim<nrf52_bsim>` board we produce a Linux 16executable, which includes the application, Zephyr OS, and models of the HW. 17 18When there is radio activity, this Linux executable will connect to the BabbleSim Phy simulation 19to simulate the radio channel. 20 21In the BabbleSim documentation you can find more information on how to 22`get <https://babblesim.github.io/fetching.html>`_ and 23`build <https://babblesim.github.io/building.html>`_ the simulator. 24In the :ref:`nrf52_bsim<nrf52_bsim>` board documentation you can find more information about how 25to build Zephyr targeting that particular board, and a few examples. 26 27Types of tests 28************** 29 30Tests without radio activity: bsim tests with twister 31----------------------------------------------------- 32 33The :ref:`bsim boards<bsim boards>` can be used without radio activity, and in that case, it is not 34necessary to connect them to a phyisical layer simulation. Thanks to this, this target boards can 35be used just like :ref:`native_posix<native_posix>` with :ref:`twister <twister_script>`, 36to run all standard Zephyr twister tests, but with models of a real SOC HW, and their drivers. 37 38Tests with radio activity 39------------------------- 40 41When there is radio activity, BabbleSim tests require at the very least a physical layer simulation 42running, and most, more than 1 simulated device. Due to this, these tests are not build and run 43with twister, but with a dedicated set of tests scripts. 44 45These tests are kept in the :code:`tests/bsim/` folder. There you can find a README with more 46information about how to build and run them, as well as the convention they follow. 47 48There are two main sets of tests of these type: 49 50* Self checking embedded application/tests: In which some of the simulated devices applications are 51 built with some checks which decide if the test is passing or failing. These embedded 52 applications tests use the :ref:`bs_tests<bsim_boards_bs_tests>` system to report the pass or 53 failure, and in many cases to build several tests into the same binary. 54 55* Test using the EDTT_ tool, in which a EDTT (python) test controls the embedded applications over 56 an RPC mechanism, and decides if the test passes or not. 57 Today these tests include a very significant subset of the BT qualification test suite. 58 59More information about how different tests types relate to BabbleSim and the bsim boards can be 60found in the :ref:`bsim boards tests section<bsim_boards_tests>`. 61 62Test coverage and BabbleSim 63*************************** 64 65As the :ref:`nrf52_bsim<nrf52_bsim>` is based on the POSIX architecture, you can easily collect test 66coverage information. 67 68You can use the script :code:`tests/bsim/generate_coverage_report.sh` to generate an html 69coverage report from tests. 70 71Check :ref:`the page on coverage generation <coverage_posix>` for more info. 72 73.. _BabbleSim: 74 https://BabbleSim.github.io 75 76.. _EDTT: 77 https://github.com/EDTTool/EDTT 78