Skip to content

tools/target/target_test.py does not handle missing sector keyword correctly #12219

@JanneKiiskila

Description

@JanneKiiskila

Description of defect

The target testing tool does not correctly recognize the lack of "sector" -keyword in the index.json -file. This is a problem, as the tests will fail with an error, which does not tell you WHERE the actual issue itself is.

It should be fixed to the Python script, so that the target name gets printed out correctly in the assert (probably one more asset needs to be added?).

We get this:

=================================== FAILURES ===================================
_____________________________ test_bl_has_sectors ______________________________
    def test_bl_has_sectors():
        """Assert a bootloader supporting pack has sector information"""
        cache = Cache(True, True)
        named_targets = (
            target for target in TARGETS if
            (hasattr(target, "device_name") and getattr(target, "bootloader_supported", False))
        )
        for target in named_targets:
            assert target.device_name in cache.index,\
                ("Target %s contains invalid device_name %s" %
                 (target.name, target.device_name))
>           assert cache.index[target.device_name]["sectors"],\
                ("Device name %s is misssing sector information" %
                 (target.device_name))
E           KeyError: 'sectors'

Reason most likely is that the whole "sectors" -value is NOT for that target in the index.json -file.
Originating offending PR is here; #12163

Target(s) affected by this defect ?

Any target, which has a bootloader enabled but does not have the sectors information in the index.json, but good luck figuring out which one. :-)

Toolchain(s) (name and version) displaying this defect ?

Travis/CI - Python

What version of Mbed-os are you using (tag or sha) ?

Current master, 4b0c4a0

What version(s) of tools are you using. List all that apply (E.g. mbed-cli)

N/A

How is this defect reproduced ?

Update index.json and add a new entry without the "sectors" -information, most likely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions