#!/bin/sh # Runs the tests that need a real Linux kernel to change the routes of: # those of the bgp-fib crate that `cargo test` skips, and the end-to-end # test of two daemons that route for each other. # # They run in a network namespace made for the purpose, so the machine's # own interfaces and routes are out of their reach, and with the one # capability the daemon needs, CAP_NET_ADMIN, rather than as root. # # Run it on Linux, as a user who can sudo. On another system, # scripts/linux-vm.sh runs it in a virtual machine. set -eu cd "$(dirname "$0")/.." [ "$(uname -s)" = Linux ] || { echo "this needs Linux; see scripts/linux-vm.sh" >&2; exit 1; } # Built as the user, so that nothing in the target directory is root's. cargo build --locked -p bgp cargo test --locked -p bgp-fib --test kernel --no-run cargo test --locked -p bgp-integration-tests --test kernel --no-run # Each in a namespace of its own, as the user, with CAP_NET_ADMIN and # nothing else. scripts/in-namespace.sh cargo test --locked -p bgp-fib --test kernel -- --include-ignored --nocapture "$@" scripts/in-namespace.sh cargo test --locked -p bgp-integration-tests --test kernel -- --include-ignored --nocapture "$@" scripts/two-routers.sh