mirror of https://codeberg.org/topola/topola.git
tests: add 3-pin XLR THT female to THT female test
Hardly functional so far.
This commit is contained in:
parent
af1bb7069f
commit
91480453b3
|
|
@ -58,9 +58,13 @@ pub struct Invoker<R: RulesTrait> {
|
||||||
|
|
||||||
impl<R: RulesTrait> Invoker<R> {
|
impl<R: RulesTrait> Invoker<R> {
|
||||||
pub fn new(autorouter: Autorouter<R>) -> Self {
|
pub fn new(autorouter: Autorouter<R>) -> Self {
|
||||||
|
Self::new_with_history(autorouter, History::new())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn new_with_history(autorouter: Autorouter<R>, history: History) -> Self {
|
||||||
Self {
|
Self {
|
||||||
autorouter,
|
autorouter,
|
||||||
history: History::new(),
|
history,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
use petgraph::{unionfind::UnionFind, visit::NodeIndexable};
|
use petgraph::{stable_graph::NodeIndex, unionfind::UnionFind, visit::NodeIndexable};
|
||||||
use topola::{
|
use topola::{
|
||||||
autorouter::{board::Board, Autorouter},
|
autorouter::{board::Board, Autorouter},
|
||||||
drawing::{
|
drawing::{
|
||||||
|
|
@ -8,10 +8,7 @@ use topola::{
|
||||||
graph::GetNodeIndex,
|
graph::GetNodeIndex,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn assert_single_layer_groundless_autoroute(
|
fn unionfind(autorouter: &mut Autorouter<impl RulesTrait>) -> UnionFind<NodeIndex<usize>> {
|
||||||
autorouter: &mut Autorouter<impl RulesTrait>,
|
|
||||||
layername: &str,
|
|
||||||
) {
|
|
||||||
for ratline in autorouter.ratsnest().graph().edge_indices() {
|
for ratline in autorouter.ratsnest().graph().edge_indices() {
|
||||||
// Accessing endpoints may create new dots because apex construction is lazy, so we access
|
// Accessing endpoints may create new dots because apex construction is lazy, so we access
|
||||||
// tem all before starting unionfind, as it requires a constant index bound.
|
// tem all before starting unionfind, as it requires a constant index bound.
|
||||||
|
|
@ -40,6 +37,15 @@ pub fn assert_single_layer_groundless_autoroute(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unionfind
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn assert_single_layer_groundless_autoroute(
|
||||||
|
autorouter: &mut Autorouter<impl RulesTrait>,
|
||||||
|
layername: &str,
|
||||||
|
) {
|
||||||
|
let unionfind = unionfind(autorouter);
|
||||||
|
|
||||||
for ratline in autorouter.ratsnest().graph().edge_indices() {
|
for ratline in autorouter.ratsnest().graph().edge_indices() {
|
||||||
let (source_dot, target_dot) = autorouter.ratline_endpoints(ratline);
|
let (source_dot, target_dot) = autorouter.ratline_endpoints(ratline);
|
||||||
|
|
||||||
|
|
@ -100,6 +106,18 @@ pub fn assert_single_layer_groundless_autoroute(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*pub fn assert_number_of_conncomps(
|
||||||
|
autorouter: &mut Autorouter<impl RulesTrait>,
|
||||||
|
conncomp_count: usize,
|
||||||
|
) {
|
||||||
|
let unionfind = unionfind(autorouter);
|
||||||
|
let mut labels = unionfind.into_labeling();
|
||||||
|
labels.sort_unstable();
|
||||||
|
labels.dedup();
|
||||||
|
|
||||||
|
assert_eq!(labels.len(), conncomp_count);
|
||||||
|
}*/
|
||||||
|
|
||||||
pub fn assert_band_length(
|
pub fn assert_band_length(
|
||||||
board: &Board<impl RulesTrait>,
|
board: &Board<impl RulesTrait>,
|
||||||
source: &str,
|
source: &str,
|
||||||
|
|
|
||||||
|
|
@ -27,59 +27,10 @@ fn test_0603_breakout() {
|
||||||
let file = File::open("tests/single_layer/data/0603_breakout/autoroute_all.cmd").unwrap();
|
let file = File::open("tests/single_layer/data/0603_breakout/autoroute_all.cmd").unwrap();
|
||||||
invoker.replay(serde_json::from_reader(file).unwrap());
|
invoker.replay(serde_json::from_reader(file).unwrap());
|
||||||
|
|
||||||
let mut unionfind = UnionFind::new(
|
let (mut autorouter, ..) = invoker.destruct();
|
||||||
invoker
|
|
||||||
.autorouter()
|
|
||||||
.board()
|
|
||||||
.layout()
|
|
||||||
.drawing()
|
|
||||||
.geometry()
|
|
||||||
.graph()
|
|
||||||
.node_bound(),
|
|
||||||
);
|
|
||||||
|
|
||||||
for edge in invoker
|
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
||||||
.autorouter()
|
//common::assert_number_of_conncomps(&mut autorouter, 2);
|
||||||
.board()
|
|
||||||
.layout()
|
|
||||||
.drawing()
|
|
||||||
.geometry()
|
|
||||||
.graph()
|
|
||||||
.edge_references()
|
|
||||||
{
|
|
||||||
unionfind.union(edge.source(), edge.target());
|
|
||||||
}
|
|
||||||
|
|
||||||
assert_eq!(
|
|
||||||
invoker
|
|
||||||
.autorouter()
|
|
||||||
.ratsnest()
|
|
||||||
.graph()
|
|
||||||
.edge_indices()
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
.len(),
|
|
||||||
2
|
|
||||||
);
|
|
||||||
|
|
||||||
for ratline in invoker.autorouter().ratsnest().graph().edge_references() {
|
|
||||||
let from_index = invoker
|
|
||||||
.autorouter()
|
|
||||||
.ratsnest()
|
|
||||||
.graph()
|
|
||||||
.node_weight(ratline.source())
|
|
||||||
.unwrap()
|
|
||||||
.trianvertex_index()
|
|
||||||
.node_index();
|
|
||||||
let to_index = invoker
|
|
||||||
.autorouter()
|
|
||||||
.ratsnest()
|
|
||||||
.graph()
|
|
||||||
.node_weight(ratline.target())
|
|
||||||
.unwrap()
|
|
||||||
.trianvertex_index()
|
|
||||||
.node_index();
|
|
||||||
assert_eq!(unionfind.find(from_index), unionfind.find(to_index));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
@ -97,6 +48,7 @@ fn test_tht_diode_bridge_rectifier() {
|
||||||
let (mut autorouter, ..) = invoker.destruct();
|
let (mut autorouter, ..) = invoker.destruct();
|
||||||
|
|
||||||
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
||||||
|
//common::assert_number_of_conncomps(&mut autorouter, 4);
|
||||||
common::assert_band_length(autorouter.board(), "J2-2", "D4-2", 15511.0, 0.5);
|
common::assert_band_length(autorouter.board(), "J2-2", "D4-2", 15511.0, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,4 +68,24 @@ fn test_four_3rd_order_smd_lc_filters() {
|
||||||
let (mut autorouter, ..) = invoker.destruct();
|
let (mut autorouter, ..) = invoker.destruct();
|
||||||
|
|
||||||
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
||||||
|
//common::assert_number_of_conncomps(&mut autorouter, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_3pin_xlr_tht_female_to_tht_female() {
|
||||||
|
let design = DsnDesign::load_from_file(
|
||||||
|
"tests/single_layer/data/3pin_xlr_tht_female_to_tht_female/3pin_xlr_tht_female_to_tht_female.dsn"
|
||||||
|
);
|
||||||
|
let board = design.unwrap().make_board();
|
||||||
|
|
||||||
|
let mut invoker = Invoker::new(Autorouter::new(board).unwrap());
|
||||||
|
let file =
|
||||||
|
File::open("tests/single_layer/data/3pin_xlr_tht_female_to_tht_female/autoroute_all.cmd")
|
||||||
|
.unwrap();
|
||||||
|
invoker.replay(serde_json::from_reader(file).unwrap());
|
||||||
|
|
||||||
|
let (mut autorouter, ..) = invoker.destruct();
|
||||||
|
|
||||||
|
// FIXME: The routing result is pretty bad.
|
||||||
|
common::assert_single_layer_groundless_autoroute(&mut autorouter, "F.Cu");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
{"hostname":"luckmann","username":"mikolaj"}
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"done": [
|
||||||
|
{
|
||||||
|
"Autoroute": {
|
||||||
|
"selectors": [
|
||||||
|
{
|
||||||
|
"pin": "J2-2",
|
||||||
|
"layer": "F.Cu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pin": "J1-2",
|
||||||
|
"layer": "F.Cu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pin": "J2-3",
|
||||||
|
"layer": "F.Cu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pin": "J2-1",
|
||||||
|
"layer": "F.Cu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pin": "J1-3",
|
||||||
|
"layer": "F.Cu"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pin": "J1-1",
|
||||||
|
"layer": "F.Cu"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"undone": []
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue