# Runs VM tests one at a time (they need a lot of memory), says what failed. # router-test NAME... run these tests # router-test --all run all of them # router-test -i NAME build the test's interactive driver and run it: # a Python prompt where start_all(), machine.succeed(...) # and test_script() work; boot once, retry steps # router-test --list # Logs: ${TMPDIR:-/tmp}/router-test-logs/NAME.log vm_tests="webui basic pppoe vlans onestick rollback dns ddns installer apply setup update image wireguard" flake=${FLAKE:-.} logs=${TMPDIR:-/tmp}/router-test-logs mkdir -p "$logs" case ${1:-} in --list) echo "$vm_tests" | tr ' ' '\n'; exit 0 ;; -i|--interactive) [ $# -eq 2 ] || { echo "usage: router-test -i NAME" >&2; exit 2; } driver=$(nix build --no-link --print-out-paths "$flake#checks.x86_64-linux.$2.driverInteractive") exec "$driver/bin/nixos-test-driver" --interactive ;; --all) set -- $vm_tests ;; ""|-*) echo "usage: router-test NAME... | --all | -i NAME | --list" >&2; exit 2 ;; esac failed=0 total=$SECONDS for name in "$@"; do log=$logs/$name.log start=$SECONDS printf '%-12s ' "$name" if nix build "$flake#checks.x86_64-linux.$name" --max-jobs 1 -L --no-link > "$log" 2>&1; then printf 'ok %4ds\n' $((SECONDS - start)) else failed=1 printf 'FAILED %4ds %s\n' $((SECONDS - start)) "$log" # The failing step and what it said, or the build error before any VM ran. if grep -aq '!!! Test "' "$log"; then grep -a -m1 '!!! Test "' "$log" | sed -E 's/^[^>]*> //; s/^/ /' | cut -c1-300 grep -a '!!! ' "$log" | sed -n '2,12p' | sed -E 's/^[^>]*> //; s/^/ /' | cut -c1-240 else grep -a -E '^error|error:' -A8 "$log" | head -24 | sed 's/^/ /' | cut -c1-240 fi fi done printf '\n%d test(s), %ds\n' $# $((SECONDS - total)) exit $failed