Skip to content
Commits on Source (3)
......@@ -263,7 +263,7 @@ READELF_COMMANDS = (
def _compare_elf_data(path1, path2):
return [
Difference.from_command(x, path1, path2)
Difference.from_command(x, path1, path2, ignore_returncodes={1})
for x in list(READELF_COMMANDS) + READELF_DEBUG_DUMP_COMMANDS
]
......
......@@ -19,6 +19,7 @@
import heapq
import logging
import subprocess
from . import feeders
from .exc import RequiredToolNotFound
......@@ -256,10 +257,8 @@ class Difference(object):
@staticmethod
def from_command_exc(klass, path1, path2, *args, **kwargs):
command_args = []
if 'command_args' in kwargs:
command_args = kwargs['command_args']
del kwargs['command_args']
command_args = kwargs.pop('command_args', [])
ignore_returncodes = kwargs.pop('ignore_returncodes', ())
def command_and_feeder(path):
command = None
......@@ -283,9 +282,15 @@ class Difference(object):
source_cmd = command1 or command2
kwargs['source'] = source_cmd.shell_cmdline()
difference = Difference.from_feeder(
feeder1, feeder2, path1, path2, *args, **kwargs
)
try:
difference = Difference.from_feeder(
feeder1, feeder2, path1, path2, *args, **kwargs
)
except subprocess.CalledProcessError as exc:
if exc.returncode in ignore_returncodes:
return None, False
assert False, exc.__dict__
if not difference:
return None, False
......
......@@ -41,6 +41,8 @@ from ..utils.tools import (
obj1 = load_fixture('test1.o')
obj2 = load_fixture('test2.o')
bug_903446 = load_fixture('bug_903446.a')
ignore_readelf_errors1 = load_fixture('test1.debug')
ignore_readelf_errors2 = load_fixture('test2.debug')
def readelf_version():
......@@ -203,3 +205,28 @@ def test_bug_903446(bug_903446):
# Not a real StaticLibFile
assert isinstance(bug_903446, FilesystemFile)
def test_ignore_readelf_errors1_identify(ignore_readelf_errors1):
assert isinstance(ignore_readelf_errors1, ElfFile)
def test_ignore_readelf_errors1_identify(ignore_readelf_errors2):
assert isinstance(ignore_readelf_errors2, ElfFile)
@pytest.fixture
def ignore_readelf_errors_differences(
ignore_readelf_errors1, ignore_readelf_errors2
):
return ignore_readelf_errors1.compare(ignore_readelf_errors2).details
@skip_unless_tools_exist('readelf')
@skip_if_tool_version_is('readelf', readelf_version, '2.29')
@skip_if_binutils_does_not_support_x86()
def test_ignore_readelf_errors(ignore_readelf_errors_differences):
with open('tests/data/ignore_readelf_errors_expected_diff', 'w') as f:
f.write(ignore_readelf_errors_differences[0].unified_diff)
expected_diff = get_data('ignore_readelf_errors_expected_diff')
assert ignore_readelf_errors_differences[0].unified_diff == expected_diff
@@ -23,19 +23,19 @@
[18] .dynamic NOBITS 0000000000003de0 000dd0 000200 10 WA 4 0 8
[19] .got NOBITS 0000000000003fe0 000dd0 000020 08 WA 0 0 8
[20] .got.plt NOBITS 0000000000004000 000dd0 000020 08 WA 0 0 8
[21] .data NOBITS 0000000000004020 000dd0 000008 00 WA 0 0 8
[22] .bss NOBITS 0000000000004028 000dd0 000008 00 WA 0 0 1
[23] .comment PROGBITS 0000000000000000 00025c 00001d 01 MS 0 0 1
[24] .debug_aranges PROGBITS 0000000000000000 000279 00005a 00 C 0 0 1
- [25] .debug_info PROGBITS 0000000000000000 0002d3 000330 00 C 0 0 1
- [26] .debug_abbrev PROGBITS 0000000000000000 000603 0000da 00 C 0 0 1
- [27] .debug_line PROGBITS 0000000000000000 0006dd 000176 00 C 0 0 1
- [28] .debug_str PROGBITS 0000000000000000 000853 0002c3 01 MSC 0 0 1
- [29] .debug_ranges PROGBITS 0000000000000000 000b16 00004e 00 C 0 0 1
+ [25] .debug_info PROGBITS 0000000000000000 0002d3 00032e 00 C 0 0 1
+ [26] .debug_abbrev PROGBITS 0000000000000000 000601 0000da 00 C 0 0 1
+ [27] .debug_line PROGBITS 0000000000000000 0006db 000176 00 C 0 0 1
+ [28] .debug_str PROGBITS 0000000000000000 000851 0002c4 01 MSC 0 0 1
+ [29] .debug_ranges PROGBITS 0000000000000000 000b15 00004e 00 C 0 0 1
[30] .symtab SYMTAB 0000000000000000 000b68 000690 18 31 49 8
[31] .strtab STRTAB 0000000000000000 0011f8 0002ca 00 0 0 1
[32] .shstrtab STRTAB 0000000000000000 0014c2 000137 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),