Skip to content

Commit ae0d175

Browse files
committed
Add multi-arch Docker test: arm64 (native) + amd64 (QEMU)
run.sh supports: test, amd64, all (parallel), lint, shell
1 parent a1d849a commit ae0d175

2 files changed

Lines changed: 56 additions & 24 deletions

File tree

test-infrastructure/docker-compose.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
1-
# Local Ubuntu test environment — mirrors GitHub Actions CI exactly.
1+
# Local test environment — mirrors GitHub Actions CI for all Docker-capable platforms.
22
#
3-
# Usage:
4-
# docker compose -f test-infrastructure/docker-compose.yml run --rm test
5-
# docker compose -f test-infrastructure/docker-compose.yml run --rm lint
3+
# Coverage matrix:
4+
# Linux arm64: native on Apple Silicon (mirrors CI ubuntu-24.04-arm)
5+
# Linux amd64: QEMU emulation (mirrors CI ubuntu-latest)
6+
# macOS: not possible in Docker — test natively: scripts/test.sh CC=cc
7+
# Windows: not possible in Docker on Mac — CI only
68
#
7-
# Shortcut (from repo root):
8-
# ./test-infrastructure/run.sh # test
9-
# ./test-infrastructure/run.sh lint # lint only
9+
# Usage:
10+
# ./test-infrastructure/run.sh # test arm64 (native, fast)
11+
# ./test-infrastructure/run.sh all # test arm64 + amd64 in parallel
12+
# ./test-infrastructure/run.sh amd64 # test amd64 only (QEMU, slower)
13+
# ./test-infrastructure/run.sh lint # lint only
1014

1115
services:
1216
test:
1317
build:
1418
context: ..
1519
dockerfile: test-infrastructure/Dockerfile
20+
platform: linux/arm64
21+
volumes:
22+
- ..:/src
23+
command: ["CC=gcc", "CXX=g++"]
24+
25+
test-amd64:
26+
build:
27+
context: ..
28+
dockerfile: test-infrastructure/Dockerfile
29+
platform: linux/amd64
1630
volumes:
1731
- ..:/src
18-
# GCC + ASan + UBSan + LeakSanitizer (exactly what CI runs)
1932
command: ["CC=gcc", "CXX=g++"]
2033

2134
lint:

test-infrastructure/run.sh

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,57 @@
11
#!/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)
39
#
410
# 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)
917

1018
set -euo pipefail
1119

1220
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
1321
COMPOSE="docker compose -f $ROOT/test-infrastructure/docker-compose.yml"
1422

1523
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) ==="
1826
$COMPOSE run --rm test
1927
;;
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 ==="
2340
;;
24-
both)
25-
echo "=== Running linters ==="
41+
lint)
42+
echo "=== Linters (clang-format-20 + cppcheck 2.20.0) ==="
2643
$COMPOSE run --rm lint
27-
echo "=== Running tests ==="
28-
$COMPOSE run --rm test
2944
;;
3045
shell)
31-
echo "=== Dropping into test container shell ==="
46+
echo "=== Debug shell (Linux arm64) ==="
3247
$COMPOSE run --rm --entrypoint bash test
3348
;;
49+
shell-amd64)
50+
echo "=== Debug shell (Linux amd64 via QEMU) ==="
51+
$COMPOSE run --rm --entrypoint bash test-amd64
52+
;;
3453
*)
35-
echo "Usage: $0 {test|lint|both|shell}"
54+
echo "Usage: $0 {test|arm64|amd64|all|lint|shell|shell-amd64}"
3655
exit 1
3756
;;
3857
esac

0 commit comments

Comments
 (0)