Fix shutdown test exception

This commit is contained in:
Quentin Legot 2023-05-07 16:09:45 +02:00
parent c862c42e43
commit 2884d5d479

View File

@ -353,9 +353,18 @@ mod test {
let mut machine = Machine::new(true, get_debug_configuration()); let mut machine = Machine::new(true, get_debug_configuration());
machine.write_int_register(17, SC_SHUTDOWN as i64); // Set type to shutdown machine.write_int_register(17, SC_SHUTDOWN as i64); // Set type to shutdown
// let ecall = Instruction::new(0b000000000000_00000_000_00000_1110011); // let ecall = Instruction::new(0b000000000000_00000_000_00000_1110011);
let insts: [u8; 4] = 0b000000000000_00000_000_00000_1110011_u32.to_le_bytes();
machine.write_memory(4, 0, 0b000000000000_00000_000_00000_1110011); // ecall machine.write_memory(1, 0, insts[0] as u64);
machine.write_memory(4, 4, 0b000000001010_00000_000_00001_0010011); // r1 <- 10 machine.write_memory(1, 1, insts[1] as u64);
machine.write_memory(1, 2, insts[2] as u64);
machine.write_memory(1, 3, insts[3] as u64); // ecall
// machine.write_memory(4, 0, 0b000000000000_00000_000_00000_1110011_u64.to_be()); // ecall
let insts: [u8; 4] = 0b000000001010_00000_000_00001_0010011_u32.to_le_bytes();
machine.write_memory(1, 4, insts[0] as u64);
machine.write_memory(1, 5, insts[1] as u64);
machine.write_memory(1, 6, insts[2] as u64);
machine.write_memory(1, 7, insts[3] as u64); // r1 <- 10
// machine.write_memory(4, 4, 0b000000001010_00000_000_00001_0010011_u64.to_be()); // r1 <- 10
let mut system = System::new(true); let mut system = System::new(true);
machine.run(&mut system); machine.run(&mut system);
// If the machine was stopped with no error, the shutdown worked // If the machine was stopped with no error, the shutdown worked