mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Change behavior of merging FRAGMENTs to constrain each fragment individually
Additionally, remove the deprecated merging of non-fragment SECTIONs
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
export LC_ALL=C
|
||||
set -o pipefail
|
||||
|
||||
otemp=$(mktemp)
|
||||
gbtemp=$(mktemp)
|
||||
@@ -13,16 +14,31 @@ bold=$(tput bold)
|
||||
resbold=$(tput sgr0)
|
||||
red=$(tput setaf 1)
|
||||
rescolors=$(tput op)
|
||||
|
||||
tryDiff () {
|
||||
diff -u --strip-trailing-cr $1 $2 || (echo "${bold}${red}${i%.asm}.out mismatch!${rescolors}${resbold}"; false)
|
||||
if ! diff -u --strip-trailing-cr $1 $2; then
|
||||
echo "${bold}${red}${i%.asm}.out mismatch!${rescolors}${resbold}"
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
tryCmp () {
|
||||
cmp $1 $2 || (../../contrib/gbdiff.bash $1 $2; echo "${bold}${red}${i%.asm}.out.bin mismatch!${rescolors}${resbold}"; false)
|
||||
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
|
||||
echo "$bold${red}Linking shouldn't produce anything on stdout!$rescolors$resbold"
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
for i in *.asm; do
|
||||
$RGBASM -o $otemp $i
|
||||
@@ -31,13 +47,13 @@ for i in *.asm; do
|
||||
ran_flag=
|
||||
for flag in '-d' '-t' '-w'; do
|
||||
if [ -f ${i%.asm}-no${flag}.out ]; then
|
||||
$RGBLINK -o $gbtemp $otemp > $outtemp 2>&1
|
||||
rgblink -o $gbtemp $otemp > $outtemp 2>&1
|
||||
tryDiff ${i%.asm}-no${flag}.out $outtemp
|
||||
rc=$(($? || $rc))
|
||||
ran_flag=1
|
||||
fi
|
||||
if [ -f ${i%.asm}${flag}.out ]; then
|
||||
$RGBLINK ${flag} -o $gbtemp $otemp > $outtemp 2>&1
|
||||
rgblink ${flag} -o $gbtemp $otemp > $outtemp 2>&1
|
||||
tryDiff ${i%.asm}${flag}.out $outtemp
|
||||
rc=$(($? || $rc))
|
||||
ran_flag=1
|
||||
@@ -49,7 +65,7 @@ for i in *.asm; do
|
||||
|
||||
# Other tests have several linker scripts
|
||||
find . -name "${i%.asm}*.link" | while read script; do
|
||||
$RGBLINK -l $script -o $gbtemp $otemp > $outtemp 2>&1
|
||||
rgblink -l $script -o $gbtemp $otemp > $outtemp 2>&1
|
||||
tryDiff ${script%.link}.out $outtemp
|
||||
rc=$(($? || $rc))
|
||||
ran_flag=1
|
||||
@@ -59,7 +75,7 @@ for i in *.asm; do
|
||||
fi
|
||||
|
||||
# The rest of the tests just links a file, and maybe checks the binary
|
||||
$RGBLINK -o $gbtemp $otemp > $outtemp 2>&1
|
||||
rgblink -o $gbtemp $otemp > $outtemp 2>&1
|
||||
if [ -f ${i%.asm}.out ]; then
|
||||
tryDiff ${i%.asm}.out $outtemp
|
||||
rc=$(($? || $rc))
|
||||
@@ -75,41 +91,54 @@ done
|
||||
|
||||
# These tests do their own thing
|
||||
|
||||
$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
|
||||
rc=$(($? || $rc))
|
||||
|
||||
$RGBASM -o $otemp bank-const/a.asm
|
||||
$RGBASM -o $gbtemp2 bank-const/b.asm
|
||||
$RGBLINK -o $gbtemp $gbtemp2 $otemp > $outtemp 2>&1
|
||||
rgblink -o $gbtemp $gbtemp2 $otemp > $outtemp 2>&1
|
||||
i="bank-const.asm" tryDiff bank-const/err.out $outtemp
|
||||
rc=$(($? || $rc))
|
||||
|
||||
for i in fragment-align/*; do
|
||||
$RGBASM -o $otemp $i/a.asm
|
||||
$RGBASM -o $gbtemp2 $i/b.asm
|
||||
rgblink -o $gbtemp $otemp $gbtemp2 2>$outtemp
|
||||
tryDiff $i/out.err $outtemp
|
||||
rc=$(($? || $rc))
|
||||
if [[ -f $i/out.gb ]]; then
|
||||
dd if=$gbtemp count=1 bs=$(printf %s $(wc -c < $i/out.gb)) > $otemp 2>/dev/null
|
||||
tryCmp $i/out.gb $otemp
|
||||
rc=$(($? || $rc))
|
||||
fi
|
||||
done
|
||||
|
||||
$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
|
||||
rc=$(($? || $rc))
|
||||
|
||||
$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
|
||||
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
|
||||
rc=$(($? || $rc))
|
||||
$RGBASM -o $otemp section-union/fragments/a.asm
|
||||
$RGBASM -o $gbtemp2 section-union/fragments/b.asm
|
||||
$RGBLINK -o $gbtemp $otemp $gbtemp2
|
||||
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
|
||||
rc=$(($? || $rc))
|
||||
for i in section-union/*.asm; do
|
||||
$RGBASM -o $otemp $i
|
||||
$RGBASM -o $gbtemp2 $i -DSECOND
|
||||
if $RGBLINK $otemp $gbtemp2 > $outtemp 2>&1; then
|
||||
if rgblink $otemp $gbtemp2 2>$outtemp; then
|
||||
echo -e "${bold}${red}$i didn't fail to link!${rescolors}${resbold}"
|
||||
rc=1
|
||||
fi
|
||||
echo --- >> $outtemp
|
||||
# Ensure RGBASM also errors out
|
||||
echo 'SECOND equs "1"' | cat $i - $i | $RGBASM - 2>> $outtemp
|
||||
cat $i - $i <<<'SECOND equs "1"' | $RGBASM - 2>> $outtemp
|
||||
tryDiff ${i%.asm}.out $outtemp
|
||||
rc=$(($? || $rc))
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user