[Reproducible-commits] [diffoscope] 01/03: Replace file path by a fixed placeholder in readelf and objdump output

Jérémy Bobbio lunar at moszumanska.debian.org
Tue Dec 22 17:22:38 UTC 2015


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

lunar pushed a commit to branch master
in repository diffoscope.

commit f527e4f2c66f078ca169f4847034150ec1b02d11
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Tue Dec 22 13:39:34 2015 +0000

    Replace file path by a fixed placeholder in readelf and objdump output
    
    We used to replace the file path by its basename. But this won't work when
    diffoscope is working on two ELF files with different basename (which can
    easily happen when the command line specify two different ELF files).
---
 diffoscope/comparators/elf.py    | 6 ++----
 tests/data/elf_obj_expected_diff | 3 +--
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/diffoscope/comparators/elf.py b/diffoscope/comparators/elf.py
index ce2ea3c..e199270 100644
--- a/diffoscope/comparators/elf.py
+++ b/diffoscope/comparators/elf.py
@@ -30,7 +30,6 @@ class Readelf(Command):
         super().__init__(*args, **kwargs)
         # we don't care about the name of the archive
         self._archive_re = re.compile(r'^File: %s\(' % re.escape(self.path))
-        self._basename = os.path.basename(self.path)
 
     @tool_required('readelf')
     def cmdline(self):
@@ -44,7 +43,7 @@ class Readelf(Command):
             # we don't care about the name of the archive
             line = self._archive_re.sub('File: lib.a(', line.decode('utf-8'))
             # the full path can appear in the output, we need to remove it
-            return line.replace(self.path, self._basename).encode('utf-8')
+            return line.replace(self.path, '<elf>').encode('utf-8')
         except UnicodeDecodeError:
             return line
 
@@ -61,7 +60,6 @@ class ObjdumpDisassemble(Command):
         super().__init__(*args, **kwargs)
         # we don't care about the name of the archive
         self._archive_re = re.compile(r'^In archive %s:' % re.escape(self.path))
-        self._basename = os.path.basename(self.path)
 
     @tool_required('objdump')
     def cmdline(self):
@@ -72,7 +70,7 @@ class ObjdumpDisassemble(Command):
             # we don't care about the name of the archive
             line = self._archive_re.sub('In archive:', line.decode('utf-8'))
             # the full path can appear in the output, we need to remove it
-            return line.replace(self.path, self._basename).encode('utf-8')
+            return line.replace(self.path, '<elf>').encode('utf-8')
         except UnicodeDecodeError:
             return line
 
diff --git a/tests/data/elf_obj_expected_diff b/tests/data/elf_obj_expected_diff
index 4d684f0..3aabe2b 100644
--- a/tests/data/elf_obj_expected_diff
+++ b/tests/data/elf_obj_expected_diff
@@ -1,7 +1,6 @@
 @@ -1,22 +1,22 @@
  
--test1.o:     file format elf64-x86-64
-+test2.o:     file format elf64-x86-64
+ <elf>:     file format elf64-x86-64
  
  Contents of section .text:
 - 0000 554889e5 b82a0000 005dc3             UH...*...].     

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



More information about the Reproducible-commits mailing list