Example #1
0
    def test_copy_simple(self):
        orig = Spec('mpileaks')
        copy = orig.copy()
        check_links(copy)

        assert orig == copy
        assert orig.eq_dag(copy)
        assert orig._normal == copy._normal
        assert orig._concrete == copy._concrete

        # ensure no shared nodes bt/w orig and copy.
        orig_ids = set(id(s) for s in orig.traverse())
        copy_ids = set(id(s) for s in copy.traverse())
        assert not orig_ids.intersection(copy_ids)
Example #2
0
    def test_copy_simple(self):
        orig = Spec('mpileaks')
        copy = orig.copy()
        check_links(copy)

        assert orig == copy
        assert orig.eq_dag(copy)
        assert orig._normal == copy._normal
        assert orig._concrete == copy._concrete

        # ensure no shared nodes bt/w orig and copy.
        orig_ids = set(id(s) for s in orig.traverse())
        copy_ids = set(id(s) for s in copy.traverse())
        assert not orig_ids.intersection(copy_ids)
Example #3
0
    def test_normalize_mpileaks(self):
        # Spec parsed in from a string
        spec = Spec('mpileaks ^mpich ^callpath ^dyninst ^[email protected]'
                    ' ^libdwarf')

        # What that spec should look like after parsing
        expected_flat = Spec('mpileaks', Spec('mpich'), Spec('callpath'),
                             Spec('dyninst'), Spec('[email protected]'),
                             Spec('libdwarf'))

        # What it should look like after normalization
        mpich = Spec('mpich')
        libelf = Spec('[email protected]')
        expected_normalized = Spec(
            'mpileaks',
            Spec('callpath', Spec('dyninst', Spec('libdwarf', libelf), libelf),
                 mpich), mpich)

        # Similar to normalized spec, but now with copies of the same
        # libelf node.  Normalization should result in a single unique
        # node for each package, so this is the wrong DAG.
        non_unique_nodes = Spec(
            'mpileaks',
            Spec(
                'callpath',
                Spec('dyninst', Spec('libdwarf', Spec('[email protected]')),
                     Spec('[email protected]')), mpich), Spec('mpich'))

        # All specs here should be equal under regular equality
        specs = (spec, expected_flat, expected_normalized, non_unique_nodes)
        for lhs, rhs in zip(specs, specs):
            self.assertEqual(lhs, rhs)
            self.assertEqual(str(lhs), str(rhs))

        # Test that equal and equal_dag are doing the right thing
        self.assertEqual(spec, expected_flat)
        self.assertTrue(spec.eq_dag(expected_flat))

        # Normalized has different DAG structure, so NOT equal.
        self.assertNotEqual(spec, expected_normalized)
        self.assertFalse(spec.eq_dag(expected_normalized))

        # Again, different DAG structure so not equal.
        self.assertNotEqual(spec, non_unique_nodes)
        self.assertFalse(spec.eq_dag(non_unique_nodes))

        spec.normalize()

        # After normalizing, spec_dag_equal should match the normalized spec.
        self.assertNotEqual(spec, expected_flat)
        self.assertFalse(spec.eq_dag(expected_flat))

        self.assertEqual(spec, expected_normalized)
        self.assertTrue(spec.eq_dag(expected_normalized))

        self.assertEqual(spec, non_unique_nodes)
        self.assertFalse(spec.eq_dag(non_unique_nodes))
Example #4
0
    def test_copy_simple(self):
        orig = Spec('mpileaks')
        copy = orig.copy()

        self.check_links(copy)

        self.assertEqual(orig, copy)
        self.assertTrue(orig.eq_dag(copy))
        self.assertEqual(orig._normal, copy._normal)
        self.assertEqual(orig._concrete, copy._concrete)

        # ensure no shared nodes bt/w orig and copy.
        orig_ids = set(id(s) for s in orig.traverse())
        copy_ids = set(id(s) for s in copy.traverse())
        self.assertFalse(orig_ids.intersection(copy_ids))
Example #5
0
    def test_copy_simple(self):
        orig = Spec('mpileaks')
        copy = orig.copy()

        self.check_links(copy)

        self.assertEqual(orig, copy)
        self.assertTrue(orig.eq_dag(copy))
        self.assertEqual(orig._normal, copy._normal)
        self.assertEqual(orig._concrete, copy._concrete)

        # ensure no shared nodes bt/w orig and copy.
        orig_ids = set(id(s) for s in orig.traverse())
        copy_ids = set(id(s) for s in copy.traverse())
        self.assertFalse(orig_ids.intersection(copy_ids))
