#!/bin/sh # Runs a command in a Linux virtual machine with this repository mounted # at the same path: for the tests that need a Linux kernel, from a machine # that is not one. Without arguments it runs scripts/kernel-tests.sh. # # scripts/linux-vm.sh the kernel tests # scripts/linux-vm.sh cargo test the whole test suite, on Linux # scripts/linux-vm.sh scripts/interop/lab.sh the lab with FRR and BIRD # scripts/linux-vm.sh bash a shell # # The machine is made on first use with Lima (https://lima-vm.io; on macOS # `brew install lima`): Ubuntu, with a Rust toolchain. It sees the # repository read-only and builds into a directory of its own. # `limactl stop ferrix` stops it and `limactl delete ferrix` removes it. set -eu vm=ferrix repository="$(cd "$(dirname "$0")/.." && pwd)" command -v limactl >/dev/null || { echo "limactl not found: install Lima first" >&2; exit 1; } if ! limactl list --quiet | grep -qx "$vm"; then limactl start --name="$vm" --cpus=8 --memory=8 --disk=30 --tty=false template://ubuntu-lts limactl shell "$vm" bash -c ' set -eu sudo apt-get update -qq sudo DEBIAN_FRONTEND=noninteractive apt-get install -y -qq build-essential iproute2 iputils-ping curl curl --proto "=https" --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal -q ' elif [ "$(limactl list --format '{{.Status}}' "$vm")" != Running ]; then limactl start "$vm" fi [ $# -gt 0 ] || set -- scripts/kernel-tests.sh limactl shell --workdir "$repository" "$vm" \ bash -lc 'export CARGO_TARGET_DIR="$HOME/target"; exec "$@"' -- "$@"