Files
gw-basic-2026/tests/run_freedos_qemu.sh
T
Eremey Valetov da1e6cebf1 CI: fix dos-cross-compile env; codegen: accept concat in CVI/CVS/CVD/cmp
- .github/workflows/ci.yml: the dos-cross-compile job failed on the
  first push because build_dos.sh sources $HOME/openwatcom-v2/setvars.sh
  if WATCOM is unset, but that file isn't part of the OpenWatcom V2
  snapshot — I'd been creating it locally by hand.  Add a "Configure
  OpenWatcom env" step that generates setvars.sh after extraction (so
  build_dos.sh works) AND exports WATCOM/PATH/INCLUDE via $GITHUB_ENV
  (so subsequent steps work even if setvars.sh sourcing changes).
  Also stash both DOS binaries before the next-mode clean wipes them,
  so the artifact upload actually has both .exe files.

- src/codegen.c: switch the four remaining emit_str_atom callers
  (CVI/CVS/CVD function args + string-comparison left/right) to
  emit_str_expr.  Now `CVS(A$+B$)` and `A$+B$ < C$` accept
  concatenation in their string operands; previously the atom-level
  caller stopped at the first identifier and the trailing `+` confused
  downstream parsing.  Verified: CVS(MKS$(3.14)+MKS$(0)) round-trips
  to 3.14 in both interpreter and compiled binary.  All 72 interpreter
  + 63 compiler tests still pass.

- docs/getting-started.md: document that gwbasic-compile auto-numbers
  unnumbered direct-mode lines (last_num + 10) so scratchpad-style
  programs compile without manual renumbering.

- tests/run_freedos_qemu.sh: helper for going through the manual TUI
  checklist on bare FreeDOS.  Modern qemu-kvm doesn't expose -fda on
  the default machine type and fat:rw: protocol is gone, so a fully
  automated FreeDOS smoke isn't tractable from userspace; this script
  builds a FAT data image (mtools), attaches it as -hdb to the FreeDOS
  qcow2, and points the user at the manual sequence in the script
  header.  The DOSBox-X harness (run_dos_smoke.sh) remains the
  automated DOS smoke.
2026-05-04 18:16:21 -04:00

75 lines
2.6 KiB
Bash
Executable File

#!/bin/bash
# Launch a FreeDOS 1.4 QEMU VM with gwbasic16.exe and the smoke test on a
# FAT disk image, for manual verification of the BIOS-rendered TUI.
#
# Usage: bash tests/run_freedos_qemu.sh
#
# The script is *not* a self-contained automated smoke test — DOS doesn't
# pipe console input cleanly enough through QEMU's -serial stdio for that
# to be reliable, and modern qemu-kvm builds don't expose -fda on the
# default machine type. Use tests/run_dos_smoke.sh (DOSBox-X) for the
# automated smoke; this script is for going through the manual TUI
# checklist in docs/getting-started.md against bare FreeDOS.
#
# Once FreeDOS boots, press a key to skip the boot menu (or wait for the
# default), then at the C:\> prompt:
#
# C:\> D:
# D:\> DIR (sanity-check the FAT image is mounted)
# D:\> GWBASIC.EXE SMOKE.BAS (runs the non-interactive smoke)
# D:\> TYPE OUT.TXT (compare against tests/expected/dos_smoke.expected)
# D:\> GWBASIC.EXE (no args -- exercises the TUI editor)
#
# Quit QEMU: Ctrl-Alt-G then close the window, or in -nographic mode use
# the QEMU monitor (Ctrl-A then X).
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
EXE="$PROJECT_DIR/gwbasic16.exe"
SMOKE="$SCRIPT_DIR/dos_smoke.bas"
FREEDOS_IMG="${FREEDOS_IMG:-$HOME/DOS/images/freedos.qcow2}"
QEMU="${QEMU:-/usr/libexec/qemu-kvm}"
DATA_IMG="$HOME/.cache/gw-basic-2026/freedos_d.img"
if [ ! -x "$EXE" ]; then
echo "ERROR: $EXE not found. Run ./build_dos.sh 16 first." >&2
exit 1
fi
if [ ! -f "$FREEDOS_IMG" ]; then
echo "ERROR: FreeDOS qcow2 not found at $FREEDOS_IMG." >&2
echo "Override with FREEDOS_IMG=/path/to/freedos.qcow2" >&2
exit 1
fi
if [ ! -x "$QEMU" ]; then
echo "ERROR: qemu-kvm not found at $QEMU. Override with QEMU=/path/to/qemu" >&2
exit 1
fi
echo "==> Building FAT data image at $DATA_IMG"
mkdir -p "$(dirname "$DATA_IMG")"
dd if=/dev/zero of="$DATA_IMG" bs=1M count=8 status=none
mkfs.vfat "$DATA_IMG" >/dev/null
mcopy -i "$DATA_IMG" "$EXE" ::GWBASIC.EXE
mcopy -i "$DATA_IMG" "$SMOKE" ::SMOKE.BAS
sed 's/$/\r/' "$SMOKE" > /tmp/_smoke_crlf.bas
mcopy -i "$DATA_IMG" -o /tmp/_smoke_crlf.bas ::SMOKE.BAS
rm -f /tmp/_smoke_crlf.bas
mdir -i "$DATA_IMG"
echo
echo "==> Launching FreeDOS QEMU. See header of $0 for the manual test sequence."
echo "==> Quit: Ctrl-Alt-G, close window. Press Enter to continue."
read -r
exec "$QEMU" \
-machine pc \
-cpu max \
-m 32 \
-hda "$FREEDOS_IMG" \
-hdb "$DATA_IMG" \
-nic none \
-boot c \
-display gtk \
-rtc base=localtime