Some checks failed
Rust / build-linux (linux-x86_64, X64, ubuntu-24.04, x86_64-unknown-linux-gnu) (pull_request) Failing after 11s
Rust / build-android (29.0.14206865, ubuntu-24.04, 33) (pull_request) Failing after 4s
Rust-lint / lint-linux (pull_request) Failing after 25s
Rust / build-linux (linux-aarch64, ARM64, ubuntu-24.04-arm, aarch64-unknown-linux-gnu) (pull_request) Has been cancelled
Rust / build-windows (windows-aarch64, woa64, windows-11-arm, aarch64-pc-windows-msvc) (pull_request) Has been cancelled
Rust / build-windows (windows-x86_64, win64, windows-2025, x86_64-pc-windows-msvc) (pull_request) Has been cancelled
Rust / build-macos (macos-aarch64, ARM64, aarch64-apple-darwin) (pull_request) Has been cancelled
Rust / Collect release artifacts (pull_request) Has been cancelled
libtest runs each test on a thread with the default 2 MiB stack. In a debug build, Device::new() materialises ~301 KiB of struct literals on the stack, and postcard::from_bytes::<Device> rebuilds the whole value on the stack, so any Device-constructing unit test (netplay savestate round trips etc.) peaks at several times that and aborts the ENTIRE test binary with a stack overflow, taking every other test down with it. Fix, both layers: - src/test_util.rs: with_big_stack() runs a test body on an explicitly sized 8 MiB thread (the budget the project already standardises on in .cargo/config.toml). Regression test: a device serialise/restore/clone round trip measured to overflow the 2 MiB libtest thread (SIGABRT) and pass at 8 MiB, plus a size_of::<Device>() < 700 KiB tripwire. - scripts/gate.sh: export RUST_MIN_STACK=8388608 around step 3 so the documented gate also covers Device-constructing tests that are not yet wrapped (the netplay cluster's !15/!18 tests land after this fix). Verified: cargo test --lib bare (no env) -> 1 passed; full gate -> GATE_OK with step 3 reporting 1 passed (was 0 on main).
92 lines
4.3 KiB
Bash
Executable File
92 lines
4.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# gopher64-netplay review gate (issue #16)
|
|
#
|
|
# Documented gate command (from a clean origin/main checkout):
|
|
# ./scripts/gate.sh
|
|
#
|
|
# What it does:
|
|
# 1. `git submodule update --init --recursive` (parallel-rdp,
|
|
# retroachievements/rcheevos, src/compat/sse2neon) — required by
|
|
# build.rs.
|
|
# 2. Wires the review box's user-local provisioning onto PATH/env (only
|
|
# when present; a no-op on hosts with system toolchains):
|
|
# - clang/clang++ from the local LLVM-18 root (build.rs requires
|
|
# clang for `-flto=thin`)
|
|
# - a real pkgconf + fontconfig/X11 dev pc files (the box has no
|
|
# system pkg-config/fontconfig and no sudo)
|
|
# - the provisioned cmake/ninja's OWN lib root on LD_LIBRARY_PATH
|
|
# (without it cmake dies with exit 127: librhash/libuv/libjsoncpp
|
|
# not found)
|
|
# 3. Runs the gate, as three distinguishable steps:
|
|
# a. `cargo check --all-targets` — TYPE-check everything, tests
|
|
# included (compile-only; the historical main blocker)
|
|
# b. `cargo test --no-run` — LINK every test binary (a test
|
|
# that type-checks but cannot link is still a broken gate)
|
|
# c. `cargo test --lib` — EXECUTE the headless library unit
|
|
# tests (netplay state sync etc.; see docs/build-gate.md)
|
|
#
|
|
# On AVX2-capable hardware, opt into the optimised CPU target:
|
|
# RUSTFLAGS="-C target-cpu=x86-64-v3" ./scripts/gate.sh
|
|
# (RUSTFLAGS REPLACES the config's rustflags for the whole invocation, so
|
|
# carry any other flags you need.)
|
|
set -euo pipefail
|
|
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
cd "$REPO_ROOT"
|
|
|
|
git submodule update --init --recursive
|
|
|
|
# --- Review-box provisioning ----------------------------------------------
|
|
LLVM_BIN="$HOME/local-tools/root/usr/lib/llvm-18/bin"
|
|
LLVM_BIN2="$HOME/local-tools/root/usr/bin"
|
|
FCPC="$HOME/.local/bin-fc/pkg-config"
|
|
FCROOT="$HOME/.local/fcroot/usr"
|
|
PC_DIR="$FCROOT/lib/x86_64-linux-gnu/pkgconfig"
|
|
|
|
if [ -d "$LLVM_BIN" ]; then
|
|
export PATH="$LLVM_BIN:$PATH" # clang / clang++ (build.rs needs clang)
|
|
fi
|
|
if [ -d "$LLVM_BIN2" ]; then
|
|
export PATH="$LLVM_BIN2:$PATH" # cmake, ninja, pkgconf, wayland-scanner
|
|
# cmake/ninja from this root link against librhash/libuv/libjsoncpp that
|
|
# ship in the SAME root (`usr/lib/x86_64-linux-gnu`); without that dir on
|
|
# LD_LIBRARY_PATH they die with exit 127 and cmake-rs reports it as
|
|
# "is `cmake` not installed?" — the issue #16 review bounce.
|
|
export LD_LIBRARY_PATH="$HOME/local-tools/root/usr/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
|
fi
|
|
if [ -x "$FCPC" ] && [ -d "$PC_DIR" ]; then
|
|
export PATH="$(dirname "$FCPC"):$PATH" # real pkg-config (not the pypi shim)
|
|
export PKG_CONFIG_PATH="$PC_DIR"
|
|
# SDL's cmake resolves X11 via CMake's classic FindX11 module (path
|
|
# scan), not through pkg-config — point those scans at the root too.
|
|
export CMAKE_INCLUDE_PATH="$FCROOT/include${CMAKE_INCLUDE_PATH:+:$CMAKE_INCLUDE_PATH}"
|
|
export CMAKE_LIBRARY_PATH="$FCROOT/lib/x86_64-linux-gnu${CMAKE_LIBRARY_PATH:+:$CMAKE_LIBRARY_PATH}"
|
|
export LD_LIBRARY_PATH="$FCROOT/lib/x86_64-linux-gnu${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
|
fi
|
|
if [ -d "$HOME/local-tools/root/usr/lib/llvm-18/lib" ]; then
|
|
export LIBCLANG_PATH="$HOME/local-tools/root/usr/lib/llvm-18/lib" # bindgen/clang-sys
|
|
export LD_LIBRARY_PATH="$HOME/local-tools/root/usr/lib/llvm-18/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
|
|
fi
|
|
|
|
# --- Gate: type-check, then link tests, then run the headless lib tests ----
|
|
echo "GATE step 1/3: cargo check --all-targets"
|
|
cargo check --all-targets
|
|
|
|
echo "GATE step 2/3: cargo test --no-run"
|
|
cargo test --no-run
|
|
|
|
echo "GATE step 3/3: cargo test --lib"
|
|
|
|
# Issue #23: libtest runs each test on a thread with the 2 MiB default stack,
|
|
# but debug builds of Device::new() materialise ~300 KiB of struct literals on
|
|
# the stack per construction, so any Device-constructing unit test overflows
|
|
# and aborts the WHOLE test binary. Give the test threads the same 8 MiB the
|
|
# project already standardises on for the main thread (.cargo/config.toml
|
|
# /STACK:8388608, Windows). Tests should additionally route their bodies
|
|
# through test_util::with_big_stack so they also pass under a bare
|
|
# `cargo test --lib` (see src/test_util.rs).
|
|
export RUST_MIN_STACK=8388608
|
|
cargo test --lib
|
|
|
|
echo "GATE_OK"
|
|
|