Example #6
0
    def test_equal(self):
        # Different spec structures to test for equality
        flat = Spec('mpileaks ^callpath ^libelf ^libdwarf')

        flat_init = Spec(
            'mpileaks', Spec('callpath'), Spec('libdwarf'), Spec('libelf'))

        flip_flat = Spec(
            'mpileaks', Spec('libelf'), Spec('libdwarf'), Spec('callpath'))

        dag = Spec('mpileaks', Spec('callpath',
                                    Spec('libdwarf',
                                         Spec('libelf'))))

        flip_dag = Spec('mpileaks', Spec('callpath',
                                         Spec('libelf',
                                              Spec('libdwarf'))))

        # All these are equal to each other with regular ==
        specs = (flat, flat_init, flip_flat, dag, flip_dag)
        for lhs, rhs in zip(specs, specs):
            self.assertEqual(lhs, rhs)
            self.assertEqual(str(lhs), str(rhs))

        # Same DAGs constructed different ways are equal
        self.assertTrue(flat.eq_dag(flat_init))

        # order at same level does not matter -- (dep on same parent)
        self.assertTrue(flat.eq_dag(flip_flat))

        # DAGs should be unequal if nesting is different
        self.assertFalse(flat.eq_dag(dag))
        self.assertFalse(flat.eq_dag(flip_dag))
        self.assertFalse(flip_flat.eq_dag(dag))
        self.assertFalse(flip_flat.eq_dag(flip_dag))
        self.assertFalse(dag.eq_dag(flip_dag))
Example #7
0
    def test_equal(self):
        # Different spec structures to test for equality
        flat = Spec('mpileaks ^callpath ^libelf ^libdwarf')

        flat_init = Spec(
            'mpileaks', Spec('callpath'), Spec('libdwarf'), Spec('libelf'))

        flip_flat = Spec(
            'mpileaks', Spec('libelf'), Spec('libdwarf'), Spec('callpath'))

        dag = Spec('mpileaks', Spec('callpath',
                                    Spec('libdwarf',
                                         Spec('libelf'))))

        flip_dag = Spec('mpileaks', Spec('callpath',
                                         Spec('libelf',
                                              Spec('libdwarf'))))

        # All these are equal to each other with regular ==
        specs = (flat, flat_init, flip_flat, dag, flip_dag)
        for lhs, rhs in zip(specs, specs):
            self.assertEqual(lhs, rhs)
            self.assertEqual(str(lhs), str(rhs))

        # Same DAGs constructed different ways are equal
        self.assertTrue(flat.eq_dag(flat_init))

        # order at same level does not matter -- (dep on same parent)
        self.assertTrue(flat.eq_dag(flip_flat))

        # DAGs should be unequal if nesting is different
        self.assertFalse(flat.eq_dag(dag))
        self.assertFalse(flat.eq_dag(flip_dag))
        self.assertFalse(flip_flat.eq_dag(dag))
        self.assertFalse(flip_flat.eq_dag(flip_dag))
        self.assertFalse(dag.eq_dag(flip_dag))
Example #8
0
 def check_normalize(self, spec_string, expected):
     spec = Spec(spec_string)
     spec.normalize()
     self.assertEqual(spec, expected)
     self.assertTrue(spec.eq_dag(expected))
Example #9
0
def test_normalize(spec_and_expected, config, builtin_mock):
    spec, expected = spec_and_expected
    spec = Spec(spec)
    spec.normalize()
    assert spec.eq_dag(expected, deptypes=False)
Example #10
0
def test_normalize(spec_and_expected, config, mock_packages):
    spec, expected = spec_and_expected
    spec = Spec(spec)
    spec.normalize()
    assert spec.eq_dag(expected, deptypes=False)
Example #11
0
def test_normalize(spec_and_expected, config, builtin_mock):
    spec, expected = spec_and_expected
    spec = Spec(spec)
    spec.normalize()
    assert spec.eq_dag(expected, deptypes=False)
Example #12
0
 def check_normalize(self, spec_string, expected):
     spec = Spec(spec_string)
     spec.normalize()
     self.assertEqual(spec, expected)
     self.assertTrue(spec.eq_dag(expected))
