def test_unique_path_traversal(self): dag = Spec('mpileaks ^zmpi') dag.normalize() names = ['mpileaks', 'callpath', 'dyninst', 'libdwarf', 'libelf', 'libelf', 'zmpi', 'fake', 'zmpi', 'fake'] pairs = zip([0,1,2,3,4,3,2,3,1,2], names) traversal = dag.preorder_traversal(cover='paths') self.assertListEqual([x.name for x in traversal], names) traversal = dag.preorder_traversal(cover='paths', depth=True) self.assertListEqual([(x, y.name) for x,y in traversal], pairs)
def test_normalize_with_virtual_spec(self): dag = Spec('mpileaks', Spec('callpath', Spec('dyninst', Spec('libdwarf', Spec('libelf')), Spec('libelf')), Spec('mpi')), Spec('mpi')) dag.normalize() # make sure nothing with the same name occurs twice counts = {} for spec in dag.preorder_traversal(keyfun=id): if not spec.name in counts: counts[spec.name] = 0 counts[spec.name] += 1 for name in counts: self.assertEqual(counts[name], 1, "Count for %s was not 1!" % name)