コード例 #1
0
def test_elf_linker(fizz_buzz, expected_linker_path):
    # Found by running `readelf -l fizz-buzz`.
    fizz_buzz_elf = Elf(fizz_buzz, chroot=chroot)
    expected_linker_path = os.path.join(
        chroot, os.path.relpath(expected_linker_path, '/'))
    assert fizz_buzz_elf.linker_file.path == expected_linker_path, \
        'The correct linker should be extracted from the ELF program header.'
コード例 #2
0
def test_elf_direct_dependencies(fizz_buzz):
    fizz_buzz_elf = Elf(fizz_buzz, chroot=chroot)
    dependencies = fizz_buzz_elf.direct_dependencies
    assert all(file.path.startswith(chroot) for file in dependencies), \
        'All dependencies should be located within the chroot.'
    assert len(dependencies), 'There should be at least one dependency.'

    # These don't apply to the musl binary.
    if 'glib' in fizz_buzz:
        assert len(dependencies) == 2, 'The linker and libc should be the only dependencies.'
        assert any('libc.so' in file.path for file in dependencies), \
            '"libc" was not found as a direct dependency of the executable.'
コード例 #3
0
def test_elf_type(fizz_buzz, expected_type):
    elf = Elf(fizz_buzz, chroot=chroot)
    assert elf.type == expected_type, 'Fizz buzz should match the expected ELF binary type.'
コード例 #4
0
def test_elf_dependencies(fizz_buzz):
    fizz_buzz_elf = Elf(fizz_buzz, chroot=chroot)
    direct_dependencies = fizz_buzz_elf.direct_dependencies
    all_dependencies = fizz_buzz_elf.dependencies
    assert set(direct_dependencies).issubset(all_dependencies), \
        'The direct dependencies should be a subset of all dependencies.'
コード例 #5
0
def test_elf_bits(fizz_buzz, bits):
    fizz_buzz_elf = Elf(fizz_buzz, chroot=chroot)
    # Can be checked by running `file fizz-buzz`.
    assert fizz_buzz_elf.bits == bits, \
        'The fizz buzz executable should be %d-bit.' % bits