mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Add test cases for SECTION UNION defining multiple identical labels (#1349)
Exported labels should fail to link; non-exported ones should be okay.
This commit is contained in:
2
test/link/.gitignore
vendored
Normal file
2
test/link/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
# Test binaries
|
||||
/unmangle
|
||||
5
test/link/section-union/same-export/a.asm
Normal file
5
test/link/section-union/same-export/a.asm
Normal file
@@ -0,0 +1,5 @@
|
||||
SECTION UNION "test", WRAM0
|
||||
Same::
|
||||
ds 1
|
||||
Foo::
|
||||
ds 2
|
||||
5
test/link/section-union/same-export/b.asm
Normal file
5
test/link/section-union/same-export/b.asm
Normal file
@@ -0,0 +1,5 @@
|
||||
SECTION UNION "test", WRAM0
|
||||
Same::
|
||||
ds 2
|
||||
Bar::
|
||||
ds 1
|
||||
1
test/link/section-union/same-export/out.err
Normal file
1
test/link/section-union/same-export/out.err
Normal file
@@ -0,0 +1 @@
|
||||
error: "Same" both in section-union/same-export/a.o from section-union/same-export/a.asm(2) and in section-union/same-export/b.o from section-union/same-export/b.asm(2)
|
||||
5
test/link/section-union/same-label/a.asm
Normal file
5
test/link/section-union/same-label/a.asm
Normal file
@@ -0,0 +1,5 @@
|
||||
SECTION UNION "test", WRAM0
|
||||
Same:
|
||||
ds 1
|
||||
Foo:
|
||||
ds 2
|
||||
5
test/link/section-union/same-label/b.asm
Normal file
5
test/link/section-union/same-label/b.asm
Normal file
@@ -0,0 +1,5 @@
|
||||
SECTION UNION "test", WRAM0
|
||||
Same:
|
||||
ds 2
|
||||
Bar:
|
||||
ds 1
|
||||
0
test/link/section-union/same-label/out.err
Normal file
0
test/link/section-union/same-label/out.err
Normal file
@@ -3,6 +3,8 @@
|
||||
export LC_ALL=C
|
||||
set -o pipefail
|
||||
|
||||
[[ -e ./unmangle ]] || make -C ../.. test/link/unmangle || exit
|
||||
|
||||
otemp="$(mktemp)"
|
||||
gbtemp="$(mktemp)"
|
||||
gbtemp2="$(mktemp)"
|
||||
@@ -82,6 +84,16 @@ evaluateTest () {
|
||||
fi
|
||||
}
|
||||
|
||||
substPath () {
|
||||
# Escape regex metacharacters
|
||||
subst="$(printf '%s\n' "$1" | sed 's:[][\/.^$*]:\\&:g')"
|
||||
# Replace the file name with a different one to match changed output
|
||||
sed -i'' -e "s|$subst|$2|g" "$3"
|
||||
# Escape regex metacharacters in the un-MinGW-mangled path
|
||||
subst="$(./unmangle "$1" | sed 's:[][\/.^$*]:\\&:g')"
|
||||
sed -i'' -e "s|$subst|$2|g" "$3"
|
||||
}
|
||||
|
||||
for i in *.asm; do
|
||||
test=${i%.asm}
|
||||
startTest
|
||||
@@ -215,6 +227,28 @@ rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
||||
tryCmpRom "$test"/ref.out.bin
|
||||
evaluateTest
|
||||
|
||||
test="section-union/same-export"
|
||||
startTest
|
||||
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||
continueTest
|
||||
rgblinkQuiet "$gbtemp2" "$otemp" 2>"$outtemp"
|
||||
substPath "$otemp" "$test/a.o" "$outtemp"
|
||||
substPath "$gbtemp2" "$test/b.o" "$outtemp"
|
||||
tryDiff "$test"/out.err "$outtemp"
|
||||
evaluateTest
|
||||
|
||||
test="section-union/same-label"
|
||||
startTest
|
||||
"$RGBASM" -o "$otemp" "$test"/a.asm
|
||||
"$RGBASM" -o "$gbtemp2" "$test"/b.asm
|
||||
continueTest
|
||||
rgblinkQuiet "$gbtemp2" "$otemp" 2>"$outtemp"
|
||||
substPath "$otemp" "$test/a.o" "$outtemp"
|
||||
substPath "$gbtemp2" "$test/b.o" "$outtemp"
|
||||
tryDiff "$test"/out.err "$outtemp"
|
||||
evaluateTest
|
||||
|
||||
for i in section-union/*.asm; do
|
||||
test=${i%.asm}
|
||||
startTest
|
||||
|
||||
16
test/link/unmangle.cpp
Normal file
16
test/link/unmangle.cpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
/**
|
||||
* MinGW mangles path names before passing them as command-line arguments.
|
||||
* Some RGBLINK warning/error messages include those mangled paths on Windows.
|
||||
* We need to see those mangled paths in test.sh to replace them with placeholders.
|
||||
* This tool simply echoes each argument, which will be mangled iff they are paths.
|
||||
* (For example, the "/tmp/foo" will be unmangled to something like
|
||||
* "C:/Users/RUNNER~1/AppData/Local/Temp/foo".)
|
||||
*/
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
for (int i = 1; i < argc; i++)
|
||||
puts(argv[i]);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user