diff --git a/src/simulator/machine.rs b/src/simulator/machine.rs index 6f73b1c..69a9e43 100644 --- a/src/simulator/machine.rs +++ b/src/simulator/machine.rs @@ -221,7 +221,7 @@ impl Machine { } } - /// Execute the instructions table of a machine putted in param + /// Execute the instructions table of a machine put in param /// /// ### Parameters /// @@ -237,6 +237,19 @@ impl Machine { } } + /// Execute the instructions table of a machine put in param + /// **WITHOUT INTERPRETING SYSCALLS** + /// + /// For debug purposes + pub fn _run_debug(&mut self, system: &mut System) { + loop { + match self.one_instruction(system) { + Ok(_) => (), + _ => break + } + } + } + /// Execute the current instruction /// /// ### Parameters @@ -694,10 +707,15 @@ impl Default for Machine { } #[cfg(test)] + mod test { use std::fs; use crate::simulator::{machine::Machine, mem_cmp}; + use crate::kernel::thread::Thread; + use crate::kernel::process::Process; + use std::rc::Rc; + use std::cell::RefCell; macro_rules! get_full_path { ($prefix: expr, $test_name:expr) => {{ @@ -717,7 +735,7 @@ mod test { let memory_after = mem_cmp::MemChecker::from(get_full_path!("memory", &end_file_name)).unwrap(); mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); let mut system = crate::kernel::system::System::default(); - m.run(&mut system); + m._run_debug(&mut system); let expected_trace = fs::read_to_string(get_full_path!("reg_trace", $a)).unwrap(); assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); assert!(expected_trace.contains(m.registers_trace.as_str()));