Files
nvdriver/tools/test_timeout_runtime.sh
LIghtJUNction 32c8728037 Migrate the workspace and kernel crates to Rust edition 2024
Mechanical, behavior-neutral: edition/resolver keys, unsafe extern blocks,
unsafe(no_mangle)/unsafe(export_name), unsafe blocks inside unsafe fn,
r#gen renames, --edition flags in Makefiles/tools, rustfmt style_edition
pinned to 2021 so formatting stays edition-independent, and clippy
collapsible_if allowed workspace-wide (let-chain churn).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-12-02 01:52:38 +08:00

28 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
set -eu
TASK_ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$TASK_ROOT"
TASK_OUT="$TASK_ROOT/target/timeout-runtime"
mkdir -p "$TASK_OUT"
RUSTC=${RUSTC:-$HOME/.cargo/bin/rustc}
cc -std=c11 -Wall -Wextra -Werror -c tests/timeout-runtime/ffi.c -o "$TASK_OUT/cpu.o"
cc -std=c11 -D_GNU_SOURCE -Wall -Wextra -Werror -c tests/pf-software/registry.c -o "$TASK_OUT/registry.o"
cc -std=c11 -pthread -Wall -Wextra -Werror -c tests/thread-state/ffi.c -o "$TASK_OUT/thread.o"
"$RUSTC" --edition=2024 --crate-name nv_rs_abi --crate-type=rlib src/common/abi/src/lib.rs -o "$TASK_OUT/libnv_rs_abi.rlib"
"$RUSTC" --edition=2024 --crate-name nv_rs_core --crate-type=rlib src/nvidia/src/lib.rs --extern nv_rs_abi="$TASK_OUT/libnv_rs_abi.rlib" -o "$TASK_OUT/libnv_rs_core.rlib"
"$RUSTC" --edition=2024 --test --crate-name nv_timeout_runtime tests/timeout-runtime/fixture.rs --extern nv_rs_abi="$TASK_OUT/libnv_rs_abi.rlib" --extern nv_rs_core="$TASK_OUT/libnv_rs_core.rlib" -L dependency="$TASK_OUT" -C link-arg="$TASK_OUT/cpu.o" -C link-arg="$TASK_OUT/registry.o" -C link-arg="$TASK_OUT/thread.o" -C link-arg=-pthread -o "$TASK_OUT/fixture"
"$TASK_OUT/fixture"
for negative in identity record; do
case "$negative" in
identity) invalid_cfg=nv_rs_timeout_bad_lifetime; invalid_local=binding ;;
record) invalid_cfg=nv_rs_timeout_bad_record; invalid_local=record ;;
esac
if "$RUSTC" --edition=2024 --test --cfg "$invalid_cfg" --crate-name nv_timeout_runtime_negative tests/timeout-runtime/fixture.rs --extern nv_rs_abi="$TASK_OUT/libnv_rs_abi.rlib" --extern nv_rs_core="$TASK_OUT/libnv_rs_core.rlib" -L dependency="$TASK_OUT" -o "$TASK_OUT/invalid-$negative" 2>"$TASK_OUT/invalid-$negative.log"; then
echo "ERROR: escaping $negative borrow was accepted" >&2
exit 1
fi
rg -q 'error\[E0515\]' "$TASK_OUT/invalid-$negative.log"
rg -q "local variable .*${invalid_local}" "$TASK_OUT/invalid-$negative.log"
echo "Scoped $negative compile-fail check passed"
done