diff options
author | Johannes 'josch' Schauer <josch@debian.org> | 2018-07-22 15:53:10 +0200 |
---|---|---|
committer | Johannes 'josch' Schauer <josch@debian.org> | 2018-07-22 20:20:06 +0200 |
commit | 7f3ce50bab648d130983dac64c7bd46e8a98c1d4 (patch) | |
tree | ca1b0d010157c81f0c36e8e4f1b9f39f628d3a0c | |
parent | 688b14c36d2192f440c27a2dcf077019b96ad0a1 (diff) |
tools/graph-difference.py: allow comparison of arbitrary input graphs
-rw-r--r-- | Makefile | 2 | ||||
-rwxr-xr-x | debian/tests/diff_tmp_out | 2 | ||||
-rwxr-xr-x | tools/graph-difference.py | 18 |
3 files changed, 8 insertions, 14 deletions
@@ -146,7 +146,7 @@ define diff_tmp_out for f in tests/$(1)/$$t/* $$t/*; do basename "$$f"; done | sort | uniq | while read f; do \ echo checking $$f; \ case "$$f" in \ - *.xml) \ + *.xml|*.dot) \ echo "+ ./tools/graph-difference.py \"tests/$(1)/$$t/$$f\" \"$$t/$$f\""; \ while : ; do ./tools/graph-difference.py "tests/$(1)/$$t/$$f" "$$t/$$f"; exit=$$?; if [ $$exit -eq 139 ]; then echo segfault; continue; fi; if [ $$exit -ne 0 ]; then exit 1; else break; fi; done;; \ *) \ diff --git a/debian/tests/diff_tmp_out b/debian/tests/diff_tmp_out index 92f73ec..00ed8eb 100755 --- a/debian/tests/diff_tmp_out +++ b/debian/tests/diff_tmp_out @@ -9,7 +9,7 @@ for t in tmp out; do for f in tests/$testname/$t/* $ADTTMP/$t/*; do basename "$f"; done | sort | uniq | while read f; do echo checking $f; case "$f" in - *.xml) + *.xml|*.dot) echo "+ botch-graph-difference \"tests/$testname/$t/$f\" \"$ADTTMP/$t/$f\""; while : ; do botch-graph-difference "tests/$testname/$t/$f" "$ADTTMP/$t/$f"; exit=$?; if [ $exit -eq 139 ]; then echo segfault; continue; fi; if [ $exit -ne 0 ]; then exit 1; else break; fi; done;; *) diff --git a/tools/graph-difference.py b/tools/graph-difference.py index 1e6e751..b64978a 100755 --- a/tools/graph-difference.py +++ b/tools/graph-difference.py @@ -21,34 +21,31 @@ def graph_difference(g, h, verbose=False): return False def normalize_node(attr): - if not attr.get('kind'): - raise Exception("need kind node attribute") # We delete the cudfversion attribute because vertices should be unique # by their name and version and not by the cudfversion which may have # been differently assigned - if attr.get('version') is not None: + if attr.get('version') is not None and 'cudfversion' in attr: del attr['cudfversion'] - if attr['kind'] == "SCC": + if attr.get('kind') == "SCC": if not attr.get('binaries'): raise Exception("nodes of kind SCC need the sources attribute") attr['sources'] = frozenset( [s for s in attr['sources'].split(',')]) - elif attr['kind'] == "InstSet": + elif attr.get('kind') == "InstSet": if not attr.get('binaries'): raise Exception( "nodes of kind InstSet need the binaries attribute") attr['binaries'] = frozenset( [p for p in attr['binaries'].split(',')]) - elif attr['kind'] == "SrcPkg": + elif attr.get('kind') == "SrcPkg": pass - else: - raise Exception("unknown node type %s" % attr['kind']) return frozenset(attr.items()) def normalize_edge(attr): # we delete the id attribute as it has no meaning. Edges are unique by # the vertices they connect because there can be no multi-edges - del attr['id'] + if 'id' in attr: + del attr['id'] # only buildgraphs have the kind attribute if attr.get('kind'): if attr['kind'] == "buildsfrom": @@ -66,9 +63,6 @@ def graph_difference(g, h, verbose=False): if attr.get('binaries'): attr['binaries'] = frozenset( [s for s in attr['binaries'].split(',')]) - else: - raise Exception( - "edge must have binaries attribute in srcgraph") if attr.get('strong'): attr['strong'] = frozenset( [s for s in attr['strong'].split(',')]) |