Complete initial tests for startup
Some checks failed
Cargo Build & Test / Rust project - latest (stable) (push) Failing after 8s

This commit is contained in:
2025-12-14 14:44:54 -06:00
parent af770d232c
commit ce4532bcdf
8 changed files with 429 additions and 64 deletions

View File

@@ -15,6 +15,20 @@ macro_rules! rom_test {
$eval
}
};
($name:ident, . $rom:literal, |$nes:ident| $eval:expr) => {
rom_test!($name, . $rom, timeout = 10000000, |$nes| $eval);
};
($name:ident, . $rom:literal, timeout = $timeout:expr, |$nes:ident| $eval:expr) => {
#[test]
fn $name() {
let rom_file = $rom;
println!("{}: {}", stringify!($name), rom_file);
let mut $nes = NES::load_nes_file(rom_file).expect("Failed to create nes object");
$nes.reset_and_run_with_timeout($timeout);
println!("Final: {:?}", $nes);
$eval
}
};
}
rom_test!(basic_cpu, "basic-cpu.nes", |nes| {
@@ -23,6 +37,8 @@ rom_test!(basic_cpu, "basic-cpu.nes", |nes| {
assert_eq!(nes.cycle, 11);
// This is off by one from Mesen, because Mesen is left pointing at the 'invalid' opcode
assert_eq!(nes.cpu.pc, 0x8002);
// Off by one from Mesen, since Mesen doesn't count the clock cycle attempting to execute the 'invalid' opcode
assert_eq!(nes.ppu.pixel, 35);
assert_eq!(nes.cpu.sp, 0xFD);
// assert_eq!(nes.cpu.a, 0x00);
@@ -35,6 +51,7 @@ rom_test!(read_write, "read_write.nes", |nes| {
assert_eq!(nes.cycle, 31);
assert_eq!(nes.cpu.pc, 0x8012);
assert_eq!(nes.cpu.sp, 0xFD);
assert_eq!(nes.cpu.a, 0xAA);
assert_eq!(nes.cpu.x, 0xAA);
assert_eq!(nes.cpu.y, 0xAA);
@@ -48,6 +65,7 @@ rom_test!(basic_init_0, "basic_init_0.nes", |nes| {
assert_eq!(nes.cycle, 41);
assert_eq!(nes.cpu.pc, 0x8018);
assert_eq!(nes.cpu.sp, 0xFF);
assert_eq!(nes.cpu.a, 0x00);
assert_eq!(nes.cpu.x, 0x00);
assert_eq!(nes.cpu.y, 0x00);
@@ -56,10 +74,59 @@ rom_test!(basic_init_0, "basic_init_0.nes", |nes| {
rom_test!(basic_init_1, "basic_init_1.nes", |nes| {
assert_eq!(nes.last_instruction, "0x801C HLT :2 []");
assert_eq!(nes.cycle, 27403);
assert_eq!(nes.ppu.pixel, 30);
assert_eq!(nes.cpu.pc, 0x801D);
assert_eq!(nes.ppu.pixel, 30);
assert_eq!(nes.cpu.sp, 0xFF);
assert_eq!(nes.cpu.a, 0x00);
assert_eq!(nes.cpu.x, 0x00);
assert_eq!(nes.cpu.y, 0x00);
});
rom_test!(basic_init_2, "basic_init_2.nes", |nes| {
assert_eq!(nes.last_instruction, "0x8021 HLT :2 []");
assert_eq!(nes.cycle, 57180);
assert_eq!(nes.cpu.pc, 0x8022);
assert_eq!(nes.ppu.pixel, 19);
assert_eq!(nes.cpu.sp, 0xFF);
assert_eq!(nes.cpu.a, 0x00);
assert_eq!(nes.cpu.x, 0x00);
assert_eq!(nes.cpu.y, 0x00);
});
rom_test!(basic_init_3, "basic_init_3.nes", |nes| {
assert_eq!(nes.last_instruction, "0x8026 HLT :2 []");
assert_eq!(nes.cycle, 86964);
assert_eq!(nes.cpu.pc, 0x8027);
assert_eq!(nes.ppu.pixel, 29);
assert_eq!(nes.cpu.sp, 0xFF);
assert_eq!(nes.cpu.a, 0x00);
assert_eq!(nes.cpu.x, 0x00);
assert_eq!(nes.cpu.y, 0x00);
});
rom_test!(even_odd, "even_odd.nes", |nes| {
assert_eq!(nes.last_instruction, "0x8023 HLT :2 []");
assert_eq!(nes.cycle, 57182);
assert_eq!(nes.cpu.pc, 0x8024);
assert_eq!(nes.ppu.pixel, 25);
assert_eq!(nes.cpu.sp, 0xFF);
assert_eq!(nes.cpu.a, 0x00);
assert_eq!(nes.cpu.x, 0x08);
assert_eq!(nes.cpu.y, 0x00);
});
// rom_test!(even_odd, "even_odd.nes", |nes| {
// assert_eq!(nes.last_instruction, "0x8023 HLT :2 []");
// assert_eq!(nes.cycle, 57182);
// assert_eq!(nes.cpu.pc, 0x8024);
// assert_eq!(nes.ppu.pixel, 25);
// assert_eq!(nes.cpu.sp, 0xFF);
// assert_eq!(nes.cpu.a, 0x00);
// assert_eq!(nes.cpu.x, 0x08);
// assert_eq!(nes.cpu.y, 0x00);
// });