source: diffoscope version: 68 tags: patch So, I finally managed to look into the tests failures were have been seeing in ubuntu's autopkgtest in armhf (and probably also ppc64el and s390x, but I didn't test for that). As supposed, the reason is that we're trying to disassemble x86-64 binaries, and the installed multiarch can't deal with them; remember that the failing tests happen during the 2 py.test call, run without _any_ recommended package installed.
Now, I came up with a patch, but my python foo has its limit, and I
think somebody might improve it quite some (e.g. please tell me how I
can write a decorated fuction that doesn't take any value as input and
still returns only pytest.mark.skipif()... what I did is uglyugly), so
I'm filing it as a bug here instead of committing; see the attachment :)
--
regards,
Mattia Rizzolo
GPG Key: 66AE 2B4A FCCF 3F52 DA18 4D18 4B04 3FCD B944 4540 .''`.
more about me: https://mapreri.org : :' :
Launchpad user: https://launchpad.net/~mapreri `. `'`
Debian QA page: https://qa.debian.org/developer.php?login=mattia `-
From a3142441274daa34c0e96f245e48a0ee2def9e7c Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo <[email protected]> Date: Mon, 16 Jan 2017 17:07:21 +0100 Subject: [PATCH] Skip some tests involving readelf/objdump/nm if the tools installed are not able to deal with elf64-x86-64 binaries --- tests/comparators/test_elf.py | 7 ++++++- tests/comparators/test_rlib.py | 4 +++- tests/comparators/utils.py | 10 ++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/comparators/test_elf.py b/tests/comparators/test_elf.py index 362d893..3b147a8 100644 --- a/tests/comparators/test_elf.py +++ b/tests/comparators/test_elf.py @@ -28,7 +28,8 @@ from diffoscope.comparators.directory import FilesystemDirectory from diffoscope.comparators.missing_file import MissingFile from diffoscope.comparators.utils.specialize import specialize -from utils import skip_unless_tools_exist, data, load_fixture +from utils import skip_unless_tools_exist, data, load_fixture, \ + skip_if_binutils_do_not_support_x86 try: import diffoscope.comparators.debian # noqa @@ -51,6 +52,7 @@ def obj_differences(obj1, obj2): return obj1.compare(obj2).details @skip_unless_tools_exist('readelf') +@skip_if_binutils_do_not_support_x86(True) def test_obj_compare_non_existing(monkeypatch, obj1): monkeypatch.setattr(Config(), 'new_file', True) difference = obj1.compare(MissingFile('/nonexisting', obj1)) @@ -58,6 +60,7 @@ def test_obj_compare_non_existing(monkeypatch, obj1): assert len(difference.details) > 0 @skip_unless_tools_exist('readelf') +@skip_if_binutils_do_not_support_x86(True) def test_diff(obj_differences): assert len(obj_differences) == 1 expected_diff = open(data('elf_obj_expected_diff')).read() @@ -86,6 +89,7 @@ def lib_differences(lib1, lib2): return lib1.compare(lib2).details @skip_unless_tools_exist('readelf', 'objdump') +@skip_if_binutils_do_not_support_x86(True) def test_lib_differences(lib_differences): assert len(lib_differences) == 2 assert lib_differences[0].source1 == 'file list' @@ -96,6 +100,7 @@ def test_lib_differences(lib_differences): assert lib_differences[1].unified_diff == expected_objdump_diff @skip_unless_tools_exist('readelf', 'objdump') +@skip_if_binutils_do_not_support_x86(True) def test_lib_compare_non_existing(monkeypatch, lib1): monkeypatch.setattr(Config(), 'new_file', True) difference = lib1.compare(MissingFile('/nonexisting', lib1)) diff --git a/tests/comparators/test_rlib.py b/tests/comparators/test_rlib.py index 93699fc..8e947bd 100644 --- a/tests/comparators/test_rlib.py +++ b/tests/comparators/test_rlib.py @@ -25,7 +25,7 @@ from diffoscope.comparators.ar import ArFile from utils import skip_unless_tools_exist, skip_unless_tool_is_at_least, \ skip_unless_tools_exist, data, load_fixture, assert_non_existing, \ - diff_ignore_line_numbers + diff_ignore_line_numbers, skip_if_binutils_do_not_support_x86 rlib1 = load_fixture(data('test1.rlib')) rlib2 = load_fixture(data('test2.rlib')) @@ -49,6 +49,7 @@ def test_num_items(differences): assert len(differences) == 4 @skip_unless_tools_exist('nm') +@skip_if_binutils_do_not_support_x86(True) def test_item0_armap(differences): assert differences[0].source1 == 'nm -s {}' assert differences[0].source2 == 'nm -s {}' @@ -56,6 +57,7 @@ def test_item0_armap(differences): assert differences[0].unified_diff == expected_diff @skip_unless_tools_exist('nm') +@skip_if_binutils_do_not_support_x86(True) def test_item1_elf(differences): assert differences[1].source1 == 'alloc_system-d16b8f0e.0.o' assert differences[1].source2 == 'alloc_system-d16b8f0e.0.o' diff --git a/tests/comparators/utils.py b/tests/comparators/utils.py index 5a0930f..c7c881a 100644 --- a/tests/comparators/utils.py +++ b/tests/comparators/utils.py @@ -20,6 +20,7 @@ import os import re import pytest +import subprocess import diffoscope from distutils.spawn import find_executable @@ -54,6 +55,15 @@ def skip_unless_tool_is_at_least(tool, actual_ver, min_ver, vcls=LooseVersion): reason="requires {} >= {} ({} detected)".format(tool, min_ver, actual_ver) ) +def skip_if_binutils_do_not_support_x86(func): + if tools_missing('objdump'): + return skip_unless_tools_exists('objdump') + out = subprocess.check_output(('objdump', '-i')).decode('utf-8').splitlines() + return pytest.mark.skipif( + 'elf64-x86-64' not in out, + reason="requires a binutils capable of reading x86-64 binaries" + ) + def load_fixture(filename): return pytest.fixture( lambda: specialize(FilesystemFile(filename)) -- 2.11.0
signature.asc
Description: PGP signature

