Skip to content

Commit

Permalink
sapemu: Actually check final CPU state
Browse files Browse the repository at this point in the history
Some test regressions (and a small nop fix), 72/256
  • Loading branch information
kleinesfilmroellchen committed Sep 8, 2024
1 parent 8ca4820 commit c40a565
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion sapemu/src/smp/ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ fn nop(cpu: &mut Smp, memory: &mut Memory, cycle: usize, state: InstructionInter
debug_instruction!("nop", cycle, cpu);

match cycle {
0 => MicroArchAction::Next,
0 => MicroArchAction::Continue(state),
1 => MicroArchAction::Next,
_ => unreachable!(),
}
}
Expand Down
22 changes: 20 additions & 2 deletions sapemu/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#![allow(unused)]

use bitflags::Flags;
use log::info;
use rstest::rstest;
use serde::Deserialize;
Expand Down Expand Up @@ -63,6 +64,17 @@ impl From<&ProcessorState> for Smp {
}
}

impl PartialEq<Smp> for ProcessorState {
fn eq(&self, other: &Smp) -> bool {
self.pc == other.pc
&& self.a == other.a
&& self.x == other.x
&& self.y == other.y
&& self.sp == other.sp
&& self.psw == other.psw.bits()
}
}

#[derive(Deserialize, Debug, Clone)]
#[repr(transparent)]
struct RamState(Vec<MemoryCellState>);
Expand Down Expand Up @@ -241,11 +253,17 @@ fn single_instruction(
memory.copy_mapped_registers_from_smp(&smp);
assert!(
test.final_state.ram == memory,
"result mismatch at test {}: {}",
"memory mismatch at test {}: {}",
test.name,
test.final_state.ram.mismatch_info(&memory)
);
// TODO: check CPU state.
assert!(
test.final_state == smp,
"cpu mismatch at test {}:\nexpected {:?}\ngot {:?}",
test.name,
test.final_state,
smp,
);
}
},
Err(why) => {
Expand Down

0 comments on commit c40a565

Please sign in to comment.