Example #13
0
    def test_normalize_mpileaks(self):
        # Spec parsed in from a string
        spec = Spec('mpileaks ^mpich ^callpath ^dyninst ^[email protected] ^libdwarf')

        # What that spec should look like after parsing
        expected_flat = Spec(
            'mpileaks', Spec('mpich'), Spec('callpath'), Spec('dyninst'),
            Spec('[email protected]'), Spec('libdwarf'))

        # What it should look like after normalization
        mpich = Spec('mpich')
        libelf = Spec('[email protected]')
        expected_normalized = Spec(
            'mpileaks',
            Spec('callpath',
                 Spec('dyninst',
                      Spec('libdwarf',
                           libelf),
                      libelf),
                 mpich),
            mpich)

        # Similar to normalized spec, but now with copies of the same
        # libelf node.  Normalization should result in a single unique
        # node for each package, so this is the wrong DAG.
        non_unique_nodes = Spec(
            'mpileaks',
            Spec('callpath',
                 Spec('dyninst',
                      Spec('libdwarf',
                           Spec('[email protected]')),
                      Spec('[email protected]')),
                 mpich),
            Spec('mpich'))

        # All specs here should be equal under regular equality
        specs = (spec, expected_flat, expected_normalized, non_unique_nodes)
        for lhs, rhs in zip(specs, specs):
            self.assertEqual(lhs, rhs)
            self.assertEqual(str(lhs), str(rhs))

        # Test that equal and equal_dag are doing the right thing
        self.assertEqual(spec, expected_flat)
        self.assertTrue(spec.eq_dag(expected_flat))

        self.assertEqual(spec, expected_normalized)
        self.assertFalse(spec.eq_dag(expected_normalized))

        self.assertEqual(spec, non_unique_nodes)
        self.assertFalse(spec.eq_dag(non_unique_nodes))

        spec.normalize()

        # After normalizing, spec_dag_equal should match the normalized spec.
        self.assertEqual(spec, expected_flat)
        self.assertFalse(spec.eq_dag(expected_flat))

        self.assertEqual(spec, expected_normalized)
        self.assertTrue(spec.eq_dag(expected_normalized))

        self.assertEqual(spec, non_unique_nodes)
        self.assertFalse(spec.eq_dag(non_unique_nodes))
Example #14
0
    def test_normalize_mpileaks(self):
        # Spec parsed in from a string
        spec = Spec('mpileaks ^mpich ^callpath ^dyninst ^[email protected]'
                    ' ^libdwarf')

        # What that spec should look like after parsing
        expected_flat = Spec(
            'mpileaks', Spec('mpich'), Spec('callpath'), Spec('dyninst'),
            Spec('[email protected]'), Spec('libdwarf'))

        # What it should look like after normalization
        mpich = Spec('mpich')
        libelf = Spec('[email protected]')
        expected_normalized = Spec(
            'mpileaks',
            Spec('callpath',
                 Spec('dyninst',
                      Spec('libdwarf',
                           libelf),
                      libelf),
                 mpich),
            mpich)

        # Similar to normalized spec, but now with copies of the same
        # libelf node.  Normalization should result in a single unique
        # node for each package, so this is the wrong DAG.
        non_unique_nodes = Spec(
            'mpileaks',
            Spec('callpath',
                 Spec('dyninst',
                      Spec('libdwarf',
                           Spec('[email protected]')),
                      Spec('[email protected]')),
                 mpich),
            Spec('mpich'))

        # All specs here should be equal under regular equality
        specs = (spec, expected_flat, expected_normalized, non_unique_nodes)
        for lhs, rhs in zip(specs, specs):
            assert lhs == rhs
            assert str(lhs) == str(rhs)

        # Test that equal and equal_dag are doing the right thing
        assert spec == expected_flat
        assert spec.eq_dag(expected_flat)

        # Normalized has different DAG structure, so NOT equal.
        assert spec != expected_normalized
        assert not spec.eq_dag(expected_normalized)

        # Again, different DAG structure so not equal.
        assert spec != non_unique_nodes
        assert not spec.eq_dag(non_unique_nodes)

        spec.normalize()

        # After normalizing, spec_dag_equal should match the normalized spec.
        assert spec != expected_flat
        assert not spec.eq_dag(expected_flat)

        # verify DAG structure without deptypes.
        assert spec.eq_dag(expected_normalized, deptypes=False)
        assert not spec.eq_dag(non_unique_nodes, deptypes=False)

        assert not spec.eq_dag(expected_normalized, deptypes=True)
        assert not spec.eq_dag(non_unique_nodes, deptypes=True)
Example #15
0
def test_normalize(spec_and_expected, config, mock_packages):
    spec, expected = spec_and_expected
    spec = Spec(spec)
    spec.normalize()
    assert spec.eq_dag(expected, deptypes=False)