diff --git a/src/simulator/machine.rs b/src/simulator/machine.rs index 357b837..710b11a 100644 --- a/src/simulator/machine.rs +++ b/src/simulator/machine.rs @@ -729,15 +729,12 @@ mod test { #[test] fn test_comp() { let mut m = Machine::init_machine(); - let path_before = "memoryComp.txt".to_string(); - let path_after = "memoryCompEnd.txt".to_string(); - let memory_before = mem_cmp::MemChecker::from(&path_before).unwrap(); - let memory_after = mem_cmp::MemChecker::from(&path_after).unwrap(); + let memory_before = mem_cmp::MemChecker::from("test/machine/memoryComp.txt").unwrap(); + let memory_after = mem_cmp::MemChecker::from("test/machine/memoryCompEnd.txt").unwrap(); mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); Machine::run(&mut m); - let path_trace = "memoryCompTrace.txt".to_string(); - let expected_trace = fs::read_to_string(path_trace).unwrap(); + let expected_trace = fs::read_to_string("test/machine/memoryCompTrace.txt").unwrap(); assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); assert!(expected_trace.contains(m.registers_trace.as_str())); @@ -746,15 +743,12 @@ mod test { #[test] fn test_div() { let mut m = Machine::init_machine(); - let path_before = "memoryDiv.txt"; - let path_after = "memoryDivEnd.txt"; - let memory_before = mem_cmp::MemChecker::from(path_before).unwrap(); - let memory_after = mem_cmp::MemChecker::from(path_after).unwrap(); + let memory_before = mem_cmp::MemChecker::from("test/machine/memoryDiv.txt").unwrap(); + let memory_after = mem_cmp::MemChecker::from("test/machine/memoryDivEnd.txt").unwrap(); mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); Machine::run(&mut m); - let path_trace = "memoryDivTrace.txt".to_string(); - let expected_trace = fs::read_to_string(path_trace).unwrap(); + let expected_trace = fs::read_to_string("test/machine/memoryDivTrace.txt").unwrap(); assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); assert!(expected_trace.contains(m.registers_trace.as_str())); @@ -763,15 +757,12 @@ mod test { #[test] fn test_if() { let mut m = Machine::init_machine(); - let path_before = "memoryIf.txt".to_string(); - let path_after = "memoryIfEnd.txt".to_string(); - let memory_before = mem_cmp::MemChecker::from(&path_before).unwrap(); - let memory_after = mem_cmp::MemChecker::from(&path_after).unwrap(); + let memory_before = mem_cmp::MemChecker::from("test/machine/memoryIf.txt").unwrap(); + let memory_after = mem_cmp::MemChecker::from("test/machine/memoryIfEnd.txt").unwrap(); mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); Machine::run(&mut m); - let path_trace = "memoryIfTrace.txt".to_string(); - let expected_trace = fs::read_to_string(path_trace).unwrap(); + let expected_trace = fs::read_to_string("test/machine/memoryIfTrace.txt").unwrap(); assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); assert!(expected_trace.contains(m.registers_trace.as_str())); @@ -780,15 +771,12 @@ mod test { #[test] fn test_jump() { let mut m = Machine::init_machine(); - let path_before = "memoryJump.txt".to_string(); - let path_after = "memoryJumpEnd.txt".to_string(); - let memory_before = mem_cmp::MemChecker::from(&path_before).unwrap(); - let memory_after = mem_cmp::MemChecker::from(&path_after).unwrap(); + let memory_before = mem_cmp::MemChecker::from("test/machine/memoryJump.txt").unwrap(); + let memory_after = mem_cmp::MemChecker::from("test/machine/memoryJumpEnd.txt").unwrap(); mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); Machine::run(&mut m); - let path_trace = "memoryJumpTrace.txt".to_string(); - let expected_trace = fs::read_to_string(path_trace).unwrap(); + let expected_trace = fs::read_to_string("test/machine/memoryJumpTrace.txt").unwrap(); assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); assert!(expected_trace.contains(m.registers_trace.as_str())); @@ -797,15 +785,12 @@ mod test { #[test] fn test_mul() { let mut m = Machine::init_machine(); - let path_before = "memoryMul.txt".to_string(); - let path_after = "memoryMulEnd.txt".to_string(); - let memory_before = mem_cmp::MemChecker::from(&path_before).unwrap(); - let memory_after = mem_cmp::MemChecker::from(&path_after).unwrap(); + let memory_before = mem_cmp::MemChecker::from("test/machine/memoryMul.txt").unwrap(); + let memory_after = mem_cmp::MemChecker::from("test/machine/memoryMulEnd.txt").unwrap(); mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); Machine::run(&mut m); - let path_trace = "memoryMulTrace.txt".to_string(); - let expected_trace = fs::read_to_string(path_trace).unwrap(); + let expected_trace = fs::read_to_string("test/machine/memoryMulTrace.txt").unwrap(); assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); assert!(expected_trace.contains(m.registers_trace.as_str())); @@ -814,15 +799,12 @@ mod test { #[test] fn test_ret() { let mut m = Machine::init_machine(); - let path_before = "memoryRet.txt".to_string(); - let path_after = "memoryRetEnd.txt".to_string(); - let memory_before = mem_cmp::MemChecker::from(&path_before).unwrap(); - let memory_after = mem_cmp::MemChecker::from(&path_after).unwrap(); + let memory_before = mem_cmp::MemChecker::from("test/machine/memoryRet.txt").unwrap(); + let memory_after = mem_cmp::MemChecker::from("test/machine/memoryRetEnd.txt").unwrap(); mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); Machine::run(&mut m); - let path_trace = "memoryRetTrace.txt".to_string(); - let expected_trace = fs::read_to_string(path_trace).unwrap(); + let expected_trace = fs::read_to_string("test/machine/memoryRetTrace.txt").unwrap(); assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); assert!(expected_trace.contains(m.registers_trace.as_str())); @@ -831,15 +813,12 @@ mod test { #[test] fn test_sub() { let mut m = Machine::init_machine(); - let path_before = "memorySub.txt".to_string(); - let path_after = "memorySubEnd.txt".to_string(); - let memory_before = mem_cmp::MemChecker::from(&path_before).unwrap(); - let memory_after = mem_cmp::MemChecker::from(&path_after).unwrap(); + let memory_before = mem_cmp::MemChecker::from("test/machine/memorySub.txt").unwrap(); + let memory_after = mem_cmp::MemChecker::from("test/machine/memorySubEnd.txt").unwrap(); mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); Machine::run(&mut m); - let path_trace = "memorySubTrace.txt".to_string(); - let expected_trace = fs::read_to_string(path_trace).unwrap(); + let expected_trace = fs::read_to_string("test/machine/memorySubTrace.txt").unwrap(); assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); assert!(expected_trace.contains(m.registers_trace.as_str())); @@ -848,15 +827,12 @@ mod test { #[test] fn test_switch() { let mut m = Machine::init_machine(); - let path_before = "memorySwitch.txt".to_string(); - let path_after = "memorySwitchEnd.txt".to_string(); - let memory_before = mem_cmp::MemChecker::from(&path_before).unwrap(); - let memory_after = mem_cmp::MemChecker::from(&path_after).unwrap(); + let memory_before = mem_cmp::MemChecker::from("test/machine/memorySwitch.txt").unwrap(); + let memory_after = mem_cmp::MemChecker::from("test/machine/memorySwitchEnd.txt").unwrap(); mem_cmp::MemChecker::fill_memory_from_mem_checker(&memory_before, &mut m); Machine::run(&mut m); - let path_trace = "memorySwitchTrace.txt".to_string(); - let expected_trace = fs::read_to_string(path_trace).unwrap(); + let expected_trace = fs::read_to_string("test/machine/memorySwitchTrace.txt").unwrap(); assert!(mem_cmp::MemChecker::compare_machine_memory(&memory_after, &m)); assert!(expected_trace.contains(m.registers_trace.as_str())); diff --git a/test_programs/.gitignore b/test/.gitignore similarity index 100% rename from test_programs/.gitignore rename to test/.gitignore diff --git a/test_programs/Makefile b/test/Makefile similarity index 100% rename from test_programs/Makefile rename to test/Makefile diff --git a/test_programs/Makefile.config b/test/Makefile.config similarity index 100% rename from test_programs/Makefile.config rename to test/Makefile.config diff --git a/test_programs/Makefile.tests b/test/Makefile.tests similarity index 100% rename from test_programs/Makefile.tests rename to test/Makefile.tests diff --git a/test_programs/README.md b/test/README.md similarity index 100% rename from test_programs/README.md rename to test/README.md diff --git a/test_programs/riscv_instructions/Makefile b/test/riscv_instructions/Makefile similarity index 100% rename from test_programs/riscv_instructions/Makefile rename to test/riscv_instructions/Makefile diff --git a/test_programs/riscv_instructions/boolean_logic/Makefile b/test/riscv_instructions/boolean_logic/Makefile similarity index 100% rename from test_programs/riscv_instructions/boolean_logic/Makefile rename to test/riscv_instructions/boolean_logic/Makefile diff --git a/test_programs/riscv_instructions/boolean_logic/comparisons.c b/test/riscv_instructions/boolean_logic/comparisons.c similarity index 100% rename from test_programs/riscv_instructions/boolean_logic/comparisons.c rename to test/riscv_instructions/boolean_logic/comparisons.c diff --git a/test_programs/riscv_instructions/boolean_logic/if.c b/test/riscv_instructions/boolean_logic/if.c similarity index 100% rename from test_programs/riscv_instructions/boolean_logic/if.c rename to test/riscv_instructions/boolean_logic/if.c diff --git a/test_programs/riscv_instructions/boolean_logic/new_comparisons.c b/test/riscv_instructions/boolean_logic/new_comparisons.c similarity index 100% rename from test_programs/riscv_instructions/boolean_logic/new_comparisons.c rename to test/riscv_instructions/boolean_logic/new_comparisons.c diff --git a/test_programs/riscv_instructions/boolean_logic/switch.c b/test/riscv_instructions/boolean_logic/switch.c similarity index 100% rename from test_programs/riscv_instructions/boolean_logic/switch.c rename to test/riscv_instructions/boolean_logic/switch.c diff --git a/test_programs/riscv_instructions/jump_instructions/Makefile b/test/riscv_instructions/jump_instructions/Makefile similarity index 100% rename from test_programs/riscv_instructions/jump_instructions/Makefile rename to test/riscv_instructions/jump_instructions/Makefile diff --git a/test_programs/riscv_instructions/jump_instructions/jump.c b/test/riscv_instructions/jump_instructions/jump.c similarity index 100% rename from test_programs/riscv_instructions/jump_instructions/jump.c rename to test/riscv_instructions/jump_instructions/jump.c diff --git a/test_programs/riscv_instructions/jump_instructions/ret.c b/test/riscv_instructions/jump_instructions/ret.c similarity index 100% rename from test_programs/riscv_instructions/jump_instructions/ret.c rename to test/riscv_instructions/jump_instructions/ret.c diff --git a/test_programs/riscv_instructions/simple_arithmetics/Makefile b/test/riscv_instructions/simple_arithmetics/Makefile similarity index 100% rename from test_programs/riscv_instructions/simple_arithmetics/Makefile rename to test/riscv_instructions/simple_arithmetics/Makefile diff --git a/test_programs/riscv_instructions/simple_arithmetics/README.md b/test/riscv_instructions/simple_arithmetics/README.md similarity index 100% rename from test_programs/riscv_instructions/simple_arithmetics/README.md rename to test/riscv_instructions/simple_arithmetics/README.md diff --git a/test_programs/riscv_instructions/simple_arithmetics/unsigned_addition.c b/test/riscv_instructions/simple_arithmetics/unsigned_addition.c similarity index 100% rename from test_programs/riscv_instructions/simple_arithmetics/unsigned_addition.c rename to test/riscv_instructions/simple_arithmetics/unsigned_addition.c diff --git a/test_programs/riscv_instructions/simple_arithmetics/unsigned_division.c b/test/riscv_instructions/simple_arithmetics/unsigned_division.c similarity index 100% rename from test_programs/riscv_instructions/simple_arithmetics/unsigned_division.c rename to test/riscv_instructions/simple_arithmetics/unsigned_division.c diff --git a/test_programs/riscv_instructions/simple_arithmetics/unsigned_multiplication.c b/test/riscv_instructions/simple_arithmetics/unsigned_multiplication.c similarity index 100% rename from test_programs/riscv_instructions/simple_arithmetics/unsigned_multiplication.c rename to test/riscv_instructions/simple_arithmetics/unsigned_multiplication.c diff --git a/test_programs/riscv_instructions/simple_arithmetics/unsigned_substraction.c b/test/riscv_instructions/simple_arithmetics/unsigned_substraction.c similarity index 100% rename from test_programs/riscv_instructions/simple_arithmetics/unsigned_substraction.c rename to test/riscv_instructions/simple_arithmetics/unsigned_substraction.c diff --git a/test_programs/userlib/Makefile b/test/userlib/Makefile similarity index 100% rename from test_programs/userlib/Makefile rename to test/userlib/Makefile diff --git a/test_programs/userlib/ldscript.lds b/test/userlib/ldscript.lds similarity index 100% rename from test_programs/userlib/ldscript.lds rename to test/userlib/ldscript.lds diff --git a/test_programs/userlib/libnachos.c b/test/userlib/libnachos.c similarity index 100% rename from test_programs/userlib/libnachos.c rename to test/userlib/libnachos.c diff --git a/test_programs/userlib/libnachos.h b/test/userlib/libnachos.h similarity index 100% rename from test_programs/userlib/libnachos.h rename to test/userlib/libnachos.h diff --git a/test_programs/userlib/sys.s b/test/userlib/sys.s similarity index 100% rename from test_programs/userlib/sys.s rename to test/userlib/sys.s diff --git a/test_programs/userlib/syscall.h b/test/userlib/syscall.h similarity index 100% rename from test_programs/userlib/syscall.h rename to test/userlib/syscall.h diff --git a/test_programs/userlib/libnachos.o b/test_programs/userlib/libnachos.o deleted file mode 100644 index 26f4cca..0000000 Binary files a/test_programs/userlib/libnachos.o and /dev/null differ diff --git a/test_programs/userlib/sys.o b/test_programs/userlib/sys.o deleted file mode 100644 index 9478fef..0000000 Binary files a/test_programs/userlib/sys.o and /dev/null differ