Skip to main content
BSWorld

English | 简体中文

CI Release PyPI bscontroller License

BSWorld tests Bluetooth Hosts and applications on Linux through deterministic simulation. Define the topology and expected behavior in pytest. Hosts connect to BSController over H4 HCI and communicate over a shared BabbleSim radio.

  • Test open-source Host stacks without hardware or changes to their source code.
  • Run multiple devices on one simulation clock. Run independent scenarios in parallel with pytest-xdist.
  • Set path attenuation, inject interference and WLAN activity, or replay recorded radio signals.
  • Inspect application logs, HCI BTSnoop captures, per-Controller radio captures, and shared Ellisys traces.

Quick Start

BSWorld runs on Linux/x86_64.

Docker

The Docker image ships with BabbleSim, a 32-bit UML kernel, and a Guest root filesystem with the Host executables. Run the integration tests from the repository root on a host with Docker Engine.

sudo docker pull ghcr.io/xiaomi/bsworld-linux:latest
mkdir -p .cache/docker-results
# The image runs as UID/GID 1000.
sudo chown 1000:1000 .cache/docker-results
sudo docker run --rm \
  --security-opt seccomp=docker/uml-seccomp.json \
  --mount "type=bind,src=$PWD/.cache/docker-results,dst=/output" \
  ghcr.io/xiaomi/bsworld-linux:latest

The results in .cache/docker-results include pytest.xml, process logs, HCI captures, and RF traces. For suite selection, image versions, and local builds, see the Docker guide.

Local Linux

Development and tests require Python 3.12 or newer. Install these tools on Ubuntu 24.04.

sudo apt-get update
sudo apt-get install -y \
  bash ca-certificates curl git repo file make binutils build-essential \
  python3.12 python3.12-dev python3.12-venv python3-pip \
  gcc-multilib g++-multilib coreutils findutils grep sed

Clone BSWorld and install it in a virtual environment.

git clone https://github.com/XiaoMi/bsworld.git
cd bsworld
export BSWORLD_ROOT="$PWD"
python3.12 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements-dev.txt

Run the development checks.

ruff check .
ruff format --check .
pytest tests/unit -q

Build and Test

Fetch the BabbleSim revisions pinned in components/babblesim.xml.

mkdir -p "$BSWORLD_ROOT/.cache/babblesim"
cd "$BSWORLD_ROOT/.cache/babblesim"
repo init --standalone-manifest --depth=1 -u "file://$BSWORLD_ROOT/components/babblesim.xml"
repo sync -c --no-tags

Set the build paths and compile BabbleSim.

export BSIM_OUT_PATH="$PWD/build"
export BSIM_COMPONENTS_PATH="$PWD/components"
export BSIM_BUILD_FAIL_ASAP=1
make -j"$(nproc)" everything

Run the BabbleSim integration tests from the repository root. In a new shell, activate .venv and restore BSWORLD_ROOT and BSIM_OUT_PATH before running the tests.

cd "$BSWORLD_ROOT"
pytest tests/integration/babblesim -n auto

To run the Host integration suites locally, prepare a 32-bit Guest as described in the UML test environment guide.

Supported Integrations

Each suite runs its Host in a UML Guest and tests it against Bumble on the same simulated radio.

Guest Host Coverage
BlueZ Multi-Guest advertising, scanning, connection and disconnection
Zephyr Bluetooth shell Advertising, scanning, GATT, pairing, privacy, link updates, periodic advertising and sync transfer
NuttX BTSak and NimBLE Advertising, multi-device scanning, interference recovery, GATT reads, writes and notifications
Apache NimBLE Linux Discovery and connection
TrouBLE Battery Service discovery, reads, and notifications in both roles

Technical Architecture

Each Host has its own BSController. Bumble uses its Controller's H4 socket directly. UML Guests use Virtio Bluetooth, which BSWorld bridges to the corresponding H4 socket.

The Controllers, the pytest clock, and any configured interference sources share a BabbleSim PHY. bs2g4phy assigns PHY device IDs, starts the native processes, and synchronizes their startup. bsclock drives the pytest event loop from the time granted by the PHY.

BSWorld assembles the topology and connects each Host to its Controller. Bumble runs in the pytest event loop. Each UML Guest runs in a separate process and receives simulation time from that loop through its own time-travel socket. A topology can run several Guests together.

Bumble runs in the pytest BSClock event loop, and each BSController worker has a separate BSClock-based loop. BS2G4PHY connects the Controllers and pytest clock to the shared BabbleSim PHY.
Figure 1: BSWorld architecture

To set per-Controller options such as device address, buffer sizes, and Bluetooth version, see BSController configuration.

Open hciN.snoop and radioN.pcapng in Wireshark to inspect a Controller's HCI traffic and radio activity. The shared babblesim/ellisys.bttrp collects BSController transmissions for Ellisys. For capture scope and file locations, see Logs, traces, and captures.

Discrete-Time Scheduling

Time base Meaning
Simulation time Advances when all PHY participants synchronize. It governs protocol timers, packet timing, RF events, asyncio waits, and test timeouts.
Wall-clock time Measures test duration on the host and varies with CPU load and Linux scheduling.

After startup, standard asyncio waits and timeouts use simulation time. See Async waiting and simulation time for examples.

Repeatability assumes identical binaries and inputs and controlled random sources. External networks, wall-clock-driven services, and other unadapted Host I/O can still introduce nondeterminism.

Documentation

Community

License

BSWorld is licensed under the Apache License 2.0. For third-party licenses, see Third-Party Notices.

Metadata

Release files for bsworld 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bsworld 1.2.1
File Size Uploaded Provenance Actions
bsworld-1.2.1.tar.gz 2.2 MB With provenance Details for bsworld-1.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bsworld 1.2.1
File Interpreter ABI Platform Actions
bsworld-1.2.1-py3-none-any.whl Python 3 none any Details for bsworld-1.2.1-py3-none-any.whl

Total release size: 2.3 MB

Release files / bsworld-1.2.1.tar.gz

Download URL bsworld-1.2.1.tar.gz
Size 2.2 MB
Tags Source
SHA-256 checksum
How to use checksums
ed3bc39cebc402deec454782a6bda21ed581368e5d9ef37cefdd41a96c76a448
BLAKE2b-256 checksum
How to use checksums
776c78b0e88010b50a54886818a869099127272b219f4441c09e327093d18de7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / bsworld-1.2.1-py3-none-any.whl

Download URL bsworld-1.2.1-py3-none-any.whl
Size 48.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac2d8b9f6e34764c5b8cfffbeee866cbef8e56db217371e4bcebe4e8dda90356
BLAKE2b-256 checksum
How to use checksums
d2551ef8b8005726e6528f71317026ddc4971fe5fc4ecd9a1dd2fda080d6ad06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for bsworld 1.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for bsworld-1.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page