Beispiel #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)
Beispiel #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)
Beispiel #3
0
    def test_sort_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 SORT(name),
        rodata->flash_rodata SORT(alignment),
        data->dram0_data SORT(init_priority),
        bss->dram0_bss SORT(name, alignment),
        common->dram0_bss SORT(alignment, name),
        iram->iram0_text SORT(name, name),
        dram->dram0_data SORT(alignment, alignment)
""")

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

        expected = [
            ('text', 'flash_text', [Mapping.Sort('name')]),
            ('rodata', 'flash_rodata', [Mapping.Sort('alignment')]),
            ('data', 'dram0_data', [Mapping.Sort('init_priority')]),
            ('bss', 'dram0_bss', [Mapping.Sort('name', 'alignment')]),
            ('common', 'dram0_bss', [Mapping.Sort('alignment', 'name')]),
            ('iram', 'iram0_text', [Mapping.Sort('name', 'name')]),
            ('dram', 'dram0_data', [Mapping.Sort('alignment', 'alignment')])
        ]
        actual = fragment.flags[('obj1', None, 'default')]
        self.assertEqual(expected, actual)

        test_fragment = self.create_fragment_file(u"""
[mapping:map]
archive: libmain.a
entries:
    obj1 (default)
        text->iram0_text SORT(name) SORT(alignment)
""")