#!/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:-$(command -v rustc || echo "$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 grep -Eq 'error\[E0515\]' "$TASK_OUT/invalid-$negative.log" grep -Eq "local variable .*${invalid_local}" "$TASK_OUT/invalid-$negative.log" echo "Scoped $negative compile-fail check passed" done