mirror of
https://github.com/kmc7468/cs420.git
synced 2025-12-16 07:28:52 +00:00
Fix testing code
This commit is contained in:
@@ -192,7 +192,11 @@ pub struct Block {
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum Instruction {
|
||||
Nop,
|
||||
// TODO: Explain what this is, why this is needed.
|
||||
/// A value, used for "simple copy".
|
||||
///
|
||||
/// This is only used during phi elimination for Asmgen. You can ignore this before that. In
|
||||
/// particular, you will need this instruction to properly generate assembly for `lost_copy.c`
|
||||
/// and `swap.c`.
|
||||
Value {
|
||||
value: Operand,
|
||||
},
|
||||
|
||||
28
src/tests.rs
28
src/tests.rs
@@ -1,5 +1,5 @@
|
||||
use std::fs::{self, File};
|
||||
use std::io::{Read, Write, stderr};
|
||||
use std::io::{self, Read, Write};
|
||||
use std::path::Path;
|
||||
use std::process::{Command, Stdio};
|
||||
use std::time::Duration;
|
||||
@@ -193,10 +193,13 @@ pub fn test_irgen(path: &Path) {
|
||||
// be nullified. So, we truncate the result value to byte size one more time here.
|
||||
println!("clang (expected): {}, kecc: {}", status as u8, value as u8);
|
||||
if status as u8 != value as u8 {
|
||||
stderr().lock().write_fmt(format_args!(
|
||||
let mut stderr = io::stderr().lock();
|
||||
stderr.write_fmt(format_args!(
|
||||
"[irgen] Failed to correctly generate {path:?}.\n\n [incorrect ir]"
|
||||
));
|
||||
write(&ir, &mut stderr()).unwrap();
|
||||
write(&ir, &mut stderr).unwrap();
|
||||
drop(stderr);
|
||||
panic!("[irgen]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,23 +280,20 @@ pub fn test_opt<P1: AsRef<Path>, P2: AsRef<Path>, O: Optimize<ir::TranslationUni
|
||||
let _ = opt.optimize(&mut ir);
|
||||
|
||||
if !ir.is_equiv(&to) {
|
||||
stderr()
|
||||
.lock()
|
||||
let mut stderr = io::stderr().lock();
|
||||
stderr
|
||||
.write_fmt(format_args!(
|
||||
"[test_opt] actual outcome mismatches with the expected outcome.\n\n[before opt]"
|
||||
))
|
||||
.unwrap();
|
||||
write(&from, &mut stderr()).unwrap();
|
||||
stderr()
|
||||
.lock()
|
||||
.write_fmt(format_args!("\n[after opt]"))
|
||||
.unwrap();
|
||||
write(&ir, &mut stderr()).unwrap();
|
||||
stderr()
|
||||
.lock()
|
||||
write(&from, &mut stderr).unwrap();
|
||||
stderr.write_fmt(format_args!("\n[after opt]")).unwrap();
|
||||
write(&ir, &mut stderr).unwrap();
|
||||
stderr
|
||||
.write_fmt(format_args!("\n[after opt (expected)]"))
|
||||
.unwrap();
|
||||
write(&to, &mut stderr()).unwrap();
|
||||
write(&to, &mut stderr).unwrap();
|
||||
drop(stderr);
|
||||
panic!("[test_opt]");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user