Add RGBFIX tests for MBC names (#1477)

RGBFIX tests are now based on .flags files
The .bin and .err files are optional
This commit is contained in:
Sylvie authored and GitHub committed 2024-08-20 21:15:37 +02:00
1 parent 8f47fb494b
commit 7d98b9a900
102 files changed
+153 -125

No files matched your search

+6 -5
View File
@@ -117,13 +117,14 @@ The object file will be linked with and without said flag, respectively; and in
### RGBFIX
Each `.bin` file corresponds to one test, and **must** be accompanied by a `.flags` file and a `.err` file.
The `.flags` file is a text file whose first line contains flags to pass to RGBFIX.
Each `.flags` file corresponds to one test.
Each one is a text file whose first line contains flags to pass to RGBFIX.
(There may be more lines, which will be ignored; they can serve as comments to explain what the test is about.)
RGBFIX will be invoked on the `.bin` file, and its error output must match the contents of the `.err` file.
(If no errors ought to be printed, then the `.err` file should just be empty.)
RGBFIX will be invoked on the `.bin` file if it exists, or else on default-input.bin.
If no `.err` file exists, RGBFIX is simply expected to be able to process the file normally.
If one *does* exist, RGBFIX's return status is ignored, but its output **must** match the `.err` file's contents.
Additionally, if a `.gb` file exists, the output of RGBFIX must match the `.gb`.
+11 -8
View File
@@ -155,6 +155,7 @@ enum MbcType {
MBC_BAD, // Specified MBC does not exist / syntax error
MBC_WRONG_FEATURES, // MBC incompatible with specified features
MBC_BAD_RANGE, // MBC number out of range
MBC_BAD_TPP1, // Invalid TPP1 major or minor revision numbers
};
static void printAcceptedMBCNames() {
@@ -170,7 +171,7 @@ static void printAcceptedMBCNames() {
fputs("\tMBC6 ($20)\n", stderr);
fputs("\tMBC7+SENSOR+RUMBLE+RAM+BATTERY ($22)\n", stderr);
fputs("\tPOCKET_CAMERA ($FC)\n", stderr);
fputs("\tBANDAI_TAMA5 ($FD)\n", stderr);
fputs("\tBANDAI_TAMA5 ($FD) [aka TAMA5]\n", stderr);
fputs("\tHUC3 ($FE)\n", stderr);
fputs("\tHUC1+RAM+BATTERY ($FF)\n", stderr);
@@ -332,12 +333,12 @@ static MbcType parseMBC(char const *name) {
if (endptr == ptr) {
report("error: Failed to parse TPP1 major revision number\n");
return MBC_BAD;
return MBC_BAD_TPP1;
}
ptr = endptr;
if (val != 1) {
report("error: RGBFIX only supports TPP1 versions 1.0\n");
return MBC_BAD;
report("error: RGBFIX only supports TPP1 version 1.0\n");
return MBC_BAD_TPP1;
}
tpp1Rev[0] = val;
tryReadSlice(".");
@@ -345,12 +346,12 @@ static MbcType parseMBC(char const *name) {
val = strtoul(ptr, &endptr, 10);
if (endptr == ptr) {
report("error: Failed to parse TPP1 minor revision number\n");
return MBC_BAD;
return MBC_BAD_TPP1;
}
ptr = endptr;
if (val > 0xFF) {
report("error: TPP1 minor revision number must be 8-bit\n");
return MBC_BAD;
return MBC_BAD_TPP1;
}
tpp1Rev[1] = val;
mbc = TPP1;
@@ -663,6 +664,7 @@ static char const *mbcName(MbcType type) {
case MBC_BAD:
case MBC_WRONG_FEATURES:
case MBC_BAD_RANGE:
case MBC_BAD_TPP1:
unreachable_();
}
@@ -686,6 +688,7 @@ static bool hasRAM(MbcType type) {
case MBC_BAD:
case MBC_WRONG_FEATURES:
case MBC_BAD_RANGE:
case MBC_BAD_TPP1:
return false;
case ROM_RAM:
@@ -1324,8 +1327,8 @@ int main(int argc, char *argv[]) {
} else if (cartridgeType == ROM_RAM || cartridgeType == ROM_RAM_BATTERY) {
fprintf(
stderr,
"warning: ROM+RAM / ROM+RAM+BATTERY are under-specified and poorly "
"supported\n"
"warning: MBC \"%s\" is under-specified and poorly supported\n",
musl_optarg
);
}
break;
+1 -1
View File
@@ -1 +1 @@
-f l -L custom-logo.1bpp
-f l -L ./custom-logo.1bpp
Binary file not shown.
+23
View File
@@ -0,0 +1,23 @@
error: Features incompatible with MBC ("mbc1+multirumble")
Accepted combinations:
ROM ($00) [aka ROM_ONLY]
MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03)
MBC2 ($05), MBC2+BATTERY ($06)
ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated]
MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D)
MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10)
MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13)
MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B)
MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E)
MBC6 ($20)
MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22)
POCKET_CAMERA ($FC)
BANDAI_TAMA5 ($FD) [aka TAMA5]
HUC3 ($FE)
HUC1+RAM+BATTERY ($FF)
TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER,
TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY,
TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE,
TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE,
TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE
+1
View File
@@ -0,0 +1 @@
-m mbc1+multirumble
+22
View File
@@ -0,0 +1,22 @@
Accepted MBC names:
ROM ($00) [aka ROM_ONLY]
MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03)
MBC2 ($05), MBC2+BATTERY ($06)
ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated]
MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D)
MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10)
MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13)
MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B)
MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E)
MBC6 ($20)
MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22)
POCKET_CAMERA ($FC)
BANDAI_TAMA5 ($FD) [aka TAMA5]
HUC3 ($FE)
HUC1+RAM+BATTERY ($FF)
TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER,
TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY,
TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE,
TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE,
TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE
+1
View File
@@ -0,0 +1 @@
-m Help
+1
View File
@@ -0,0 +1 @@
-m BANDAI_TAMA5
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m HUC1+RAM+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m HUC3
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC1+RAM+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC1+RAM
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC1
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC2+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC2
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC3+RAM+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC3+RAM
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC3+TIMER+BATTERY
Binary file not shown.
@@ -0,0 +1 @@
-m MBC3+TIMER+RAM+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC3
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC5+RAM+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC5+RAM
Binary file not shown.
@@ -0,0 +1 @@
-m MBC5+RUMBLE+RAM+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC5+RUMBLE+RAM
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC5+RUMBLE
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC5
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MBC6
Binary file not shown.
@@ -0,0 +1 @@
-m MBC7+SENSOR+RUMBLE+RAM+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MMM01+RAM+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MMM01+RAM
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m MMM01
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m POCKET_CAMERA
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m ROM_ONLY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
warning: MBC "ROM+RAM+BATTERY" is under-specified and poorly supported
+1
View File
@@ -0,0 +1 @@
-m ROM+RAM+BATTERY
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
warning: MBC "ROM+RAM" is under-specified and poorly supported
+1
View File
@@ -0,0 +1 @@
-m ROM+RAM
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m ROM
Binary file not shown.
+1
View File
@@ -0,0 +1 @@
-m TAMA5
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
-m ROM -r 2
-m rom_only -r 2
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
Binary file not shown.
View File
Whitespace-only changes.
View File
Whitespace-only changes.
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1 +1 @@
-m MBC3+RAM -r 0
-m mbc3+ram -r 0
+1 -1
View File
@@ -1 +1 @@
-m MBC3+RAM -r 2
-m mbc3+ram -r 2
+1 -1
View File
@@ -1 +1 @@
-m MBC3 -r 0
-m mbc3 -r 0
Binary file not shown.
-2
View File
@@ -1,2 +0,0 @@
warning: ROM+RAM / ROM+RAM+BATTERY are under-specified and poorly supported
warning: Overwrote a non-zero byte in the cartridge type
-1
View File
@@ -1 +0,0 @@
-m8
Binary file not shown.
+20 -11
View File
@@ -42,7 +42,7 @@ tryCmp () {
runTest () {
flags=$(
head -n 1 "$2/$1.flags" | # Allow other lines to serve as comments
sed "s#-L #-L ${src//#/\\#}/#g" # Prepend src directory to logo file
sed "s# ./# ${src//#/\\#}/#g" # Prepend src directory to path arguments
)
for variant in '' ' piped'; do
@@ -51,26 +51,37 @@ runTest () {
if [[ $progress -ne 0 ]]; then
echo "${bold}${green}$1${variant}...${rescolors}${resbold}"
fi
if [[ -r "$2/$1.bin" ]]; then
desired_input="$2/$1.bin"
else
desired_input="$src/default-input.bin"
fi
if [[ -z "$variant" ]]; then
cp "$2/$1.bin" out.gb
cp "$desired_input" out.gb
if [[ -n "$(eval "$RGBFIX" $flags out.gb '2>out.err')" ]]; then
echo "${bold}${red}Fixing $1 in-place shouldn't output anything on stdout!${rescolors}${resbold}"
our_rc=1
fi
subst='out.gb'
subst=out.gb
else
# Stop! This is not a Useless Use Of Cat. Using cat instead of
# stdin redirection makes the input an unseekable pipe - a scenario
# that's harder to deal with.
# shellcheck disable=SC2002
cat "$2/$1.bin" | eval $RGBFIX "$flags" - '>out.gb' '2>out.err'
cat "$desired_input" | eval $RGBFIX "$flags" - '>out.gb' '2>out.err'
subst='<stdin>'
fi
sed "s/$subst/<filename>/g" "out.err" | tryDiff "$2/$1.err" - "$1.err${variant}"
if [[ -r "$2/$1.err" ]]; then
desired_errname="$2/$1.err"
else
desired_errname=/dev/null
fi
sed "s/$subst/<filename>/g" out.err | tryDiff "$desired_errname" - "$1.err${variant}"
(( our_rc = our_rc || $? ))
if [[ -r "$2/$1.gb" ]]; then
tryCmp "$2/$1.gb" "out.gb" "$1.gb${variant}"
tryCmp "$2/$1.gb" out.gb "$1.gb${variant}"
(( our_rc = our_rc || $? ))
fi
@@ -85,8 +96,8 @@ runTest () {
rm -f padding*_* # Delete padding test cases generated but not deleted (e.g. interrupted)
progress=1
for i in "$src"/*.bin; do
runTest "$(basename "$i" .bin)" "$src"
for i in "$src"/*.flags; do
runTest "$(basename "$i" .flags)" "$src"
done
# Check the result with all different padding bytes
@@ -103,9 +114,7 @@ for (( i=0; i < 10; ++i )); do
runTest padding${suffix} .
done
done
echo "Done!"
# TODO: check MBC names
echo "${bold}Done checking padding!${resbold}"
# Check that RGBFIX errors out when inputting a non-existent file...
$RGBFIX noexist 2>out.err
-23
View File
@@ -1,24 +1 @@
error: Failed to parse TPP1 major revision number
error: Unknown MBC "TPP1_lol"
Accepted MBC names:
ROM ($00) [aka ROM_ONLY]
MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03)
MBC2 ($05), MBC2+BATTERY ($06)
ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated]
MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D)
MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10)
MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13)
MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B)
MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E)
MBC6 ($20)
MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22)
POCKET_CAMERA ($FC)
BANDAI_TAMA5 ($FD)
HUC3 ($FE)
HUC1+RAM+BATTERY ($FF)
TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER,
TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY,
TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE,
TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE,
TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE
-23
View File
@@ -1,24 +1 @@
error: Failed to parse TPP1 minor revision number
error: Unknown MBC "TPP1_1.lol"
Accepted MBC names:
ROM ($00) [aka ROM_ONLY]
MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03)
MBC2 ($05), MBC2+BATTERY ($06)
ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated]
MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D)
MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10)
MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13)
MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B)
MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E)
MBC6 ($20)
MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22)
POCKET_CAMERA ($FC)
BANDAI_TAMA5 ($FD)
HUC3 ($FE)
HUC1+RAM+BATTERY ($FF)
TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER,
TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY,
TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE,
TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE,
TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE
Binary file not shown.
+5
View File
@@ -0,0 +1,5 @@
warning: Overwrote a non-zero byte in the cartridge type
warning: Overwrote a non-zero byte in the TPP1 identification code
warning: Overwrote a non-zero byte in the TPP1 revision number
warning: Overwrote a non-zero byte in the RAM size
warning: Overwrote a non-zero byte in the TPP1 feature flags
+1
View File
@@ -0,0 +1 @@
-m TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE -r 8
Binary file not shown.
+1 -24
View File
@@ -1,24 +1 @@
error: RGBFIX only supports TPP1 versions 1.0
error: Unknown MBC "TPP1_2.0"
Accepted MBC names:
ROM ($00) [aka ROM_ONLY]
MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03)
MBC2 ($05), MBC2+BATTERY ($06)
ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated]
MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D)
MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10)
MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13)
MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B)
MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E)
MBC6 ($20)
MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22)
POCKET_CAMERA ($FC)
BANDAI_TAMA5 ($FD)
HUC3 ($FE)
HUC1+RAM+BATTERY ($FF)
TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER,
TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY,
TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE,
TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE,
TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE
error: RGBFIX only supports TPP1 version 1.0
-23
View File
@@ -1,24 +1 @@
error: TPP1 minor revision number must be 8-bit
error: Unknown MBC "TPP1_1.256"
Accepted MBC names:
ROM ($00) [aka ROM_ONLY]
MBC1 ($01), MBC1+RAM ($02), MBC1+RAM+BATTERY ($03)
MBC2 ($05), MBC2+BATTERY ($06)
ROM+RAM ($08) [deprecated], ROM+RAM+BATTERY ($09) [deprecated]
MMM01 ($0B), MMM01+RAM ($0C), MMM01+RAM+BATTERY ($0D)
MBC3+TIMER+BATTERY ($0F), MBC3+TIMER+RAM+BATTERY ($10)
MBC3 ($11), MBC3+RAM ($12), MBC3+RAM+BATTERY ($13)
MBC5 ($19), MBC5+RAM ($1A), MBC5+RAM+BATTERY ($1B)
MBC5+RUMBLE ($1C), MBC5+RUMBLE+RAM ($1D), MBC5+RUMBLE+RAM+BATTERY ($1E)
MBC6 ($20)
MBC7+SENSOR+RUMBLE+RAM+BATTERY ($22)
POCKET_CAMERA ($FC)
BANDAI_TAMA5 ($FD)
HUC3 ($FE)
HUC1+RAM+BATTERY ($FF)
TPP1_1.0, TPP1_1.0+RUMBLE, TPP1_1.0+MULTIRUMBLE, TPP1_1.0+TIMER,
TPP1_1.0+TIMER+RUMBLE, TPP1_1.0+TIMER+MULTIRUMBLE, TPP1_1.0+BATTERY,
TPP1_1.0+BATTERY+RUMBLE, TPP1_1.0+BATTERY+MULTIRUMBLE,
TPP1_1.0+BATTERY+TIMER, TPP1_1.0+BATTERY+TIMER+RUMBLE,
TPP1_1.0+BATTERY+TIMER+MULTIRUMBLE
Loaded 100 of 102 files, more files were not shown because too many files have changed in this diff. Show more