Fix loader test, only use one bin file in test_thread_context
This commit is contained in:
parent
cfb58fd6b3
commit
b804117127
@ -225,9 +225,9 @@ fn get_string_param(addr: i64, maxlen: usize, machine: &Machine) -> Vec<char>{
|
||||
let mut c = 1;
|
||||
|
||||
while c != 0 && i < maxlen {
|
||||
c = machine.read_memory(1, addr as usize + i);
|
||||
c = machine.read_memory(1, addr as usize + i) as u8;
|
||||
//dest.push(c as char);
|
||||
dest[i] = c as u8 as char;
|
||||
dest[i] = c as char;
|
||||
i += 1;
|
||||
}
|
||||
|
||||
|
@ -205,12 +205,10 @@ mod test {
|
||||
use crate::{simulator::{machine::Machine, loader}, kernel::{system::System, thread::{Thread, self}, process::Process}};
|
||||
|
||||
#[test]
|
||||
#[ignore = "Pas encore terminé, contient des bugs"]
|
||||
fn test_thread_context() {
|
||||
let mut machine = Machine::init_machine();
|
||||
let (loader, ptr1) = loader::Loader::new("./test/riscv_instructions/simple_arithmetics/unsigned_addition", &mut machine, 0).expect("IO Error");
|
||||
println!("{}", ptr1);
|
||||
let (loader2, ptr2) = loader::Loader::new("./test/riscv_instructions/syscall_tests/halt", &mut machine, ptr1 as usize).expect("IO Error");
|
||||
let mut machine = Machine::default();
|
||||
|
||||
let (loader, ptr) = loader::Loader::new("./test/riscv_instructions/syscall_tests/halt", &mut machine, 0).expect("IO Error");
|
||||
let start_pc = loader.elf_header.entrypoint;
|
||||
let system = &mut System::default();
|
||||
|
||||
@ -218,18 +216,11 @@ mod test {
|
||||
let thread1 = Rc::new(RefCell::new(thread1));
|
||||
system.get_thread_manager().get_g_alive().push(Rc::clone(&thread1));
|
||||
|
||||
let thread2 = Thread::new("th2");
|
||||
let thread2 = Rc::new(RefCell::new(thread2));
|
||||
system.get_thread_manager().get_g_alive().push(Rc::clone(&thread1));
|
||||
|
||||
let owner1 = Process { num_thread: 0 };
|
||||
system.get_thread_manager().start_thread(Rc::clone(&thread1), owner1, loader.elf_header.entrypoint, ptr1, -1);
|
||||
system.get_thread_manager().start_thread(Rc::clone(&thread1), owner1, loader.elf_header.entrypoint, ptr, -1);
|
||||
debug_assert_eq!(thread1.borrow_mut().thread_context.pc, start_pc);
|
||||
debug_assert!(system.get_thread_manager().get_g_alive().contains(&Rc::clone(&thread1)));
|
||||
|
||||
let owner2 = Process { num_thread: 0 };
|
||||
system.get_thread_manager().start_thread(Rc::clone(&thread2), owner2, ptr1 + loader2.elf_header.entrypoint, ptr2 , -1);
|
||||
|
||||
let to_run = system.get_thread_manager().find_next_to_run().unwrap();
|
||||
debug_assert_eq!(to_run, Rc::clone(&thread1));
|
||||
|
||||
|
@ -612,7 +612,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_parse_elf() {
|
||||
let mut machine = Machine::init_machine();
|
||||
let mut machine = Machine::default();
|
||||
let loader = Loader::load_and_parse("./test/riscv_instructions/simple_arithmetics/unsigned_addition").expect("IO Error");
|
||||
loader.load_into_machine(&mut machine, 0).expect("Parsing error");
|
||||
assert!(!loader.elf_header.is_32bits);
|
||||
@ -623,7 +623,7 @@ mod test {
|
||||
assert_eq!(0x4000, loader.elf_header.entrypoint);
|
||||
assert_eq!(64, loader.elf_header.elf_header_size);
|
||||
assert_eq!(64, loader.elf_header.program_header_location);
|
||||
assert_eq!(18984, loader.elf_header.section_header_location);
|
||||
assert_eq!(18992, loader.elf_header.section_header_location);
|
||||
assert_eq!(56, loader.elf_header.program_header_size);
|
||||
assert_eq!(64, loader.elf_header.section_header_size);
|
||||
assert_eq!(4, loader.elf_header.program_header_entries);
|
||||
@ -633,7 +633,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_parse_section() {
|
||||
let mut machine = Machine::init_machine();
|
||||
let mut machine = Machine::default();
|
||||
let loader = Loader::load_and_parse("./test/riscv_instructions/simple_arithmetics/unsigned_addition").expect("IO Error");
|
||||
loader.load_into_machine(&mut machine, 0).expect("Parsing error");
|
||||
assert_eq!(9, loader.sections.len());
|
||||
|
Loading…
Reference in New Issue
Block a user