[diffoscope] 10/12: Add --hide-section=debug-symbols.

Maria Glukhova siamezzze-guest at moszumanska.debian.org
Wed Mar 8 15:59:10 CET 2017


This is an automated email from the git hooks/post-receive script.

siamezzze-guest pushed a commit to branch siamezzze/hide-profiles-experiment
in repository diffoscope.

commit f93a79af4a2be26e87b024313604fe8560961b45
Author: Maria Glukhova <siamezzze at gmail.com>
Date:   Sat Feb 25 14:41:51 2017 +0200

    Add --hide-section=debug-symbols.
---
 diffoscope/comparators/elf.py |  7 ++++++-
 diffoscope/config.py          |  1 +
 diffoscope/main.py            |  4 ++++
 tests/test_hide_profile.py    | 15 +++++++++++++++
 4 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/diffoscope/comparators/elf.py b/diffoscope/comparators/elf.py
index 17b0f26..04c4615 100644
--- a/diffoscope/comparators/elf.py
+++ b/diffoscope/comparators/elf.py
@@ -27,6 +27,7 @@ from diffoscope.exc import OutputParsingError
 from diffoscope.tools import tool_required
 from diffoscope.tempfiles import get_named_temporary_file
 from diffoscope.difference import Difference
+from diffoscope.config import Config
 
 from .deb import DebFile, get_build_id_map
 from .utils.file import File
@@ -411,6 +412,10 @@ class ElfContainer(Container):
 
                 if name.startswith('.debug') or name.startswith('.zdebug'):
                     has_debug_symbols = True
+                    if Config().hide_section == "debug-symbols":
+                        logger.debug("Skipping %s due to request to hide "
+                                     "debug symbols" % name)
+                        continue
 
                 if _should_skip_section(name, type):
                     continue
@@ -432,7 +437,7 @@ class ElfContainer(Container):
             )
             raise OutputParsingError(command, self)
 
-        if not has_debug_symbols:
+        if not has_debug_symbols and Config().hide_section != 'debug-symbols':
             self._install_debug_symbols()
 
     @tool_required('objcopy')
diff --git a/diffoscope/config.py b/diffoscope/config.py
index 67039c3..8a995ac 100644
--- a/diffoscope/config.py
+++ b/diffoscope/config.py
@@ -35,6 +35,7 @@ class Config(object):
     enforce_constraints = True
     excludes = ()
     hide_timestamp = None
+    hide_section = None
 
     _singleton = {}
 
diff --git a/diffoscope/main.py b/diffoscope/main.py
index 7ef6d26..97e0ab2 100644
--- a/diffoscope/main.py
+++ b/diffoscope/main.py
@@ -164,6 +164,9 @@ def create_parser():
     group3.add_argument('--hide-timestamp', dest='hide_timestamp',
                         action='store', choices=['gzip-metadata'],
                         help='hide certain timestamp differences')
+    group3.add_argument('--hide-section', dest='hide_section',
+                        action='store', choices=['debug-symbols'],
+                        help='hide certain timestamp differences')
     group3.add_argument('--fuzzy-threshold', dest='fuzzy_threshold', type=int,
                         help='Threshold for fuzzy-matching '
                         '(0 to disable, %(default)s is default, 400 is high fuzziness)',
@@ -256,6 +259,7 @@ def run_diffoscope(parsed_args):
     Config().new_file = parsed_args.new_file
     Config().excludes = parsed_args.excludes
     Config().hide_timestamp = parsed_args.hide_timestamp
+    Config().hide_section = parsed_args.hide_section
     set_locale()
     logger.debug('Starting comparison')
     ProgressManager().setup(parsed_args)
diff --git a/tests/test_hide_profile.py b/tests/test_hide_profile.py
index e3ee2ef..d04e91e 100644
--- a/tests/test_hide_profile.py
+++ b/tests/test_hide_profile.py
@@ -22,6 +22,9 @@ import pytest
 
 from diffoscope.main import main
 
+from comparators.utils.tools import skip_unless_tools_exist, \
+    skip_if_binutils_does_not_support_x86, skip_unless_module_exists
+
 
 def run(capsys, filenames, *args):
     with pytest.raises(SystemExit) as exc:
@@ -43,3 +46,15 @@ def test_hide_gzip_metadata(capsys):
     assert ret == 1
     assert '── metadata' not in out
     assert '│   --- test1\n├── +++ test2' in out
+
+ at skip_unless_tools_exist('readelf', 'objdump', 'objcopy')
+ at skip_if_binutils_does_not_support_x86()
+ at skip_unless_module_exists('debian.deb822')
+def test_hide_debugsym(capsys):
+    ret, out = run(capsys, ('dbgsym/add/test-dbgsym_1_amd64.deb',
+                            'dbgsym/mult/test-dbgsym_1_amd64.deb'),
+                   '--hide-section=debug-symbols')
+
+    assert ret == 1
+    assert not any(['test-cases/dbgsym/package/test.c:2' in line for
+                    line in out.split()])

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/diffoscope.git


More information about the diffoscope mailing list