76 lines
2.1 KiB
Bash
Executable File
76 lines
2.1 KiB
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
script_dir=$(CDPATH= cd -- "$(dirname "$0")" && pwd)
|
|
repo_root=$(CDPATH= cd -- "$script_dir/../.." && pwd)
|
|
workdir=$(mktemp -d /tmp/fruix-guile-subprocess.XXXXXX)
|
|
trap 'rm -rf "$workdir"' EXIT INT TERM
|
|
|
|
if [ -n "${GUILE_BIN:-}" ]; then
|
|
guile_bin=$GUILE_BIN
|
|
elif command -v guile3 >/dev/null 2>&1; then
|
|
guile_bin=$(command -v guile3)
|
|
elif command -v guile-3.0 >/dev/null 2>&1; then
|
|
guile_bin=$(command -v guile-3.0)
|
|
else
|
|
echo "Unable to find GUILE_BIN, guile3, or guile-3.0 in PATH" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -x "$guile_bin" ]; then
|
|
echo "Guile binary is not executable: $guile_bin" >&2
|
|
exit 1
|
|
fi
|
|
|
|
guile_prefix=$(CDPATH= cd -- "$(dirname "$guile_bin")/.." && pwd)
|
|
guile_lib_dir=$guile_prefix/lib
|
|
if [ -e "$guile_lib_dir/libguile-3.0.so.1" ]; then
|
|
if [ -n "${LD_LIBRARY_PATH:-}" ]; then
|
|
export LD_LIBRARY_PATH="$guile_lib_dir:$LD_LIBRARY_PATH"
|
|
else
|
|
export LD_LIBRARY_PATH="$guile_lib_dir"
|
|
fi
|
|
fi
|
|
|
|
ulimit -c 0 || true
|
|
|
|
cc -Wall -Wextra -O2 "$repo_root/tests/guile/posix-spawn-freebsd-diagnostics.c" \
|
|
-o "$workdir/posix-spawn-freebsd-diagnostics"
|
|
|
|
printf 'Using Guile: %s\n' "$guile_bin"
|
|
printf 'Using LD_LIBRARY_PATH: %s\n' "${LD_LIBRARY_PATH:-<unset>}"
|
|
printf '== Native posix_spawn diagnostics ==\n'
|
|
"$workdir/posix-spawn-freebsd-diagnostics"
|
|
|
|
expect_crash=${EXPECT_GUILE_SUBPROCESS_CRASH:-1}
|
|
|
|
run_guile_case() {
|
|
name=$1
|
|
code=$2
|
|
set +e
|
|
"$guile_bin" -c "$code" >/dev/null 2>&1
|
|
rc=$?
|
|
set -e
|
|
printf '%s exit=%s\n' "$name" "$rc"
|
|
if [ "$expect_crash" -eq 1 ]; then
|
|
[ "$rc" -eq 139 ]
|
|
else
|
|
[ "$rc" -eq 0 ]
|
|
fi
|
|
}
|
|
|
|
if [ "$expect_crash" -eq 1 ]; then
|
|
printf '== Guile subprocess crash repro ==\n'
|
|
else
|
|
printf '== Guile subprocess validation (expect success) ==\n'
|
|
fi
|
|
run_guile_case system-star '(system* "/usr/bin/true")'
|
|
run_guile_case spawn '(spawn "/usr/bin/true" (list "/usr/bin/true"))'
|
|
run_guile_case open-pipe-star '(use-modules (ice-9 popen)) (open-pipe* OPEN_READ "/usr/bin/true")'
|
|
|
|
if [ "$expect_crash" -eq 1 ]; then
|
|
printf 'known FreeBSD Guile subprocess crash profile reproduced\n'
|
|
else
|
|
printf 'Guile subprocess helpers succeeded as expected\n'
|
|
fi
|