mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-15 23:18:48 +00:00
Improve --irrun option to print byte size value
This commit is contained in:
@@ -116,7 +116,13 @@ fn compile_ir(
|
||||
|
||||
if matches.is_present("irrun") {
|
||||
let result = ir::interp(input, Vec::new()).unwrap();
|
||||
println!("[result] {:?}", result);
|
||||
let (value, width, is_signed) = result.get_int().expect("non-integer value occurs");
|
||||
assert_eq!(width, 32);
|
||||
assert!(is_signed);
|
||||
|
||||
// When obtain status from `gcc` executable process, status value is truncated to byte size.
|
||||
// So, we also truncate result value to byte size before printing it.
|
||||
println!("[result] {:?}", value as u8);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
12
src/tests.rs
12
src/tests.rs
@@ -115,8 +115,8 @@ pub fn test_irgen(path: &Path) {
|
||||
// For this reason, we make `fuzzer` generate the C source code which returns value
|
||||
// typecasted to `unsigned char`. However, during `creduce` reduce the code, typecasting
|
||||
// may be deleted. So, we truncate result value to byte size one more time here.
|
||||
println!("gcc: {}, kecc: {}", status as i8, value as i8);
|
||||
assert_eq!(status as i8, value as i8);
|
||||
println!("gcc: {}, kecc: {}", status as u8, value as u8);
|
||||
assert_eq!(status as u8, value as u8);
|
||||
}
|
||||
|
||||
pub fn test_irparse(path: &Path) {
|
||||
@@ -297,8 +297,8 @@ pub fn test_asmgen(path: &Path) {
|
||||
|
||||
let qemu_status = some_or_exit!(status.code(), SKIP_TEST);
|
||||
|
||||
println!("kecc interp: {}, qemu: {}", value as i8, qemu_status as i8);
|
||||
assert_eq!(value as i8, qemu_status as i8);
|
||||
println!("kecc interp: {}, qemu: {}", value as u8, qemu_status as u8);
|
||||
assert_eq!(value as u8, qemu_status as u8);
|
||||
}
|
||||
|
||||
// TODO: test all the way down to assembly
|
||||
@@ -397,6 +397,6 @@ pub fn test_end_to_end(path: &Path) {
|
||||
// For this reason, we make `fuzzer` generate the C source code which returns value
|
||||
// typecasted to `unsigned char`. However, during `creduce` reduce the code, typecasting
|
||||
// may be deleted. So, we truncate result value to byte size one more time here.
|
||||
println!("gcc: {}, kecc: {}", status as i8, value as i8);
|
||||
assert_eq!(status as i8, value as i8);
|
||||
println!("gcc: {}, kecc: {}", status as u8, value as u8);
|
||||
assert_eq!(status as u8, value as u8);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user