|
1 | 1 | #!/bin/bash |
2 | | -# Quick runner for local Docker-based CI testing. |
| 2 | +# Local CI testing — GCC + ASan + LeakSanitizer in Docker. |
| 3 | +# |
| 4 | +# Coverage: |
| 5 | +# arm64: Native on Apple Silicon (fast, ~3 min) |
| 6 | +# amd64: QEMU emulation (slower, ~8 min) — mirrors CI ubuntu-latest |
| 7 | +# macOS: Run natively: scripts/test.sh CC=cc CXX=c++ |
| 8 | +# Windows: CI only (no Docker support on Mac) |
3 | 9 | # |
4 | 10 | # Usage: |
5 | | -# ./test-infrastructure/run.sh # Run GCC tests (ASan + LeakSanitizer) |
6 | | -# ./test-infrastructure/run.sh lint # Run linters (clang-format + cppcheck) |
7 | | -# ./test-infrastructure/run.sh both # Lint then test |
8 | | -# ./test-infrastructure/run.sh shell # Drop into container shell for debugging |
| 11 | +# ./test-infrastructure/run.sh # arm64 test (default, fast) |
| 12 | +# ./test-infrastructure/run.sh all # arm64 + amd64 in parallel |
| 13 | +# ./test-infrastructure/run.sh amd64 # amd64 only |
| 14 | +# ./test-infrastructure/run.sh lint # clang-format + cppcheck |
| 15 | +# ./test-infrastructure/run.sh shell # debug shell (arm64) |
| 16 | +# ./test-infrastructure/run.sh shell-amd64 # debug shell (amd64) |
9 | 17 |
|
10 | 18 | set -euo pipefail |
11 | 19 |
|
12 | 20 | ROOT="$(cd "$(dirname "$0")/.." && pwd)" |
13 | 21 | COMPOSE="docker compose -f $ROOT/test-infrastructure/docker-compose.yml" |
14 | 22 |
|
15 | 23 | case "${1:-test}" in |
16 | | - test) |
17 | | - echo "=== Running GCC + ASan + LeakSanitizer tests (mirrors Ubuntu CI) ===" |
| 24 | + test|arm64) |
| 25 | + echo "=== Linux arm64 (GCC + ASan + LeakSanitizer) ===" |
18 | 26 | $COMPOSE run --rm test |
19 | 27 | ;; |
20 | | - lint) |
21 | | - echo "=== Running linters (clang-format-20 + cppcheck 2.20.0) ===" |
22 | | - $COMPOSE run --rm lint |
| 28 | + amd64) |
| 29 | + echo "=== Linux amd64 via QEMU (GCC + ASan + LeakSanitizer) ===" |
| 30 | + $COMPOSE run --rm test-amd64 |
| 31 | + ;; |
| 32 | + all) |
| 33 | + echo "=== Testing arm64 + amd64 in parallel ===" |
| 34 | + $COMPOSE run --rm -d test |
| 35 | + $COMPOSE run --rm test-amd64 |
| 36 | + echo "=== Waiting for arm64... ===" |
| 37 | + # docker compose run -d returns immediately; wait for the container |
| 38 | + $COMPOSE wait test 2>/dev/null || true |
| 39 | + echo "=== All platforms passed ===" |
23 | 40 | ;; |
24 | | - both) |
25 | | - echo "=== Running linters ===" |
| 41 | + lint) |
| 42 | + echo "=== Linters (clang-format-20 + cppcheck 2.20.0) ===" |
26 | 43 | $COMPOSE run --rm lint |
27 | | - echo "=== Running tests ===" |
28 | | - $COMPOSE run --rm test |
29 | 44 | ;; |
30 | 45 | shell) |
31 | | - echo "=== Dropping into test container shell ===" |
| 46 | + echo "=== Debug shell (Linux arm64) ===" |
32 | 47 | $COMPOSE run --rm --entrypoint bash test |
33 | 48 | ;; |
| 49 | + shell-amd64) |
| 50 | + echo "=== Debug shell (Linux amd64 via QEMU) ===" |
| 51 | + $COMPOSE run --rm --entrypoint bash test-amd64 |
| 52 | + ;; |
34 | 53 | *) |
35 | | - echo "Usage: $0 {test|lint|both|shell}" |
| 54 | + echo "Usage: $0 {test|arm64|amd64|all|lint|shell|shell-amd64}" |
36 | 55 | exit 1 |
37 | 56 | ;; |
38 | 57 | esac |
0 commit comments