From 8b4d5be49d9ad219eadefe91873bddaf2d09556a Mon Sep 17 00:00:00 2001 From: John Breaux Date: Sat, 29 Apr 2023 18:38:38 -0500 Subject: [PATCH] tests: Update tests for memory being CPU-internal --- src/cpu/tests.rs | 4 ++-- tests/chip8_test_suite.rs | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/cpu/tests.rs b/src/cpu/tests.rs index 7bf986a..f1f1233 100644 --- a/src/cpu/tests.rs +++ b/src/cpu/tests.rs @@ -704,7 +704,7 @@ mod io { ScreenTest { program: include_bytes!("../../chip-8/IBM Logo.ch8"), screen: include_bytes!("tests/screens/IBM Logo.ch8/20.bin"), - steps: 56, + steps: 21, quirks: Quirks { bin_ops: false, shift: false, @@ -1151,7 +1151,7 @@ mod behavior { cpu.pc = 0xfff; match cpu.tick(&mut bus) { Err(Error::InvalidAddressRange { range }) => { - eprintln!("InvalidBusRange {{ {range:04x?} }}") + eprintln!("InvalidAddressRange {{ {range:04x?} }}") } other => unreachable!("{other:04x?}"), } diff --git a/tests/chip8_test_suite.rs b/tests/chip8_test_suite.rs index 8a9bf19..d79e6b0 100644 --- a/tests/chip8_test_suite.rs +++ b/tests/chip8_test_suite.rs @@ -16,12 +16,8 @@ fn setup_environment() -> (CPU, Bus) { ( cpu, bus! { - // Load the charset into ROM - Charset [0x0050..0x00A0] = include_bytes!("../src/mem/charset.bin"), - // Load the ROM file into RAM - Program [0x0200..0x1000], // Create a screen, and fill it with garbage - Screen [0x0F00..0x1000] = b"jsuadhgufywegrwsdyfogbbg4owgbrt", + Screen [0x000..0x100] = b"jsuadhgufywegrwsdyfogbbg4owgbrt", }, ) } @@ -34,11 +30,14 @@ struct SuiteTest { fn run_screentest(test: SuiteTest, mut cpu: CPU, mut bus: Bus) { // Set the test to run - bus.write(0x1ffu16, test.test); + cpu.poke(0x1ffu16, test.test); cpu.load_program_bytes(test.data).unwrap(); // The test suite always initiates a keypause on test completion while !(cpu.flags.is_paused()) { cpu.multistep(&mut bus, 10).unwrap(); + if cpu.cycle() > 1000000 { + panic!("test {} took too long", test.test) + } } // Compare the screen to the reference screen buffer bus.print_screen().unwrap();