From e20347e38c1390a980014b316fa1a9a3e1a234ce Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Wed, 29 Jan 2025 12:53:44 -0500 Subject: [PATCH] Add more RGBLINK tests (#1639) --- src/link/object.cpp | 14 +++++++------- src/link/section.cpp | 13 +++++++++---- test/link/invalid-bank-t.out | 2 +- test/link/invalid-ram-types-d.out | 3 +++ test/link/invalid-ram-types.asm | 5 +++++ test/link/vram-fixed-dmg-mode-d.out | 2 +- 6 files changed, 26 insertions(+), 13 deletions(-) create mode 100644 test/link/invalid-ram-types-d.out create mode 100644 test/link/invalid-ram-types.asm diff --git a/src/link/object.cpp b/src/link/object.cpp index 7a77b345..8f19035d 100644 --- a/src/link/object.cpp +++ b/src/link/object.cpp @@ -239,7 +239,7 @@ static void readPatch( tryReadLong( nodeID, file, - "%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s node ID: %s", + "%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s node ID: %s", fileName, sectName.c_str(), i @@ -248,7 +248,7 @@ static void readPatch( tryReadLong( patch.lineNo, file, - "%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s line number: %s", + "%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s line number: %s", fileName, sectName.c_str(), i @@ -256,7 +256,7 @@ static void readPatch( tryReadLong( patch.offset, file, - "%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s offset: %s", + "%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s offset: %s", fileName, sectName.c_str(), i @@ -264,7 +264,7 @@ static void readPatch( tryReadLong( patch.pcSectionID, file, - "%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s", + "%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s", fileName, sectName.c_str(), i @@ -272,7 +272,7 @@ static void readPatch( tryReadLong( patch.pcOffset, file, - "%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s", + "%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s PC offset: %s", fileName, sectName.c_str(), i @@ -281,7 +281,7 @@ static void readPatch( PatchType, type, file, - "%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s type: %s", + "%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s type: %s", fileName, sectName.c_str(), i @@ -290,7 +290,7 @@ static void readPatch( tryReadLong( rpnSize, file, - "%s: Unable to read \"%s\"'s patch #%" PRIu32 "'s RPN size: %s", + "%s: Cannot read \"%s\"'s patch #%" PRIu32 "'s RPN size: %s", fileName, sectName.c_str(), i diff --git a/src/link/section.cpp b/src/link/section.cpp index 3e7d3eea..7fc62a31 100644 --- a/src/link/section.cpp +++ b/src/link/section.cpp @@ -258,7 +258,7 @@ static void doSanityChecks(Section §ion) { error( nullptr, 0, - "%s: ROMX sections must be in bank 1 (if any) with option -t", + "Section \"%s\" has type ROMX, which must be in bank 1 (if any) with option `-t`", section.name.c_str() ); } else { @@ -270,7 +270,7 @@ static void doSanityChecks(Section §ion) { error( nullptr, 0, - "%s: WRAMX sections must be in bank 1 with options -w or -d", + "Section \"%s\" has type WRAMX, which must be in bank 1 with options `-w` or `-d`", section.name.c_str() ); } else { @@ -278,7 +278,12 @@ static void doSanityChecks(Section §ion) { } } if (isDmgMode && section.type == SECTTYPE_VRAM && section.bank == 1) { - error(nullptr, 0, "%s: VRAM bank 1 can't be used with option -d", section.name.c_str()); + error( + nullptr, + 0, + "Section \"%s\" has type VRAM, which must be in bank 0 with option `-d`", + section.name.c_str() + ); } // Check if alignment is reasonable, this is important to avoid UB @@ -292,7 +297,7 @@ static void doSanityChecks(Section §ion) { error( nullptr, 0, - "%s: %s sections cannot be aligned to $%04x bytes", + "Section \"%s\" has type %s, which cannot be aligned to $%04x bytes", section.name.c_str(), sectionTypeInfo[section.type].name.c_str(), section.alignMask + 1 diff --git a/test/link/invalid-bank-t.out b/test/link/invalid-bank-t.out index c3879a17..abbb2589 100644 --- a/test/link/invalid-bank-t.out +++ b/test/link/invalid-bank-t.out @@ -1,2 +1,2 @@ -error: test: ROMX sections must be in bank 1 (if any) with option -t +error: Section "test" has type ROMX, which must be in bank 1 (if any) with option `-t` Linking failed with 1 error diff --git a/test/link/invalid-ram-types-d.out b/test/link/invalid-ram-types-d.out new file mode 100644 index 00000000..fa19dcdc --- /dev/null +++ b/test/link/invalid-ram-types-d.out @@ -0,0 +1,3 @@ +error: Section "test1" has type WRAMX, which must be in bank 1 with options `-w` or `-d` +error: Section "test2" has type VRAM, which must be in bank 0 with option `-d` +Linking failed with 2 errors diff --git a/test/link/invalid-ram-types.asm b/test/link/invalid-ram-types.asm new file mode 100644 index 00000000..bb6fe039 --- /dev/null +++ b/test/link/invalid-ram-types.asm @@ -0,0 +1,5 @@ +SECTION "test1", WRAMX, BANK[2] +db + +SECTION "test2", VRAM, BANK[1] +db diff --git a/test/link/vram-fixed-dmg-mode-d.out b/test/link/vram-fixed-dmg-mode-d.out index bbc42471..e69647cb 100644 --- a/test/link/vram-fixed-dmg-mode-d.out +++ b/test/link/vram-fixed-dmg-mode-d.out @@ -1,2 +1,2 @@ -error: v1: VRAM bank 1 can't be used with option -d +error: Section "v1" has type VRAM, which must be in bank 0 with option `-d` Linking failed with 1 error