Move integration tests into src/tools/tests.

The integration tests use both libcretonne and libreader, so moving them avoids
the circular dev-dependency.

Also go back to building everything under src/tools/target to avoid rebuilding
the libraries when cargo is invoked in different subdirectories. This speeds up
test-all.sh quite a bit.

Finally, skip the pure debug build. We build "cargo test" and "cargo build
--release" which should cover everything we need.
This commit is contained in:
Jakob Stoklund Olesen
2016-08-12 10:27:15 -07:00
parent 514ebc6bf9
commit 84a154a8ca
5 changed files with 14 additions and 15 deletions

View File

@@ -0,0 +1,60 @@
extern crate cretonne;
extern crate cton_reader;
use self::cton_reader::parser::Parser;
use self::cretonne::ir::entities::Ebb;
use self::cretonne::cfg::ControlFlowGraph;
use self::cretonne::dominator_tree::DominatorTree;
fn test_dominator_tree(function_source: &str, idoms: Vec<u32>) {
let func = &Parser::parse(function_source).unwrap()[0];
let cfg = ControlFlowGraph::new(&func);
let dtree = DominatorTree::new(&cfg);
assert_eq!(dtree.ebbs().collect::<Vec<_>>().len(), idoms.len());
for (i, j) in idoms.iter().enumerate() {
let ebb = Ebb::with_number(i.clone() as u32);
let idom = Ebb::with_number(*j);
assert_eq!(dtree.idom(ebb.unwrap()), idom);
}
}
#[test]
fn basic() {
test_dominator_tree("
function test(i32) {
ebb0(v0: i32):
jump ebb1
ebb1:
brz v0, ebb3
jump ebb2
ebb2:
jump ebb3
ebb3:
return
}
", vec![0, 0, 1, 1]);
}
#[test]
fn loops() {
test_dominator_tree("
function test(i32) {
ebb0(v0: i32):
brz v0, ebb1
jump ebb2
ebb1:
jump ebb3
ebb2:
brz v0, ebb4
jump ebb5
ebb3:
jump ebb4
ebb4:
brz v0, ebb3
jump ebb5
ebb5:
brz v0, ebb4
return
}
", vec![0, 0, 0, 0, 0, 0]);
}