mdoc man page covering all modes and the OTS/ingest long options, verified with groff and NetBSD mandoc. CMake installs the binary and the man page (guarded against add_subdirectory embedding). Also corrects the stale direction-1 comment in the DOSBox round-trip script: multi-file archives created by v3 have extracted fine in the original since the custom-Huffman-tree fix.
185 lines
4.9 KiB
Bash
Executable File
185 lines
4.9 KiB
Bash
Executable File
#!/bin/bash
|
|
# Cross-tool round-trip test: original UC2 Pro -> UC2 v3 via DOSBox-X
|
|
#
|
|
# Tests both directions: UC2 v3 creates a multi-file archive that the
|
|
# original extracts (Direction 1), and the original creates an archive
|
|
# that UC2 v3 extracts (Direction 2). Multi-file Direction 1 has worked
|
|
# since the custom-Huffman-tree fix; an earlier version of this comment
|
|
# documented a hang that no longer reproduces.
|
|
#
|
|
# Usage: roundtrip_dosbox.sh <uc2-cli> <uc2pro.exe> <corpus-dir>
|
|
|
|
set -euo pipefail
|
|
|
|
UC2_CLI="$1"
|
|
UC2PRO="$2"
|
|
CORPUS="$3"
|
|
|
|
FILES=(hello.txt textfile.txt allbytes.bin random.bin zeros.bin)
|
|
|
|
if ! flatpak info com.dosbox_x.DOSBox-X &>/dev/null; then
|
|
echo "SKIP: DOSBox-X not installed (flatpak com.dosbox_x.DOSBox-X)"
|
|
exit 0
|
|
fi
|
|
|
|
WORK="$(mktemp -d "$HOME/.cache/uc2-dosbox-test.XXXXXX")"
|
|
trap 'rm -rf "$WORK"' EXIT
|
|
|
|
mkdir -p "$WORK/corpus" "$WORK/out" "$WORK/output"
|
|
for f in "${FILES[@]}"; do
|
|
cp "$CORPUS/$f" "$WORK/corpus/"
|
|
done
|
|
cp "$UC2PRO" "$WORK/uc2pro.exe"
|
|
|
|
# --- Session 1: Extract UC2 Pro distribution from SFX ---
|
|
echo "=== Session 1: Extracting UC2 Pro tools from SFX ==="
|
|
cat > "$WORK/dosbox.conf" <<DOSBOXCFG
|
|
[sdl]
|
|
output=none
|
|
fullscreen=false
|
|
[dosbox]
|
|
memsize=16
|
|
machine=svga_s3
|
|
[cpu]
|
|
cycles=max
|
|
[autoexec]
|
|
mount c: $WORK
|
|
c:
|
|
uc2pro UC2DIST
|
|
exit
|
|
DOSBOXCFG
|
|
|
|
# SFX decompression takes 3-8 minutes depending on host CPU speed
|
|
timeout 600 flatpak run com.dosbox_x.DOSBox-X \
|
|
-conf "$WORK/dosbox.conf" -nopromptfolder 2>/dev/null || true
|
|
|
|
UC2DIST_COUNT=$(ls "$WORK/UC2DIST/" 2>/dev/null | wc -l)
|
|
if [ ! -f "$WORK/UC2DIST/UC.EXE" ] || [ "$UC2DIST_COUNT" -lt 22 ]; then
|
|
echo "FAIL: UC2 Pro SFX extraction incomplete ($UC2DIST_COUNT/22 files)"
|
|
exit 1
|
|
fi
|
|
echo " UC.EXE extracted ($(wc -c < "$WORK/UC2DIST/UC.EXE") bytes, $UC2DIST_COUNT files)"
|
|
|
|
# --- Direction 1: UC2 v3 creates, original extracts (multi-file) ---
|
|
echo "=== Direction 1: UC2 v3 creates -> original extracts ==="
|
|
DIR1_FILES=(hello.txt textfile.txt allbytes.bin random.bin)
|
|
"$UC2_CLI" -w "$WORK/v3multi.uc2" \
|
|
"$WORK/corpus/hello.txt" "$WORK/corpus/textfile.txt" \
|
|
"$WORK/corpus/allbytes.bin" "$WORK/corpus/random.bin"
|
|
mkdir -p "$WORK/dir1_out"
|
|
cat > "$WORK/dosbox.conf" <<DOSBOXCFG
|
|
[sdl]
|
|
output=none
|
|
fullscreen=false
|
|
[dosbox]
|
|
memsize=16
|
|
machine=svga_s3
|
|
[cpu]
|
|
cycles=max
|
|
[autoexec]
|
|
mount c: $WORK
|
|
c:
|
|
cd C:\\DIR1_OUT
|
|
C:\\UC2DIST\\UC eF C:\\V3MULTI *.*
|
|
echo DIR1 > C:\\DIR1.TXT
|
|
exit
|
|
DOSBOXCFG
|
|
|
|
timeout 120 flatpak run com.dosbox_x.DOSBox-X \
|
|
-conf "$WORK/dosbox.conf" -nopromptfolder 2>/dev/null || true
|
|
|
|
# --- Session 2: original creates archive ---
|
|
echo "=== Session 2 (Direction 2): UC2 Pro creates archive ==="
|
|
cat > "$WORK/dosbox.conf" <<DOSBOXCFG
|
|
[sdl]
|
|
output=none
|
|
fullscreen=false
|
|
[dosbox]
|
|
memsize=16
|
|
machine=svga_s3
|
|
[cpu]
|
|
cycles=max
|
|
[autoexec]
|
|
mount c: $WORK
|
|
c:
|
|
cd C:\\UC2DIST
|
|
UC a C:\\OUT\\DOSTEST C:\\CORPUS\\*.*
|
|
echo DONE > C:\\MARKER.TXT
|
|
exit
|
|
DOSBOXCFG
|
|
|
|
timeout 300 flatpak run com.dosbox_x.DOSBox-X \
|
|
-conf "$WORK/dosbox.conf" -nopromptfolder 2>/dev/null || true
|
|
|
|
if [ ! -f "$WORK/MARKER.TXT" ]; then
|
|
echo "FAIL: DOSBox session did not complete"
|
|
exit 1
|
|
fi
|
|
|
|
DOS_ARCHIVE=""
|
|
for candidate in "$WORK/out/DOSTEST.UC2" "$WORK/out/dostest.uc2"; do
|
|
[ -f "$candidate" ] && DOS_ARCHIVE="$candidate" && break
|
|
done
|
|
if [ -z "$DOS_ARCHIVE" ]; then
|
|
echo "FAIL: UC2 Pro did not create DOSTEST.UC2"
|
|
exit 1
|
|
fi
|
|
echo " Archive created: $(wc -c < "$DOS_ARCHIVE") bytes"
|
|
|
|
# --- Extract with UC2 v3 and verify ---
|
|
echo "=== Extracting with UC2 v3 ==="
|
|
"$UC2_CLI" -d "$WORK/output" "$DOS_ARCHIVE"
|
|
|
|
FAIL=0
|
|
for f in "${FILES[@]}"; do
|
|
upper=$(echo "$f" | tr '[:lower:]' '[:upper:]')
|
|
extracted=""
|
|
for candidate in "$WORK/output/$f" "$WORK/output/$upper"; do
|
|
[ -f "$candidate" ] && extracted="$candidate" && break
|
|
done
|
|
if [ -z "$extracted" ]; then
|
|
echo " FAIL: $f not extracted"
|
|
FAIL=1
|
|
continue
|
|
fi
|
|
if cmp -s "$CORPUS/$f" "$extracted"; then
|
|
echo " OK: $f"
|
|
else
|
|
echo " FAIL: $f content mismatch"
|
|
FAIL=1
|
|
fi
|
|
done
|
|
|
|
# --- Verify Direction 1 (multi-file) ---
|
|
echo "--- Verifying Direction 1 (UC2 v3 -> original) ---"
|
|
if [ -f "$WORK/DIR1.TXT" ]; then
|
|
for f in "${DIR1_FILES[@]}"; do
|
|
upper=$(echo "$f" | tr '[:lower:]' '[:upper:]')
|
|
extracted=""
|
|
for candidate in "$WORK/dir1_out/$upper" "$WORK/dir1_out/$f"; do
|
|
[ -f "$candidate" ] && extracted="$candidate" && break
|
|
done
|
|
if [ -z "$extracted" ]; then
|
|
echo " FAIL: $f not extracted by original (Direction 1)"
|
|
FAIL=1
|
|
elif cmp -s "$CORPUS/$f" "$extracted"; then
|
|
echo " OK: $f (Direction 1)"
|
|
else
|
|
echo " FAIL: $f content mismatch (Direction 1)"
|
|
FAIL=1
|
|
fi
|
|
done
|
|
else
|
|
echo " FAIL: Direction 1 DOSBox session incomplete"
|
|
FAIL=1
|
|
fi
|
|
|
|
if [ $FAIL -ne 0 ]; then
|
|
echo "FAILED: some files did not survive cross-tool round-trip"
|
|
echo "Work directory preserved at: $WORK"
|
|
trap - EXIT
|
|
exit 1
|
|
fi
|
|
|
|
echo "PASSED: all files verified (both directions)"
|