Ejemplo n.º 1
0
def test_no_build_id_on_dump():
    elf_fixture_filename = os.path.join(
        ELF_FIXTURES_DIR, "memfault_build_id_present_and_unpopulated.elf")
    with pytest.raises(Exception, match="No Build ID Found"):
        with open(elf_fixture_filename, "rb") as elf_fixture_file:
            b = BuildIdInspectorAndPatcher(elf_fixture_file)
            b.dump_build_info(num_chars=1)
Ejemplo n.º 2
0
def test_get_build_info(fixture, expected_result):
    elf_fixture_filename = os.path.join(ELF_FIXTURES_DIR, fixture)
    with open_copy(elf_fixture_filename, mode="rb") as elf_copy_file:
        b = BuildIdInspectorAndPatcher(elf_copy_file)
        assert b.get_build_info() == expected_result

        assert filecmp.cmp(elf_copy_file.name, elf_fixture_filename)
Ejemplo n.º 3
0
def test_no_memfault_sdk_present():
    elf_fixture_filename = os.path.join(ELF_FIXTURES_DIR,
                                        "no_memfault_symbols.elf")
    with pytest.raises(
            Exception,
            match=
            "Could not locate 'g_memfault_build_id' symbol in provided ELF"):
        with open(elf_fixture_filename, "rb") as elf_fixture_file:
            b = BuildIdInspectorAndPatcher(elf_fixture_file)
            b.check_or_update_build_id()
Ejemplo n.º 4
0
def test_memfault_id_populated(capsys, snapshot):
    elf_fixture_filename = os.path.join(
        ELF_FIXTURES_DIR, "memfault_build_id_present_and_populated.elf")

    with open_copy(elf_fixture_filename, mode="rb") as elf_copy_file:
        b = BuildIdInspectorAndPatcher(elf_copy_file)
        b.check_or_update_build_id()

        assert filecmp.cmp(elf_copy_file.name, elf_fixture_filename)

    out, _ = capsys.readouterr()
    lines = out.splitlines()
    snapshot.assert_match(lines)