aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--.gitmodules6
-rwxr-xr-xscripts/test-e2e.sh121
m---------tests/aoc2023.nes0
-rw-r--r--tests/aoc2023.nes.tar.gzbin460712 -> 0 bytes
-rw-r--r--tests/cfg/nrom65.cfg62
m---------tests/code.nes0
-rw-r--r--tests/code.nes.tar.gzbin51347 -> 0 bytes
8 files changed, 173 insertions, 20 deletions
diff --git a/.gitignore b/.gitignore
index 9eeba11..4e70798 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
/target
-*.nes
-tests/code.nes
+/*.nes
+tests/out/*.nes
TODO
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..7dd6a24
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,6 @@
+[submodule "tests/aoc2023.nes"]
+ path = tests/aoc2023.nes
+ url = git@github.com:mssola/aoc2023.nes
+[submodule "tests/code.nes"]
+ path = tests/code.nes
+ url = git@github.com:mssola/code.nes
diff --git a/scripts/test-e2e.sh b/scripts/test-e2e.sh
index 2185768..3eb5754 100755
--- a/scripts/test-e2e.sh
+++ b/scripts/test-e2e.sh
@@ -1,48 +1,133 @@
#!/usr/bin/env sh
-set -ex
+# Instead of setting -e or something like that, we will accumulate errors and
+# exit with the accumulated result at the end.
+exit_code=0
+
+AS65=${AS65:-"./target/debug/xa65"}
+
+##
+# Ensure git submodules are there and that the environment is set up correctly.
pushd tests
rm -rf out/
mkdir -p out/
-rm -rf code.nes
-tar xzf code.nes.tar.gz
+if [ ! -d code.nes ]; then
+ echo "(error) You need 'code.nes' for end-to-end tests."
+ exit 1
+fi
+
+if [ ! -d aoc2023.nes ]; then
+ echo "(error) You need 'aoc2023.nes' for end-to-end tests."
+ exit 1
+fi
-rm -rf aoc2023.nes
-tar xzf aoc2023.nes.tar.gz
popd
+##
+# Build.
+
+echo "(info): build development binaries"
cargo build
-# Custom
+##
+# Custom tests.
+echo "test: custom => defines-undefines.nes"
./target/debug/nasm -c empty -Werror -o tests/out/defines-undefined.nes tests/defines.s
diff tests/out/defines-undefined.nes tests/expected/defines-undefined.nes
+exit_code=$((exit_code + $?))
+echo "test: custom => defines-one.nes"
./target/debug/nasm -D LALA -c empty -Werror -o tests/out/defines-one.nes tests/defines.s
diff tests/out/defines-one.nes tests/expected/defines-one.nes
+exit_code=$((exit_code + $?))
+echo "test: custom => defines-two.nes"
./target/debug/nasm -D LALA=2 -c empty -Werror -o tests/out/defines-two.nes tests/defines.s
diff tests/out/defines-two.nes tests/expected/defines-two.nes
+exit_code=$((exit_code + $?))
+##
# code.nes
-./target/debug/nasm -c nrom -Werror -o tests/out/sprite.nes tests/code.nes/basics/sprite.s
-diff tests/out/sprite.nes tests/code.nes/out/basics/sprite.nes
+echo "test: code.nes => basics/sprite.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/basics/sprite.s
+exit_code=$((exit_code + $?))
+
+echo "test: code.nes => basics/input.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/basics/input.s
+exit_code=$((exit_code + $?))
+
+echo "test: code.nes => basics/persist.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc1.cfg -o /dev/null tests/code.nes/basics/persist.s
+exit_code=$((exit_code + $?))
+
+echo "test: code.nes => basics/flicker.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/basics/flicker.s
+exit_code=$((exit_code + $?))
+
+echo "test: code.nes => basics/unrom.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/unrom.cfg -o /dev/null tests/code.nes/basics/unrom.s
+exit_code=$((exit_code + $?))
+
+echo "test: code.nes => basics/chr-ram.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/unrom.cfg -o /dev/null tests/code.nes/basics/chr-ram.s
+exit_code=$((exit_code + $?))
+
+echo "test: code.nes => fx/blink.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc3.cfg -o /dev/null tests/code.nes/fx/blink.s
+exit_code=$((exit_code + $?))
-./target/debug/nasm -c unrom -Werror -o tests/out/chr-ram.nes tests/code.nes/basics/chr-ram.s
-diff tests/out/chr-ram.nes tests/code.nes/out/basics/chr-ram.nes
+echo "test: code.nes => scroll/toggle.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/scroll/toggle.s
+exit_code=$((exit_code + $?))
-./target/debug/nasm -c nrom -Werror -o tests/out/flicker.nes tests/code.nes/basics/flicker.s
-diff tests/out/flicker.nes tests/code.nes/out/basics/flicker.nes
+echo "test: code.nes => scroll/level.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/scroll/level.s
+exit_code=$((exit_code + $?))
-./target/debug/nasm -c nrom -Werror -o tests/out/space.nes tests/code.nes/space/src/space.s
-diff tests/out/space.nes tests/code.nes/out/space/space.nes
+echo "test: code.nes => scroll/sprite0.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/scroll/sprite0.s
+exit_code=$((exit_code + $?))
+echo "test: code.nes => scroll/mmc3.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc3.cfg -o /dev/null tests/code.nes/scroll/mmc3.s
+exit_code=$((exit_code + $?))
+
+echo "test: code.nes => rand/rand.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/rand/rand.s
+exit_code=$((exit_code + $?))
+
+echo "test: code.nes => scroll/roulette.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/mmc3.cfg -o /dev/null tests/code.nes/scroll/roulette.s
+exit_code=$((exit_code + $?))
+
+echo "test: code.nes => space/space.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/code.nes/config/nrom.cfg -o /dev/null tests/code.nes/space/src/space.s
+exit_code=$((exit_code + $?))
+
+##
# aoc2023.nes
-./target/debug/nasm -c tests/aoc2023.nes/config/nes.cfg -o tests/out/1.nes tests/aoc2023.nes/src/1.s
-./target/debug/nasm -c tests/aoc2023.nes/config/nes.cfg -o tests/out/2.nes tests/aoc2023.nes/src/2.s
-./target/debug/nasm -c tests/aoc2023.nes/config/nes.cfg -o tests/out/3.nes tests/aoc2023.nes/src/3.s
-./target/debug/nasm -c tests/aoc2023.nes/config/nes.cfg -o tests/out/4.nes tests/aoc2023.nes/src/4.s
+echo "test: aoc2023.nes => 1.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/1.s
+exit_code=$((exit_code + $?))
+
+echo "test: aoc2023.nes => 2.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/2.s
+exit_code=$((exit_code + $?))
+
+echo "test: aoc2023.nes => 3.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/3.s
+exit_code=$((exit_code + $?))
+
+echo "test: aoc2023.nes => 4.nes"
+$AS65 --strict -b ./target/debug/nasm -C tests/cfg/nrom65.cfg -o /dev/null tests/aoc2023.nes/src/4.s
+exit_code=$((exit_code + $?))
+
+##
+# Done!
+
+exit $exit_code
diff --git a/tests/aoc2023.nes b/tests/aoc2023.nes
new file mode 160000
+Subproject e1de44339093a3d47b0257aded13de405a3e861
diff --git a/tests/aoc2023.nes.tar.gz b/tests/aoc2023.nes.tar.gz
deleted file mode 100644
index b21d3e1..0000000
--- a/tests/aoc2023.nes.tar.gz
+++ /dev/null
Binary files differ
diff --git a/tests/cfg/nrom65.cfg b/tests/cfg/nrom65.cfg
new file mode 100644
index 0000000..bb7d234
--- /dev/null
+++ b/tests/cfg/nrom65.cfg
@@ -0,0 +1,62 @@
+SYMBOLS {
+ __STACKSIZE__: type = weak, value = $0300; # 3 pages stack
+}
+MEMORY {
+ ZP: file = "", start = $0002, size = $001A, type = rw, define = yes;
+
+ # INES Cartridge Header
+ HEADER: file = %O, start = $0000, size = $0010, fill = yes;
+
+ # 2 16K ROM Banks
+ # - startup
+ # - code
+ # - rodata
+ # - data (load)
+ ROM0: file = %O, start = $8000, size = $7FFA, fill = yes, define = yes;
+
+ # Hardware Vectors at End of 2nd 8K ROM
+ ROMV: file = %O, start = $FFFA, size = $0006, fill = yes;
+
+ # 1 8k CHR Bank
+ ROM2: file = %O, start = $0000, size = $2000, fill = yes;
+
+ # standard 2k SRAM (-zeropage)
+ # $0100-$0200 cpu stack
+ # $0200-$0500 3 pages for ppu memory write buffer
+ # $0500-$0800 3 pages for cc65 parameter stack
+ SRAM: file = "", start = $0500, size = __STACKSIZE__, define = yes;
+
+ # additional 8K SRAM Bank
+ # - data (run)
+ # - bss
+ # - heap
+ RAM: file = "", start = $6000, size = $2000, define = yes;
+}
+SEGMENTS {
+ ZEROPAGE: load = ZP, type = zp;
+ HEADER: load = HEADER, type = ro;
+ STARTUP: load = ROM0, type = ro, define = yes;
+ LOWCODE: load = ROM0, type = ro, optional = yes;
+ ONCE: load = ROM0, type = ro, optional = yes;
+ CODE: load = ROM0, type = ro, define = yes;
+ RODATA: load = ROM0, type = ro, define = yes;
+ DATA: load = ROM0, run = RAM, type = rw, define = yes;
+ VECTORS: load = ROMV, type = rw;
+ CHARS: load = ROM2, type = rw;
+ BSS: load = RAM, type = bss, define = yes;
+}
+FEATURES {
+ CONDES: type = constructor,
+ label = __CONSTRUCTOR_TABLE__,
+ count = __CONSTRUCTOR_COUNT__,
+ segment = ONCE;
+ CONDES: type = destructor,
+ label = __DESTRUCTOR_TABLE__,
+ count = __DESTRUCTOR_COUNT__,
+ segment = RODATA;
+ CONDES: type = interruptor,
+ label = __INTERRUPTOR_TABLE__,
+ count = __INTERRUPTOR_COUNT__,
+ segment = RODATA,
+ import = __CALLIRQ__;
+}
diff --git a/tests/code.nes b/tests/code.nes
new file mode 160000
+Subproject cdf9137af1d600c27bf0750615027859c9c2415
diff --git a/tests/code.nes.tar.gz b/tests/code.nes.tar.gz
deleted file mode 100644
index 437bbed..0000000
--- a/tests/code.nes.tar.gz
+++ /dev/null
Binary files differ