Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 33 additions & 18 deletions tools/bridge-lock-selftest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,24 +259,26 @@ else
fi

# The drive lock degrades without flock(1) when nothing is on the wire: one
# warning and 0, unlocked. On a bridged backend it stays strict. Through
# warning and 0, unlocked. On a bridged backend it stays strict, and an
# omitted backend is refused rather than read as unbridged. Through
# amiberry-run.sh a SLIRP run gets past the drive with the warning; its 2 is
# rig_claim_port's, which needs flock(1) on main as well.
dn=$(PATH="$S/noflock" AMINETXDUO_BRIDGE_LOCK="$S/bridge.lock" bash -c '
. "$1/tools/emu-rig-lock.sh"
rig_claim_drive "$2/nf-drive" nf slirp 2> "$2/nf-slirp.err"; a=$?
rig_claim_drive "$2/nf-drive" nf ens18 2> /dev/null; b=$?
echo "$a,$b"' _ "$ROOT" "$S")
rig_claim_drive "$2/nf-drive" nf 2> /dev/null; c=$?
echo "$a,$b,$c"' _ "$ROOT" "$S")
: > "$EV"
PATH="$S/noflock" run C noflockslirp slirp
if [ "$dn" = 0,2 ] &&
if [ "$dn" = 0,2,2 ] &&
grep -q '^no flock: drive .*nf-drive not locked; do not run two of this tag at once$' \
"$S/nf-slirp.err" &&
grep -q '^no flock: drive .*amiberry-testhd-ifsurvive not locked' "$S/noflockslirp.out" &&
! grep -q 'drive lock' "$S/noflockslirp.out"; then
kv noflock_drive ok
else
kv noflock_drive "wrong:slirp,bridged=$dn:run=$(cat "$S/noflockslirp.rc")"
kv noflock_drive "wrong:slirp,bridged,omitted=$dn:run=$(cat "$S/noflockslirp.rc")"
fi

: > "$EV"
Expand Down Expand Up @@ -654,39 +656,52 @@ else
fi
echo "lock_order_took_s=$took"

# EVERY LAUNCHER, statically: any script that starts the emulator claims its
# EVERY LAUNCHER, statically: any script that starts an emulator claims its
# drive before its first destructive step (a wipe, an extraction, a mkdir or
# cp restage, the shared Workbench build, Xvfb, tcpdump, a kill or the
# emulator), and a bridged one claims the bridge after the drive and before
# the emulator. Found by what they do, so a new launcher with no claim fails
# here rather than waiting for a reviewer to spot it.
START='(exec|setsid) +(setsid +)?"[$]AMIBERRY"|"[$]AMIBERRY" +(--log +)?-f|start_emulator "'
DESTRUCTIVE_ALL="$DESTRUCTIVE|lha +x|tar x"
# emulator) and before the emulator itself, and a bridged one claims the
# bridge after the drive and before the emulator. Found by what they do, so
# a new launcher with no claim fails here rather than waiting for a reviewer
# to spot it. A line run through ssh acts on the remote host, not on this
# host's drive, and is not a destructive step here.
#
# Emulator -> the line that starts it. Discovery is the union of the rows;
# a launcher's emulator line is its first non-comment match of any row.
declare -A EMU_START=(
[amiberry]='(exec|setsid) +(setsid +)?"[$]AMIBERRY"|"[$]AMIBERRY" +(--log +)?-f|start_emulator "'
[winuae]='ssh .*powershell .*run[.]ps1 -Config '
)
# Launchers discovery must find; a pattern that drifts from one fails here.
KNOWN_LAUNCHERS="tools/amiberry-run.sh install/test/run-workbench.sh tools/winuae-run.sh"
START=""
for emu in "${!EMU_START[@]}"; do START="${START:+$START|}${EMU_START[$emu]}"; done
DESTRUCTIVE_ALL="$DESTRUCTIVE|lha +x|tar x|$START"
lo_bad=""
launchers=$(cd "$ROOT" && grep -rlE "$START" --include='*.sh' tools tests install |
grep -v '^tools/bridge-lock-selftest\.sh$' | sort)
for f in $launchers; do
from=1
[ "$f" != tests/tools/console-instance.sh ] ||
from=$(grep -n '^esac' "$ROOT/$f" | head -1 | cut -d: -f1)
first() { awk -v from="$from" -v re="$1" '
NR >= from && $0 !~ /^[[:space:]]*#/ && $0 ~ re { print NR; exit }' "$ROOT/$f"; }
first() { awk -v from="$from" -v re="$1" -v skip="${2:-^$}" '
NR >= from && $0 !~ /^[[:space:]]*#/ && $0 !~ skip && $0 ~ re { print NR; exit }' "$ROOT/$f"; }
d=$(first '^[[:space:]]*rig_claim_drive ')
b=$(first '^[[:space:]]*rig_claim_bridge ')
x=$(first "$DESTRUCTIVE_ALL")
x=$(first "$DESTRUCTIVE_ALL" '^[[:space:]]*ssh ')
e=$(first "$START")
echo "launcher_$(basename "$f" .sh)=drive:${d:-none} bridge:${b:-none} first_destructive:${x:-none} emulator:${e:-none}"
[ -n "$e" ] || { lo_bad="$lo_bad $f:no-emulator-start"; continue; }
[ -n "$d" ] || { lo_bad="$lo_bad $f:no-drive-claim"; continue; }
[ "$d" -lt "$e" ] || lo_bad="$lo_bad $f:drive($d)>=emulator($e)"
[ -z "$x" ] || [ "$d" -lt "$x" ] || lo_bad="$lo_bad $f:drive($d)>=destructive($x)"
if [ -n "$b" ]; then
[ "$d" -lt "$b" ] || lo_bad="$lo_bad $f:bridge($b)-before-drive($d)"
[ -z "$e" ] || [ "$b" -lt "$e" ] || lo_bad="$lo_bad $f:bridge($b)>=emulator($e)"
[ "$b" -lt "$e" ] || lo_bad="$lo_bad $f:bridge($b)>=emulator($e)"
fi
done
case "$launchers" in
*tools/amiberry-run.sh*install/test/run-workbench.sh*|*install/test/run-workbench.sh*tools/amiberry-run.sh*) ;;
*) lo_bad="$lo_bad discovery-missed-known-launchers" ;;
esac
for f in $KNOWN_LAUNCHERS; do
grep -qxF "$f" <<< "$launchers" || lo_bad="$lo_bad $f:not-discovered"
done
if [ -z "$lo_bad" ]; then
kv launcher_order ok
else
Expand Down
1 change: 1 addition & 0 deletions tools/emu-rig-lock.sh
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ rig_drive_path() { # dir

rig_claim_drive() { # dir who backend [wait]
[ -n "${1:-}" ] || { echo "rig_claim_drive: no drive named" >&2; return 2; }
[ -n "${3:-}" ] || { echo "rig_claim_drive: no backend given" >&2; return 2; }
[ -z "$RIG_DRIVE_FD" ] || return 0
if ! rig_have_flock; then
rig_backend_bridged "${3:-}" && { rig_no_flock; return 2; }
Expand Down
11 changes: 11 additions & 0 deletions tools/winuae-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ HD="$ROOT/build/winuae-testhd-$TAG"
RRUN="$RROOT\\run\\$TAG"
RRUN_FWD="$RROOT_FWD/run/$TAG"

# THE DRIVE, before the staging below wipes it and before the copy back
# wipes it again (tools/emu-rig-lock.sh, rig_claim_drive). Only the local
# staging directory is arbitrated here: the guest's network, bridged or not,
# is on $HOST, where this host's locks mean nothing -- hence no bridge claim
# and backend none, which degrades with a warning rather than refusing on a
# host with no flock(1).
# shellcheck source=emu-rig-lock.sh
. "$ROOT/tools/emu-rig-lock.sh"
rig_claim_drive "$HD" "winuae $TAG (${AMINETXDUO_WINUAE_A2065:-slirp} on $HOST) in $ROOT" \
none || exit $?

# ------------------------------------------------------------------- models --
#
# chipmem_size and friends are in 512 KB units despite what WinUAE's own help
Expand Down
Loading