From 7d6792a638938d643fe70f70aba976dba3771d5f Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Fri, 10 May 2024 07:40:22 +0000 Subject: [PATCH] test: Always log logical-to-physical mappings For tests using a logical topology, log the resulting mapping to the physical one. This way, we always have a record of the entire environment. --- test/infamy/env.py | 2 ++ test/infamy/topology.py | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/test/infamy/env.py b/test/infamy/env.py index 97e87d22..e38c8127 100644 --- a/test/infamy/env.py +++ b/test/infamy/env.py @@ -35,6 +35,8 @@ class Env(object): if not self.ltop.map_to(self.ptop): raise tap.TestSkip() + print(repr(self.ltop)) + def attach(self, node, port, factory_default=True): if self.ltop: mapping = self.ltop.mapping[node] diff --git a/test/infamy/topology.py b/test/infamy/topology.py index 1cd80403..4a365ae4 100644 --- a/test/infamy/topology.py +++ b/test/infamy/topology.py @@ -51,6 +51,22 @@ class Topology: attrs[dn] = dp self.g.add_edge(sn, dn, **attrs) + def __repr__(self): + if not self.mapping: + return "" + + out = "" + + for n in self.mapping: + out += f"{n + ':':<8} {self.mapping[n][None]}\n" + for e in self.mapping[n]: + if not e: + continue + + out += f" {e + ':':<8} {self.mapping[n][e]}\n" + + return out + def map_to(self, phy): mapper = isomorphism.MultiGraphMatcher(phy.g, self.g, edge_match=match_edge,