Skip to content

Running the tests from scratch ​

How to check a change on your machine starting from a clean clone: what to install, what must be run, where root, kernel modules and Docker are needed, what can be skipped. The details of each level are in Checks.

What you need ​

  • Linux on x86_64: ours builds only for Linux.
  • rustup, a C compiler (gcc or clang) and make. The Rust version and the x86_64-unknown-linux-musl target are pinned in rust-toolchain.toml, rustup installs them itself.
  • Python 3.11 or newer: tests/run.py and the other scripts use only the standard library.
  • For E2E — Docker with the docker compose plugin, sudo for modprobe and musl-gcc (the musl-tools package in Debian and Ubuntu).

There is no need to set CARGO_TARGET_DIR: without it everything is built in the clone's target/.

The mandatory set ​

Without root and Docker, from the repository root:

sh
python3 tests/run.py -- cargo test --workspace
python3 tests/run.py -- cargo clippy --workspace --all-targets -- -D warnings
python3 tests/layers.py

tests/run.py writes the full output to /tmp/ours-check-*.log, and to the terminal — the result (passed/failed/ignored) and the log path; see runner. The first cargo test --workspace from a clean clone takes a few minutes, and target/ grows past 10 GB with E2E; while working, the tests of the affected crate are enough: python3 tests/run.py -- cargo test -p <crate>.

The tree is formatted with rustfmt at its defaults: run cargo fmt --all before committing; CI checks it with cargo fmt --all -- --check.

Root and kernel modules ​

cargo test itself does not require root. What depends on the environment:

WhatWithout itHow to enable
kTLS tests (modules/system/tls, vless)skip themselves with the message skipping: `ktls` is unavailable; with OURS_EXPECT=ktls they fail insteadsudo modprobe tls
Rust netns tests (auto-nft and TUN)reported as ignoreda separate netns, OURS_NETNS_TESTS=1 and --ignored --test-threads 1, see the test command
#[ignore]: network, kTLS key updates, measurementsare not run-- --ignored
tests/e2e/netns/*.sh (tun, wireguard, inbound, auto-nft)—unprivileged user namespaces; on Ubuntu 24.04 — sudo sysctl kernel.apparmor_restrict_unprivileged_userns=0

The workspace suite needs IPv6 loopback (::1), which several tests bind to.

E2E in Docker ​

sh
tests/e2e/run.sh socks                 # one scenario
tests/e2e/run.sh                       # all
PROXY=sing-box tests/e2e/run.sh socks  # the same scenario on the reference
  • By default ours is checked: the script builds a musl binary and mounts it into the container. PROXY=sing-box runs the same checks on the reference: a check that fails there too is wrong.
  • The script loads the modules nft_tproxy nf_tproxy_ipv4 nf_tproxy_ipv6 nft_fib_inet if they are missing, and asks for sudo for that. Without sudo they can be loaded in advance.
  • The first run builds the images (Alpine, sing-box from the official image by digest, Xray by sha256) — internet access is needed. One scenario takes 10–20 seconds, all of them — about ten minutes.
  • Run ours and sing-box one after another: the compose projects share subnets.

In detail — E2E.

What can be skipped ​

An ordinary change does not need:

  • tests/features.py — builds of every feature of the binary (needs cargo-hack); needed if [features] or conditional compilation changed;
  • the MIPS check (nightly and clang) — unless atomics, usize and libc were touched;
  • the interop in tests/interop/ — the sing-box and Xray binaries are supplied by hand; needed for changes to a protocol on the wire;
  • the dashboard browser tests (.mjs, need Chromium) and the benchlab measurements (janeblower/benchlab);
  • fuzzing (cargo +nightly fuzz).

The Python dashboard tests are fast and need no browser; they are worth running for changes to app/ui and the admin API:

sh
python3 tests/run.py -- cargo build -p ours
python3 tests/run.py -- python3 tests/dashboard/test_admin.py
python3 tests/run.py -- python3 tests/dashboard/test_demo.py

CI ​

.github/workflows/ci.yml runs on pushes to master, on tags and on pull requests: the mandatory set, rustfmt, the dashboard tests, the musl build, cross builds, cargo-deny, a fuzz replay and E2E. A pull request runs E2E only when tests/e2e_affected.py says the change reaches the binary, or when it has the e2e label. Details are in Checks.

GPL-3.0-or-later