Merge branch 'master' into features-1.1.0

This commit is contained in:
Rangi committed 2026-09-27 20:49:36 -04:00
commit ad4e399018
26 files changed
+241 -203

No files matched your search

+3 -5
View File
@@ -13,12 +13,10 @@ MACRO test_mod
def x = \1 ; dividend
def y = \2 ; divisor
shift 2
def q = x / y ; quotient
def r = x % y ; remainder
; identity laws
test (V (q * y + r)) == (V x)
test (V (x + y) % y) == (V r)
test (V (x - y) % y) == (V r)
test (V x) / y * y + (V x) % y == (V x)
test (V (x + y)) % y == (V x) % y
test (V (x - y)) % y == (V x) % y
ENDM
MACRO test_each_mod
+53 -14
View File
@@ -35,6 +35,13 @@ rescolors="$(tput op)"
RGBFIX="$src/../../rgbfix"
startTest () {
(( tests++ ))
if [[ $progress -ne 0 ]]; then
echo "${bold}${green}$1...${rescolors}${resbold}"
fi
}
tryDiff () {
if ! diff -au --strip-trailing-cr "$1" "$2"; then
echo "${bold}${red}${3:-$1} mismatch!${rescolors}${resbold}"
@@ -44,7 +51,7 @@ tryDiff () {
tryCmp () {
if ! cmp "$1" "$2"; then
"$src/../../gbdiff.bash" "$1" "$2"
"$src/../../contrib/gbdiff.bash" "$1" "$2" | head
echo "${bold}${red}${3:-$1} mismatch!${rescolors}${resbold}"
false
fi
@@ -61,11 +68,7 @@ runTest () {
fi
for variant in '' ' piped' ' output'; do
(( tests++ ))
our_rc=0
if [[ $progress -ne 0 ]]; then
echo "${bold}${green}$1${variant}...${rescolors}${resbold}"
fi
startTest "$1${variant}"
if [[ -r "$2/$1.bin" ]]; then
desired_input="$2/$1.bin"
else
@@ -96,7 +99,7 @@ runTest () {
desired_errname=/dev/null
fi
sed -e "s/$subst/<filename>/g" -e "s#$src_subst##g" out.out | tryDiff "$desired_outname" - "$1.out${variant}"
(( our_rc = our_rc || $? ))
our_rc=$?
sed -e "s/$subst/<filename>/g" -e "s#$src_subst##g" out.err | tryDiff "$desired_errname" - "$1.err${variant}"
(( our_rc = our_rc || $? ))
@@ -116,11 +119,36 @@ runTest () {
runSpecialTest () {
name="$1"
shift
echo "${bold}${green}${name}...${rescolors}${resbold}"
startTest "$name"
eval "$RGBFIX" "$@" -o out.gb '>out.out' '2>out.err'
tryDiff out.out /dev/null "${name}.out"
our_rc=$?
tryDiff out.err /dev/null "${name}.err"
(( our_rc = our_rc || $? ))
tryCmp input.gb out.gb "${name}.gb"
(( our_rc = our_rc || $? ))
(( rc = rc || our_rc ))
if [[ $our_rc -ne 0 ]]; then
(( failed++ ))
fi
}
runTestExpectingFailure () {
name="$1"
shift
startTest "$name"
eval "$RGBFIX" "$@" '2>out.err'
rc=$((rc || $? != 1))
our_rc=$(($? != 1))
tryDiff "$src/${name}.err" out.err "${name}.err"
rc=$((rc || $?))
our_rc=$((our_rc || $?))
rc=$((rc || our_rc))
if [[ $our_rc -ne 0 ]]; then
(( failed++ ))
fi
}
rm -f padding*_* # Delete padding test cases generated but not deleted (e.g. interrupted)
@@ -130,14 +158,24 @@ for i in "$src"/*.flags; do
runTest "$(basename "$i" .flags)" "$src"
done
# Check that RGBFIX truncates a pre-existing output file
dd if=/dev/zero of=input.gb bs=1 count=336 >/dev/null 2>&1
dd if=/dev/zero of=out.gb bs=1 count=16384 >/dev/null 2>&1
runSpecialTest pre-existing-output input.gb
# Check that RGBFIX handles an output file identical to the input file
dd if=/dev/zero of=input.gb bs=1 count=336 >/dev/null 2>&1
cp input.gb out.gb
runSpecialTest equivalent-output out.gb
# Check that RGBFIX errors out when inputting a non-existent file
runSpecialTest no-exist no-exist
runTestExpectingFailure no-exist no-exist
# Check that RGBFIX errors out when not inputting any file
runSpecialTest no-input
runTestExpectingFailure no-input
# Check that RGBFIX errors out when inputting multiple files with an output file
runSpecialTest multiple-to-one one two three -o multiple-to-one
runTestExpectingFailure multiple-to-one one two three -o multiple-to-one
# Check the result with all different padding bytes
echo "${bold}Checking padding...${resbold}"
@@ -149,7 +187,8 @@ for (( i=0; i < 10; ++i )); do
echo "$padding..."
for suffix in '' -large -larger; do
cat <<<"-p $padding" >padding$suffix.flags
tr '\377' \\$((padding / 64))$(((padding / 8) % 8))$((padding % 8)) <"$src/padding$suffix.gb" >padding$suffix.gb # OK because $FF bytes are only used for padding
# `tr`ing &377 aka $FF is OK because $FF bytes are only used for padding
tr '\377' \\$((padding / 64))$(((padding / 8) % 8))$((padding % 8)) <"$src/padding$suffix.gb" >padding$suffix.gb
runTest padding${suffix} .
done
done
+1
View File
@@ -1,3 +1,4 @@
-C
-m
-t reverse_curve.tilemap
-a reverse_curve.attrmap
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
? @L���€�€�€�円G|C<#
Binary file not shown.
+4
View File
@@ -0,0 +1,4 @@
-m
-t reverse_no_curve.tilemap
-a reverse_no_curve.attrmap
-p reverse_no_curve.pal
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -466,7 +466,7 @@ int main(int argc, char *argv[]) {
auto cgbColor = [](Rgba const &rgba) {
auto field = [](uint16_t component, uint8_t shift) {
return (component & 0x1F) << shift;
return (component >> 3) << shift;
};
return rgba.isTransparent()
? Rgba::transparent
+11 -5
View File
@@ -89,20 +89,26 @@ for f in *.png; do
done
newTest "$RGBGFX" $flags "$f"
test_rc=0
if [[ -e "${f%.png}.err" ]]; then
runTest 2>"$errtmp"
diff -au --strip-trailing-cr "${f%.png}.err" "$errtmp" || failTest
diff -au --strip-trailing-cr "${f%.png}.err" "$errtmp" || test_rc=$?
else
runTest && checkOutput "${f%.png}" || failTest $?
runTest || test_rc=$?
fi
checkOutput "${f%.png}" || test_rc=$?
(( test_rc )) && failTest $test_rc
newTest "$RGBGFX" $flags - "<$f"
test_rc=0
if [[ -e "${f%.png}.err" ]]; then
runTest 2>"$errtmp"
diff -au --strip-trailing-cr "${f%.png}.err" <(sed "s#<stdin>#${f//#/\\#}#g" "$errtmp") || failTest
diff -au --strip-trailing-cr "${f%.png}.err" <(sed "s#<stdin>#${f//#/\\#}#g" "$errtmp") || test_rc=$?
else
runTest && checkOutput "${f%.png}" || failTest $?
runTest || test_rc=$?
fi
checkOutput "${f%.png}" || test_rc=$?
(( test_rc )) && failTest $test_rc
done
for f in *.[12]bpp; do
@@ -122,7 +128,7 @@ for f in *.[12]bpp; do
if [[ -e "${f%.[12]bpp}.err" ]]; then
newTest "$RGBGFX $flags -o $f -r 1 result.png"
runTest 2>"$errtmp"
diff -au --strip-trailing-cr "${f%.[12]bpp}.err" <(sed "s#<stdin>#${f//#/\\#}#g" "$errtmp") || failTest
diff -au --strip-trailing-cr "${f%.[12]bpp}.err" <(sed "s#<stdin>#${f//#/\\#}#g" "$errtmp") || failTest $?
else
newTest "$RGBGFX $flags -o $f -r 1 result.png && $RGBGFX $flags -o result.2bpp result.png"
runTest && tryCmp "$f" result.2bpp || failTest $?
+45 -20
View File
@@ -14,9 +14,10 @@ gbtemp2="$(mktemp)"
outtemp="$(mktemp)"
outtemp2="$(mktemp)"
outtemp3="$(mktemp)"
errtemp="$(mktemp)"
# shellcheck disable=SC2064 # (Immediate expansion is the desired behavior.)
trap "rm -f ${otemp@Q} ${gbtemp@Q} ${gbtemp2@Q} ${outtemp@Q} ${outtemp2@Q} ${outtemp3@Q}" EXIT
trap "rm -f ${otemp@Q} ${gbtemp@Q} ${gbtemp2@Q} ${outtemp@Q} ${outtemp2@Q} ${outtemp3@Q} ${errtemp@Q}" EXIT
tests=0
failed=0
@@ -92,31 +93,39 @@ for i in *.asm; do
continue
fi
RGBLINKFLAGS=()
if [ -f "${test}.flags" ]; then
RGBLINKFLAGS+=("@${test}.flags")
fi
ran_test=false
# Some tests have variants depending on flags
ran_flag=false
for flag in '-d' '-t' '-w'; do
if [ -f "${test}-no${flag}.out" ]; then
continueTest "-no${flag}"
rgblinkQuiet "${RGBLINKFLAGS[@]}" -o "$gbtemp" "$otemp" 2>"$outtemp"
tryDiff "${test}-no${flag}.out" "$outtemp"
bin=${test}-no${flag}.out.bin
if [ -f "$bin" ]; then
tryCmpRom "$bin"
fi
evaluateTest
ran_flag=true
ran_test=true
fi
if [ -f "${test}${flag}.out" ]; then
continueTest "$flag"
rgblinkQuiet "${RGBLINKFLAGS[@]}" ${flag} -o "$gbtemp" "$otemp" 2>"$outtemp"
tryDiff "${test}${flag}.out" "$outtemp"
bin=${test}${flag}.out.bin
if [ -f "$bin" ]; then
tryCmpRom "$bin"
fi
evaluateTest
ran_flag=true
ran_test=true
fi
done
if "$ran_flag"; then
if "$ran_test"; then
continue
fi
@@ -127,10 +136,14 @@ for i in *.asm; do
continueTest "${script#${test}}"
rgblinkQuiet "${RGBLINKFLAGS[@]}" -l "$script" -o "$gbtemp" "$otemp" 2>"$outtemp"
tryDiff "${script%.link}.out" "$outtemp"
bin=${script%.link}.out.bin
if [ -f "$bin" ]; then
tryCmpRom "$bin"
fi
evaluateTest
ran_flag=true
ran_test=true
done
if "$ran_flag"; then
if "$ran_test"; then
continue
fi
@@ -195,7 +208,8 @@ test="fragment-literals"
startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
continueTest
rgblinkQuiet -o "$gbtemp" -m "$outtemp" -n "$outtemp2" "$otemp"
rgblinkQuiet -o "$gbtemp" -m "$outtemp" -n "$outtemp2" "$otemp" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
tryDiff "$test"/ref.out.map "$outtemp"
tryDiff "$test"/ref.out.sym "$outtemp2"
@@ -206,7 +220,8 @@ startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
"$RGBASM" -o "$outtemp" "$test"/b.asm
continueTest
rgblinkQuiet -o "$gbtemp" -n "$outtemp2" "$otemp" "$outtemp"
rgblinkQuiet -o "$gbtemp" -n "$outtemp2" "$otemp" "$outtemp" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
tryDiff "$test"/ref.out.sym "$outtemp2"
evaluateTest
@@ -227,8 +242,10 @@ startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
"$RGBASM" -o "$outtemp" "$test"/b.asm
continueTest
rgblinkQuiet -o "$gbtemp" "$otemp"
rgblinkQuiet -o "$gbtemp2" "$outtemp"
rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
rgblinkQuiet -o "$gbtemp2" "$outtemp" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmp "$gbtemp" "$gbtemp2"
evaluateTest
@@ -236,7 +253,8 @@ test="load-fragment/base"
startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
continueTest
rgblinkQuiet -o "$gbtemp" -n "$outtemp" "$otemp"
rgblinkQuiet -o "$gbtemp" -n "$outtemp" "$otemp" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
tryDiff "$test"/ref.out.sym "$outtemp"
evaluateTest
@@ -246,7 +264,8 @@ startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
continueTest
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
evaluateTest
@@ -256,7 +275,8 @@ startTest
"$RGBASM" -o "$outtemp" "$test"/b.asm
"$RGBASM" -o "$outtemp2" "$test"/c.asm
continueTest
rgblinkQuiet -o "$gbtemp" -m "$outtemp3" -n "$gbtemp2" "$otemp" "$outtemp" "$outtemp2"
rgblinkQuiet -o "$gbtemp" -m "$outtemp3" -n "$gbtemp2" "$otemp" "$outtemp" "$outtemp2" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
tryDiff "$test"/ref.out.map "$outtemp3"
tryDiff "$test"/ref.out.sym "$gbtemp2"
@@ -387,7 +407,8 @@ startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
continueTest
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
evaluateTest
@@ -404,7 +425,8 @@ startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
continueTest
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
evaluateTest
@@ -413,7 +435,8 @@ startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
continueTest
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
evaluateTest
@@ -440,7 +463,8 @@ startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
continueTest
rgblinkQuiet -o "$gbtemp" -l "$test"/script.link "$otemp" "$gbtemp2"
rgblinkQuiet -o "$gbtemp" -l "$test"/script.link "$otemp" "$gbtemp2" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
evaluateTest
@@ -449,7 +473,8 @@ startTest
"$RGBASM" -o "$otemp" "$test"/a.asm
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
continueTest
rgblinkQuiet -o "$gbtemp" -l "$test"/script.link "$otemp" "$gbtemp2"
rgblinkQuiet -o "$gbtemp" -l "$test"/script.link "$otemp" "$gbtemp2" 2>"$errtemp"
tryDiff /dev/null "$errtemp"
tryCmpRom "$test"/ref.out.bin
evaluateTest
+6 -28
View File
@@ -18,8 +18,6 @@ Options:
--only-free skip tests that build nonfree codebases
--jobs <n> build external codebases with `make -j<n>`
--os <os> skip tests known to fail on <os> (e.g. `macos-14`)
--installed-rgbds use the system installed RGBDS
(only compatible with external codebases)
EOF
}
@@ -28,8 +26,7 @@ EOF
nonfree=true
internal=true
external=true
installedrgbds=false
make_jobs=
make_args=()
osname=
while [[ $# -gt 0 ]]; do
case "$1" in
@@ -46,12 +43,9 @@ while [[ $# -gt 0 ]]; do
--only-free)
nonfree=false
;;
--installed-rgbds)
installedrgbds=true
;;
--jobs)
shift
make_jobs="-j$1"
make_args+=(-j "$1")
;;
--os)
shift
@@ -73,26 +67,10 @@ if ! "$internal" && ! "$external"; then
false
fi
if "$internal" && "$installedrgbds"; then
echo "Please specify --only-external with --installed-rgbds"
echo "(internal tests don't support running with system-installed RGBDS)"
false
fi
# Refuse to run if RGBDS isn't available
if "$installedrgbds"; then
is_installed() {
command -v "$1" >/dev/null 2>&1
}
if ! (is_installed rgbasm && is_installed rgblink && is_installed rgbfix && is_installed rgbgfx); then
echo "Please install RGBDS before running the tests"
false
fi
else
if [[ ! ( -x ../rgbasm && -x ../rgblink && -x ../rgbfix && -x ../rgbgfx ) ]]; then
echo "Please build RGBDS before running the tests"
false
fi
if [[ ! ( -x ../rgbasm && -x ../rgblink && -x ../rgbfix && -x ../rgbgfx ) ]]; then
echo "Please build RGBDS before running the tests"
false
fi
# Tests included with the repository
@@ -128,6 +106,6 @@ for cfg in *.cfg; do (
# Run nonfree tests only if they are opted into.
if ! "$EXT_TEST_IS_NONFREE" || "$nonfree"; then
./test.sh "$test_name" "$make_jobs"
./test.sh "$test_name" "${make_args[@]}"
fi
); done