#! /bin/bash # Usage of the works is permitted provided that this # instrument is retained with the works, so that any entity # that uses the works is notified of this instrument. # # DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY. . cfg.sh if [ -n "$LMACROS_DIR" ]; then { options_i_lmacros=-I"${LMACROS_DIR%/}"/ } fi if [ -n "$LDOSBOOT_DIR" ]; then { options_i_ldosboot=-I"${LDOSBOOT_DIR%/}"/ } fi if [ -n "$SCANPTAB_DIR" ]; then { options_i_scanptab=-I"${SCANPTAB_DIR%/}"/ } fi if [ -n "$BOOTIMG_DIR" ]; then { options_i_bootimg=-I"${BOOTIMG_DIR%/}"/ } fi if [ -n "$LDEBUG_DIR" ]; then { options_i_ldebug=-I"${LDEBUG_DIR%/}"/ } fi bpe=12 echo -ne 'failure\r\n' > result.txt nasm "${LDOSBOOT_DIR%/}"/boot.asm -w-user \ -D_LOAD_NAME="'TESTWRIT'" -D_LOAD_EXT="'SYS'" -D_FAT$bpe \ "$@" \ "$options_i_lmacros" \ -D_MAP=boot${bpe}tw.map -l boot${bpe}tw.lst -o boot${bpe}tw.bin && nasm "${LDOSBOOT_DIR%/}"/testwrit.asm \ "$options_i_lmacros" \ -o testwrit.bin -l testwrit.lst && nasm "${LDOSBOOT_DIR%/}"/iniload.asm -w-user \ "$options_i_lmacros" \ "$options_i_ldosboot" \ "$options_i_scanptab" \ -D_PAYLOAD_FILE="'testwrit.bin'" -o testwrit.sys -l testwrin.lst \ -D_INILOAD_SIGNATURE='"TW"' && nasm "${BOOTIMG_DIR%/}"/bootimg.asm \ "$options_i_lmacros" \ "$options_i_bootimg" \ -o diskette.img -l diskette.lst \ -D_PAYLOADFILE="testwrit.sys,result.txt" -D_BOOTFILE="'boot12tw.bin'" && nasm "${LDOSBOOT_DIR%/}"/boot.asm -w-user \ "$options_i_lmacros" \ -D_LOAD_NAME="'LDEBUG'" -D_LOAD_EXT="'COM'" \ -D_MAP=boot12db.map -l boot12db.lst -o boot12db.bin && nasm "${BOOTIMG_DIR%/}"/bootimg.asm \ "$options_i_ldebug" \ "$options_i_lmacros" \ "$options_i_bootimg" \ -o diskldbg.img -l diskldbg.lst \ -D_PAYLOADFILE="ldebug.com" -D_BOOTFILE="'boot12db.bin'" && timeout --foreground 10 dosemu -input \ "$(echo -ne 'boot fdb\rif (rc) then boot quit\rq\r')" \ -I "floppy { device diskldbg.img }" \ -I "floppy { device diskette.img }" \ -A -dumb 2> /dev/null > result.log rc=$? stty sane if ((rc == 124)) then echo timeout fi if [[ "$(mtype -t -i diskette.img ::RESULT.TXT 2> /dev/null)" == success ]] then echo success else echo failure, log contains: cat result.log | perl -e ' my %errorlookup = ( V => "Check value mismatch", F => "File not found", E => "Not enough file data", R => "Disk read error", B => "Bad chain / bad FS", M => "Out of memory", I => "FSIBOOT error", S => "Fix sector size mismatch", C => "Fix cluster size mismatch", ); my $empty = 1; while (<>) { next if $empty and /^\s*$/; next if /^(dosemu2 2|Configured: |Please test against)/; next if /^(Get the latest code|Submit Bugs via|Ask for help in)/; $empty = 0; if (/^([A-Z])\x7/ and defined $errorlookup{$1}) { s/^(.).//g; print "lDOS boot error condition letter \"$1\" = $errorlookup{$1}\n"; s/[\x7\n]//g; s/^\s*$//; next if /^(dosemu2 2|Configured: |Please test against)/; next if /^(Get the latest code|Submit Bugs via|Ask for help in)/; print; print "\n" unless /^$/; } else { s/[\x7\n]//g; print; print "\n"; }; };' fi