Exemplo n.º 1
0
    def test_flag_order(self):
        # Test that the order in which the flags are specified is retained
        test_fragment = self.create_fragment_file(u"""
[mapping:map]
archive: libmain.a
entries:
    obj1 (default);
        text->flash_text ALIGN(4) KEEP() SURROUND(sym1) ALIGN(8) SORT(name),
        rodata->flash_rodata KEEP() ALIGN(4) KEEP() SURROUND(sym1) ALIGN(8) ALIGN(4) SORT(name)
""")
        fragment_file = FragmentFile(test_fragment, self.sdkconfig)
        fragment = fragment_file.fragments[0]

        expected = [('text', 'flash_text', [
            Mapping.Align(4, True, False),
            Mapping.Keep(),
            Mapping.Surround('sym1'),
            Mapping.Align(8, True, False),
            Mapping.Sort('name')
        ]),
                    ('rodata', 'flash_rodata', [
                        Mapping.Keep(),
                        Mapping.Align(4, True, False),
                        Mapping.Keep(),
                        Mapping.Surround('sym1'),
                        Mapping.Align(8, True, False),
                        Mapping.Align(4, True, False),
                        Mapping.Sort('name')
                    ])]
        actual = fragment.flags[('obj1', None, 'default')]
        self.assertEqual(expected, actual)
Exemplo n.º 2
0
    def test_flags_entries_multiple_flags_and_entries(self):
        # Not an error, generation step handles this, since
        # it that step has a more complete information
        # about all mappings. This can happen across multiple
        # mapping fragments.
        test_fragment = self.create_fragment_file(u"""
[mapping:map]
archive: libmain.a
entries:
    obj1 (default);
        text->flash_text ALIGN(4) KEEP() SURROUND(sym1) SORT(name)
    obj1 (default);
        text->flash_text ALIGN(4) KEEP() SURROUND(sym1) SORT(name)
""")
        fragment_file = FragmentFile(test_fragment, self.sdkconfig)
        fragment = fragment_file.fragments[0]

        expected = [('text', 'flash_text', [
            Mapping.Align(4, True, False),
            Mapping.Keep(),
            Mapping.Surround('sym1'),
            Mapping.Sort('name')
        ]),
                    ('text', 'flash_text', [
                        Mapping.Align(4, True, False),
                        Mapping.Keep(),
                        Mapping.Surround('sym1'),
                        Mapping.Sort('name')
                    ])]
        actual = fragment.flags[('obj1', None, 'default')]
        self.assertEqual(expected, actual)
Exemplo n.º 3
0
    def test_align_flag(self):
        # Test parsing combinations and orders of flags
        test_fragment = self.create_fragment_file(u"""
[mapping:map]
archive: libmain.a
entries:
    obj1 (default);
        text->flash_text ALIGN(8),
        rodata->flash_rodata ALIGN(8, pre),
        data->dram0_data ALIGN(8, pre, post),
        bss->dram0_bss ALIGN(8, post),
        common->dram0_bss ALIGN(8, pre, post) ALIGN(8)
""")

        fragment_file = FragmentFile(test_fragment, self.sdkconfig)
        fragment = fragment_file.fragments[0]

        expected = [
            ('text', 'flash_text', [Mapping.Align(8, True, False)]),
            ('rodata', 'flash_rodata', [Mapping.Align(8, True, False)]),
            ('data', 'dram0_data', [Mapping.Align(8, True, True)]),
            ('bss', 'dram0_bss', [Mapping.Align(8, False, True)]),
            ('common', 'dram0_bss',
             [Mapping.Align(8, True, True),
              Mapping.Align(8, True, False)])
        ]
        actual = fragment.flags[('obj1', None, 'default')]

        self.assertEqual(expected, actual)

        # Wrong post, pre order
        test_fragment = self.create_fragment_file(u"""
[mapping:map]
archive: libmain.a
entries:
    obj1 (noflash)
        text->iram0_text ALIGN(8, post, pre)
""")

        with self.assertRaises(ParseFatalException):
            FragmentFile(test_fragment, self.sdkconfig)