mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix linking tiny overlay files (#755)
* Fix compatibility of rgblink -O and -t The -t "tiny mode" option makes ROM0 cover 0x8000 bytes, not 0x4000. The -O "overlay" option fills areas uncovered by sections with data from an overlay file. These needed to cooperate so that the calculated uncovered overlay size does not exceed the actual size of the ROM. Fixes #754 * Print link test names like asm tests do * Make the three test.sh scripts more similar
This commit is contained in:
2
test/link/overlay/a.asm
Normal file
2
test/link/overlay/a.asm
Normal file
@@ -0,0 +1,2 @@
|
||||
SECTION "0", ROM0[0]
|
||||
DS $8000
|
||||
0
test/link/overlay/out.err
Normal file
0
test/link/overlay/out.err
Normal file
BIN
test/link/overlay/out.gb
Normal file
BIN
test/link/overlay/out.gb
Normal file
Binary file not shown.
1
test/link/overlay/overlay.gb
Normal file
1
test/link/overlay/overlay.gb
Normal file
File diff suppressed because one or more lines are too long
@@ -1,37 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
export LC_ALL=C
|
||||
set -o pipefail
|
||||
|
||||
otemp=$(mktemp)
|
||||
gbtemp=$(mktemp)
|
||||
gbtemp2=$(mktemp)
|
||||
outtemp=$(mktemp)
|
||||
otemp="$(mktemp)"
|
||||
gbtemp="$(mktemp)"
|
||||
gbtemp2="$(mktemp)"
|
||||
outtemp="$(mktemp)"
|
||||
rc=0
|
||||
|
||||
trap "rm -f '$otemp' '$gbtemp' '$gbtemp2' '$outtemp'" EXIT
|
||||
|
||||
bold=$(tput bold)
|
||||
resbold=$(tput sgr0)
|
||||
red=$(tput setaf 1)
|
||||
rescolors=$(tput op)
|
||||
bold="$(tput bold)"
|
||||
resbold="$(tput sgr0)"
|
||||
red="$(tput setaf 1)"
|
||||
green="$(tput setaf 2)"
|
||||
rescolors="$(tput op)"
|
||||
|
||||
RGBASM=../../rgbasm
|
||||
RGBLINK=../../rgblink
|
||||
|
||||
startTest () {
|
||||
echo "$bold$green${i%.asm}...$rescolors$resbold"
|
||||
}
|
||||
|
||||
tryDiff () {
|
||||
if ! diff -u --strip-trailing-cr $1 $2; then
|
||||
if ! diff -u --strip-trailing-cr "$1" "$2"; then
|
||||
echo "${bold}${red}${i%.asm}.out mismatch!${rescolors}${resbold}"
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
tryCmp () {
|
||||
if ! cmp $1 $2; then
|
||||
../../contrib/gbdiff.bash $1 $2
|
||||
if ! cmp "$1" "$2"; then
|
||||
../../contrib/gbdiff.bash "$1" "$2"
|
||||
echo "${bold}${red}${i%.asm}.out.bin mismatch!${rescolors}${resbold}"
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
RGBASM=../../rgbasm
|
||||
RGBLINK=../../rgblink
|
||||
rgblink() {
|
||||
out="$(env $RGBLINK "$@")" || return $?
|
||||
if [[ -n "$out" ]]; then
|
||||
@@ -41,6 +48,7 @@ rgblink() {
|
||||
}
|
||||
|
||||
for i in *.asm; do
|
||||
startTest
|
||||
$RGBASM -o $otemp $i
|
||||
|
||||
# Some tests have variants depending on flags
|
||||
@@ -91,13 +99,16 @@ done
|
||||
|
||||
# These tests do their own thing
|
||||
|
||||
i="bank-const.asm"
|
||||
startTest
|
||||
$RGBASM -o $otemp bank-const/a.asm
|
||||
$RGBASM -o $gbtemp2 bank-const/b.asm
|
||||
rgblink -o $gbtemp $gbtemp2 $otemp > $outtemp 2>&1
|
||||
i="bank-const.asm" tryDiff bank-const/err.out $outtemp
|
||||
tryDiff bank-const/out.err $outtemp
|
||||
rc=$(($? || $rc))
|
||||
|
||||
for i in fragment-align/*; do
|
||||
startTest
|
||||
$RGBASM -o $otemp $i/a.asm
|
||||
$RGBASM -o $gbtemp2 $i/b.asm
|
||||
rgblink -o $gbtemp $otemp $gbtemp2 2>$outtemp
|
||||
@@ -110,27 +121,46 @@ for i in fragment-align/*; do
|
||||
fi
|
||||
done
|
||||
|
||||
i="high-low.asm"
|
||||
startTest
|
||||
$RGBASM -o $otemp high-low/a.asm
|
||||
rgblink -o $gbtemp $otemp
|
||||
$RGBASM -o $otemp high-low/b.asm
|
||||
rgblink -o $gbtemp2 $otemp
|
||||
i="high-low.asm" tryCmp $gbtemp $gbtemp2
|
||||
tryCmp $gbtemp $gbtemp2
|
||||
rc=$(($? || $rc))
|
||||
|
||||
i="overlay.asm"
|
||||
startTest
|
||||
$RGBASM -o $otemp overlay/a.asm
|
||||
rgblink -o $gbtemp -t -O overlay/overlay.gb $otemp > $outtemp 2>&1
|
||||
# This test does not trim its output with 'dd' because it needs to verify the correct output size
|
||||
tryDiff overlay/out.err $outtemp
|
||||
rc=$(($? || $rc))
|
||||
tryCmp overlay/out.gb $gbtemp
|
||||
rc=$(($? || $rc))
|
||||
|
||||
i="section-union/good.asm"
|
||||
startTest
|
||||
$RGBASM -o $otemp section-union/good/a.asm
|
||||
$RGBASM -o $gbtemp2 section-union/good/b.asm
|
||||
rgblink -o $gbtemp -l section-union/good/script.link $otemp $gbtemp2
|
||||
dd if=$gbtemp count=1 bs=$(printf %s $(wc -c < section-union/good/ref.out.bin)) > $otemp 2>/dev/null
|
||||
i="section-union/good.asm" tryCmp section-union/good/ref.out.bin $otemp
|
||||
tryCmp section-union/good/ref.out.bin $otemp
|
||||
rc=$(($? || $rc))
|
||||
|
||||
i="section-union/fragments.asm"
|
||||
startTest
|
||||
$RGBASM -o $otemp section-union/fragments/a.asm
|
||||
$RGBASM -o $gbtemp2 section-union/fragments/b.asm
|
||||
rgblink -o $gbtemp $otemp $gbtemp2
|
||||
dd if=$gbtemp count=1 bs=$(printf %s $(wc -c < section-union/fragments/ref.out.bin)) > $otemp 2>/dev/null
|
||||
i="section-union/fragments.asm" tryCmp section-union/fragments/ref.out.bin $otemp
|
||||
tryCmp section-union/fragments/ref.out.bin $otemp
|
||||
rc=$(($? || $rc))
|
||||
|
||||
for i in section-union/*.asm; do
|
||||
$RGBASM -o $otemp $i
|
||||
startTest
|
||||
$RGBASM -o $otemp $i
|
||||
$RGBASM -o $gbtemp2 $i -DSECOND
|
||||
if rgblink $otemp $gbtemp2 2>$outtemp; then
|
||||
echo -e "${bold}${red}$i didn't fail to link!${rescolors}${resbold}"
|
||||
|
||||
Reference in New Issue
Block a user