about summary refs log tree commit diff stats
path: root/test/core/graph.py
diff options
context:
space:
mode:
authorTim Blazytko <tim.blazytko@rub.de>2015-05-12 19:40:19 +0200
committerTim Blazytko <tim.blazytko@rub.de>2015-06-02 15:04:04 +0200
commit2677cffbb49008488ac37684a3657aa4c3298afa (patch)
treeffc4fdd2955e9bf1b2370c0645393f4fafdc0e83 /test/core/graph.py
parent8635555509e768655f5503792ad39ae1b6b3ff76 (diff)
downloadmiasm-2677cffbb49008488ac37684a3657aa4c3298afa.tar.gz
miasm-2677cffbb49008488ac37684a3657aa4c3298afa.zip
Tests/graph: extended regression tests
Diffstat (limited to 'test/core/graph.py')
-rw-r--r--test/core/graph.py42
1 files changed, 41 insertions, 1 deletions
diff --git a/test/core/graph.py b/test/core/graph.py
index eb320542..4ef37040 100644
--- a/test/core/graph.py
+++ b/test/core/graph.py
@@ -54,12 +54,19 @@ g2.add_edge(2, 3)
 g2.add_edge(3, 4)
 g2.add_edge(5, 6)
 g2.add_edge(6, 3)
+g2.add_edge(4, 7)
+g2.add_edge(4, 8)
+g2.add_edge(7, 9)
+g2.add_edge(8, 9)
 
 dominators = g2.compute_dominators(5)
 assert(dominators == {3: set([3, 5, 6]),
                       4: set([3, 4, 5, 6]),
                       5: set([5]),
-                      6: set([5, 6])})
+                      6: set([5, 6]),
+                      7: set([3, 4, 5, 6, 7]),
+                      8: set([3, 4, 5, 6, 8]),
+                      9: set([3, 4, 5, 6, 9])})
 
 
 assert(list(g2.walk_dominators(1, dominators)) == [])
@@ -113,3 +120,36 @@ assert(list(g2.walk_postdominators(3, postdominators)) == [4])
 assert(list(g2.walk_postdominators(4, postdominators)) == [])
 assert(list(g2.walk_postdominators(5, postdominators)) == [6, 3, 4])
 assert(list(g2.walk_postdominators(6, postdominators)) == [3, 4])
+
+idoms = g1.compute_immediate_dominators(1)
+assert(idoms == {2: 1,
+                 3: 2,
+                 4: 2,
+                 5: 2,
+                 6: 2})
+
+idoms = g2.compute_immediate_dominators(1)
+assert(idoms == {2: 1,
+                 3: 2,
+                 4: 3,
+                 7: 4,
+                 8: 4,
+                 9: 4})
+
+idoms = g2.compute_immediate_dominators(5)
+assert(idoms == {3: 6,
+                 4: 3,
+                 6: 5,
+                 7: 4,
+                 8: 4,
+                 9: 4})
+
+frontier = g1.compute_dominance_frontier(1)
+assert(frontier == {2: set([2, 5]),
+                    5: set([3, 4])})
+
+frontier = g2.compute_dominance_frontier(1)
+assert(frontier == {9: set([7, 8])})
+
+frontier = g2.compute_dominance_frontier(5)
+assert(frontier == {9: set([7, 8])})
\ No newline at end of file