mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Refactor link/test.sh to avoid repeating test names (#1353)
This commit is contained in:
@@ -25,13 +25,13 @@ RGBASM=../../rgbasm
|
|||||||
RGBLINK=../../rgblink
|
RGBLINK=../../rgblink
|
||||||
|
|
||||||
startTest () {
|
startTest () {
|
||||||
echo "${bold}${green}${i%.asm} assembling...${rescolors}${resbold}"
|
echo "${bold}${green}${test} assembling...${rescolors}${resbold}"
|
||||||
}
|
}
|
||||||
|
|
||||||
continueTest () {
|
continueTest () {
|
||||||
(( tests++ ))
|
(( tests++ ))
|
||||||
our_rc=0
|
our_rc=0
|
||||||
echo "${bold}${green}${i%.asm}$1...${rescolors}${resbold}"
|
echo "${bold}${green}${test}$1...${rescolors}${resbold}"
|
||||||
}
|
}
|
||||||
|
|
||||||
tryDiff () {
|
tryDiff () {
|
||||||
@@ -45,7 +45,7 @@ tryDiff () {
|
|||||||
tryCmp () {
|
tryCmp () {
|
||||||
if ! cmp "$1" "$2"; then
|
if ! cmp "$1" "$2"; then
|
||||||
../../contrib/gbdiff.bash "$1" "$2"
|
../../contrib/gbdiff.bash "$1" "$2"
|
||||||
echo "${bold}${red}${i%.asm}.out.bin mismatch!${rescolors}${resbold}"
|
echo "${bold}${red}${test}.out.bin mismatch!${rescolors}${resbold}"
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
(( our_rc = our_rc || $? ))
|
(( our_rc = our_rc || $? ))
|
||||||
@@ -60,7 +60,7 @@ tryCmpRom () {
|
|||||||
tryCmpRomSize () {
|
tryCmpRomSize () {
|
||||||
rom_size=$(printf %s $(wc -c <"$1"))
|
rom_size=$(printf %s $(wc -c <"$1"))
|
||||||
if [ "$rom_size" -ne "$2" ]; then
|
if [ "$rom_size" -ne "$2" ]; then
|
||||||
echo "$bold${red}${i%.asm} binary size mismatch! ${rescolors}${resbold}"
|
echo "$bold${red}${test} binary size mismatch! ${rescolors}${resbold}"
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
(( our_rc = our_rc || $? ))
|
(( our_rc = our_rc || $? ))
|
||||||
@@ -83,23 +83,24 @@ evaluateTest () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for i in *.asm; do
|
for i in *.asm; do
|
||||||
|
test=${i%.asm}
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" "$i"
|
"$RGBASM" -o "$otemp" "${test}.asm"
|
||||||
|
|
||||||
# Some tests have variants depending on flags
|
# Some tests have variants depending on flags
|
||||||
ran_flag=false
|
ran_flag=false
|
||||||
for flag in '-d' '-t' '-w'; do
|
for flag in '-d' '-t' '-w'; do
|
||||||
if [ -f "${i%.asm}-no${flag}.out" ]; then
|
if [ -f "${test}-no${flag}.out" ]; then
|
||||||
continueTest "-no${flag}"
|
continueTest "-no${flag}"
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${i%.asm}-no${flag}.out" "$outtemp"
|
tryDiff "${test}-no${flag}.out" "$outtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
ran_flag=true
|
ran_flag=true
|
||||||
fi
|
fi
|
||||||
if [ -f "${i%.asm}${flag}.out" ]; then
|
if [ -f "${test}${flag}.out" ]; then
|
||||||
continueTest "$flag"
|
continueTest "$flag"
|
||||||
rgblinkQuiet ${flag} -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet ${flag} -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${i%.asm}${flag}.out" "$outtemp"
|
tryDiff "${test}${flag}.out" "$outtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
ran_flag=true
|
ran_flag=true
|
||||||
fi
|
fi
|
||||||
@@ -109,10 +110,10 @@ for i in *.asm; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Other tests have several linker scripts
|
# Other tests have several linker scripts
|
||||||
for script in "${i%.asm}"*.link; do
|
for script in "$test"*.link; do
|
||||||
[[ -e "$script" ]] || break # If the glob doesn't match, it just... doesn't expand!
|
[[ -e "$script" ]] || break # If the glob doesn't match, it just... doesn't expand!
|
||||||
|
|
||||||
continueTest "${script#${i%.asm}}"
|
continueTest "${script#${test}}"
|
||||||
rgblinkQuiet -l "$script" -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet -l "$script" -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${script%.link}.out" "$outtemp"
|
tryDiff "${script%.link}.out" "$outtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
@@ -125,8 +126,8 @@ for i in *.asm; do
|
|||||||
# The rest of the tests just links a file, and maybe checks the binary
|
# The rest of the tests just links a file, and maybe checks the binary
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${i%.asm}.out" "$outtemp"
|
tryDiff "${test}.out" "$outtemp"
|
||||||
bin=${i%.asm}.out.bin
|
bin=${test}.out.bin
|
||||||
if [ -f "$bin" ]; then
|
if [ -f "$bin" ]; then
|
||||||
tryCmpRom "$bin"
|
tryCmpRom "$bin"
|
||||||
fi
|
fi
|
||||||
@@ -135,98 +136,99 @@ done
|
|||||||
|
|
||||||
# These tests do their own thing
|
# These tests do their own thing
|
||||||
|
|
||||||
i="bank-const.asm"
|
test="bank-const"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" bank-const/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
"$RGBASM" -o "$gbtemp2" bank-const/b.asm
|
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$gbtemp2" "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" "$gbtemp2" "$otemp" 2>"$outtemp"
|
||||||
tryDiff bank-const/out.err "$outtemp"
|
tryDiff "$test"/out.err "$outtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
for i in fragment-align/*; do
|
for test in fragment-align/*; do
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" "$i"/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
"$RGBASM" -o "$gbtemp2" "$i"/b.asm
|
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2" 2>"$outtemp"
|
||||||
tryDiff "$i"/out.err "$outtemp"
|
tryDiff "$test"/out.err "$outtemp"
|
||||||
if [[ -f "$i"/out.gb ]]; then
|
if [[ -f "$test"/out.gb ]]; then
|
||||||
tryCmpRom "$i"/out.gb
|
tryCmpRom "$test"/out.gb
|
||||||
fi
|
fi
|
||||||
evaluateTest
|
evaluateTest
|
||||||
done
|
done
|
||||||
|
|
||||||
i="high-low.asm"
|
test="high-low"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" high-low/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
"$RGBASM" -o "$outtemp" high-low/b.asm
|
"$RGBASM" -o "$outtemp" "$test"/b.asm
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp"
|
rgblinkQuiet -o "$gbtemp" "$otemp"
|
||||||
rgblinkQuiet -o "$gbtemp2" "$outtemp"
|
rgblinkQuiet -o "$gbtemp2" "$outtemp"
|
||||||
tryCmp "$gbtemp" "$gbtemp2"
|
tryCmp "$gbtemp" "$gbtemp2"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
i="overlay.asm"
|
test="overlay"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" overlay/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" -t -O overlay/overlay.gb "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" -t -O "$test"/overlay.gb "$otemp" 2>"$outtemp"
|
||||||
tryDiff overlay/out.err "$outtemp"
|
tryDiff "$test"/out.err "$outtemp"
|
||||||
# This test does not trim its output with 'dd' because it needs to verify the correct output size
|
# This test does not trim its output with 'dd' because it needs to verify the correct output size
|
||||||
tryCmp overlay/out.gb "$gbtemp"
|
tryCmp "$test"/out.gb "$gbtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
i="scramble-romx.asm"
|
test="scramble-romx"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" scramble-romx/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" -S romx=3 "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" -S romx=3 "$otemp" 2>"$outtemp"
|
||||||
tryDiff scramble-romx/out.err "$outtemp"
|
tryDiff "$test"/out.err "$outtemp"
|
||||||
# This test does not compare its exact output with 'tryCmpRom' because no scrambling order is guaranteed
|
# This test does not compare its exact output with 'tryCmpRom' because no scrambling order is guaranteed
|
||||||
tryCmpRomSize "$gbtemp" 65536
|
tryCmpRomSize "$gbtemp" 65536
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
i="section-fragment/jr-offset.asm"
|
test="section-fragment/jr-offset"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" section-fragment/jr-offset/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
"$RGBASM" -o "$gbtemp2" section-fragment/jr-offset/b.asm
|
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
||||||
tryCmpRom section-fragment/jr-offset/ref.out.bin
|
tryCmpRom "$test"/ref.out.bin
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
i="section-union/good.asm"
|
test="section-union/good"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" section-union/good/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
"$RGBASM" -o "$gbtemp2" section-union/good/b.asm
|
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" -l section-union/good/script.link "$otemp" "$gbtemp2"
|
rgblinkQuiet -o "$gbtemp" -l "$test"/script.link "$otemp" "$gbtemp2"
|
||||||
tryCmpRom section-union/good/ref.out.bin
|
tryCmpRom "$test"/ref.out.bin
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
i="section-union/fragments.asm"
|
test="section-union/fragments"
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" section-union/fragments/a.asm
|
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||||
"$RGBASM" -o "$gbtemp2" section-union/fragments/b.asm
|
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
||||||
tryCmpRom section-union/fragments/ref.out.bin
|
tryCmpRom "$test"/ref.out.bin
|
||||||
evaluateTest
|
evaluateTest
|
||||||
|
|
||||||
for i in section-union/*.asm; do
|
for i in section-union/*.asm; do
|
||||||
|
test=${i%.asm}
|
||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" "$i"
|
"$RGBASM" -o "$otemp" "${test}.asm"
|
||||||
"$RGBASM" -o "$gbtemp2" "$i" -DSECOND
|
"$RGBASM" -o "$gbtemp2" "${test}.asm" -DSECOND
|
||||||
continueTest
|
continueTest
|
||||||
if rgblinkQuiet "$otemp" "$gbtemp2" 2>"$outtemp"; then
|
if rgblinkQuiet "$otemp" "$gbtemp2" 2>"$outtemp"; then
|
||||||
echo -e "${bold}${red}$i didn't fail to link!${rescolors}${resbold}"
|
echo -e "${bold}${red}${test}.asm didn't fail to link!${rescolors}${resbold}"
|
||||||
our_rc=1
|
our_rc=1
|
||||||
fi
|
fi
|
||||||
echo --- >>"$outtemp"
|
echo --- >>"$outtemp"
|
||||||
# Ensure RGBASM also errors out
|
# Ensure RGBASM also errors out
|
||||||
cat "$i" - "$i" <<<'def SECOND equs "1"' | "$RGBASM" - 2>>"$outtemp"
|
cat "${test}.asm" - "${test}.asm" <<<'def SECOND equs "1"' | "$RGBASM" - 2>>"$outtemp"
|
||||||
tryDiff "${i%.asm}.out" "$outtemp"
|
tryDiff "${test}.out" "$outtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user