63 lines
2.2 KiB
Bash
Executable file
63 lines
2.2 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# verify-win16-serial.sh - both-directions RS-232 gate for the Win16 port.
|
|
#
|
|
# Runs SERTEST.EXE (examples/sertest: banner, then echo) on Windows 3.11
|
|
# under DOSBox (scripts/lib/win16Gate.sh) with COM1 as a nullmodem
|
|
# connecting to the host peer (scripts/lib/serialLoopPeer.py), which waits
|
|
# for the banner, sends a probe and expects it echoed. That exercises the
|
|
# chain: JoeyLib's Win16 serial HAL -> OpenComm/WriteComm/ReadComm ->
|
|
# KPCOMM.DRV (the communications driver JoeyLib's Windows runs with in place
|
|
# of COMM.DRV) and Windows' virtual COM device -> DOSBox's UART -> host.
|
|
#
|
|
# Usage: scripts/verify-win16-serial.sh
|
|
# Env: WIN16_SERIAL_PORT TCP port the peer listens on (default 6804)
|
|
# Requires: Windows on DOSBox (install.sh install emulator:win16), python3;
|
|
# build/win16/bin/SERTEST.EXE (make win16).
|
|
|
|
set -uo pipefail
|
|
|
|
repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
|
source "$repo/scripts/lib/joeyEnv.sh"
|
|
source "$repo/scripts/lib/win16Gate.sh"
|
|
|
|
label=verify-win16-serial
|
|
win16Need
|
|
program=$(joeyExampleProgram sertest win16)
|
|
[ -f "$program" ] || { echo "$label: build SERTEST.EXE first (make win16)" >&2; exit 2; }
|
|
port="${WIN16_SERIAL_PORT:-6804}"
|
|
# The peer's budget: Windows' boot, then the banner and the echo.
|
|
wall=60
|
|
|
|
work=$(mktemp -d -t joeylib-win16-serial.XXXXXX)
|
|
peerPid=""
|
|
cleanup() {
|
|
joeyStop "$peerPid"
|
|
win16Stop
|
|
rm -rf "$work"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
python3 "$repo/scripts/lib/serialLoopPeer.py" tcp-server "$port" "$wall" > "$work/peer.log" 2>&1 &
|
|
peerPid=$!
|
|
sleep 1
|
|
mkdir -p "$work/program"
|
|
cp "$program" "$work/program/SERTEST.EXE"
|
|
win16Stage "$work" "$work/program" SERTEST.EXE
|
|
# transparent:1 -- data bytes only: DOSBox's in-band escapes for the control
|
|
# lines would reach the plain TCP peer as data.
|
|
WIN16_DOSBOX_ARGS=(--set "serial1=nullmodem server:127.0.0.1 port:$port transparent:1")
|
|
win16Start "$work"
|
|
wait "$peerPid"
|
|
rc=$?
|
|
peerPid=""
|
|
cat "$work/peer.log"
|
|
if [ "$rc" -eq 0 ]; then
|
|
echo "$label: PASS (banner out, probe echoed through COM1)"
|
|
else
|
|
echo "$label: FAIL" >&2
|
|
fi
|
|
exit "$rc"
|