[diffoscope] 02/02: Improve names in output of "internal" binwalk members. (Closes: #877525)

Chris Lamb chris at chris-lamb.co.uk
Tue Oct 3 18:09:57 CEST 2017


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

lamby pushed a commit to branch master
in repository diffoscope.

commit 07c05626c4190732dbab010ec734bef19d9b48eb
Author: Chris Lamb <lamby at debian.org>
Date:   Tue Oct 3 17:09:45 2017 +0100

    Improve names in output of "internal" binwalk members. (Closes: #877525)
---
 diffoscope/comparators/binwalk.py | 15 ++++++++++++++-
 tests/comparators/test_binwalk.py |  5 +++--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/diffoscope/comparators/binwalk.py b/diffoscope/comparators/binwalk.py
index 0382cf0..b3f5600 100644
--- a/diffoscope/comparators/binwalk.py
+++ b/diffoscope/comparators/binwalk.py
@@ -89,7 +89,10 @@ class BinwalkFile(File):
         )
 
         members = {
-            os.path.basename(x): x
+            '{} file embedded at offset {}'.format(
+                os.path.splitext(x)[1],
+                os.path.basename(os.path.splitext(x)[0]),
+            ): x
             for x in glob.glob(os.path.join(unpacked.name, '*/*'))
         }
 
@@ -103,3 +106,13 @@ class BinwalkFile(File):
         file._unpacked = unpacked
 
         return True
+
+    def compare(self, other, source=None):
+        difference = super().compare(other, source)
+
+        if difference is not None:
+            difference.add_comment(
+                "comprises of {} embedded members".format(len(self._members))
+            )
+
+        return difference
diff --git a/tests/comparators/test_binwalk.py b/tests/comparators/test_binwalk.py
index a205ff2..f4b841d 100644
--- a/tests/comparators/test_binwalk.py
+++ b/tests/comparators/test_binwalk.py
@@ -50,8 +50,9 @@ def comparison(binwalk1, binwalk2):
 @skip_unless_module_exists('binwalk')
 def test_listing(comparison):
     differences = comparison.details
-    assert differences[0].source1 == '0.cpio'
-    assert differences[1].source2 == '600.cpio'
+    assert comparison.comments == ["comprises of 2 embedded members"]
+    assert differences[0].source1 == '.cpio file embedded at offset 0'
+    assert differences[1].source2 == '.cpio file embedded at offset 600'
 
     expected_diff = get_data('binwalk_expected_diff')
     assert differences[0].details[0].unified_diff == expected_diff

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


More information about the diffoscope mailing list