#!/usr/bin/env bash # run_tests.sh — Run the unit test suite inside Docker (no GPU required) # # Uses the `tester` Docker stage which: # 1. Builds the release binary (or reuses cached build) # 2. Symlinks the CUDA stubs so libcuda.so.1 is satisfied without a driver # 3. Runs `cargo test --release` # # Usage: # ./run_tests.sh # run all unit tests # ./run_tests.sh models # run only tests matching "models" # CUDA_VERSION=12.1.0 ./run_tests.sh set -euo pipefail CUDA_VERSION=${CUDA_VERSION:-12.4.1} UBUNTU_VERSION=${UBUNTU_VERSION:-22.04} TEST_FILTER=${1:-} echo "==> Building tester stage (CUDA ${CUDA_VERSION} / Ubuntu ${UBUNTU_VERSION})..." docker build \ --target tester \ --build-arg CUDA_VERSION="${CUDA_VERSION}" \ --build-arg UBUNTU_VERSION="${UBUNTU_VERSION}" \ --tag whisper-tester:local \ . if [[ -n "${TEST_FILTER}" ]]; then echo "==> Running tests matching '${TEST_FILTER}'..." docker run --rm \ -e LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs \ whisper-tester:local \ sh -c "cd /build && ln -sf /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && LD_LIBRARY_PATH=/usr/local/cuda/lib64/stubs cargo test --release '${TEST_FILTER}'" else echo "==> All tests ran during docker build (tester stage)." echo " Build succeeded — all tests passed." fi