[Reproducible-commits] [debbindiff] 06/06: Add tests for ELF comparators

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Jun 24 12:45:53 UTC 2015


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

lunar pushed a commit to branch master
in repository debbindiff.

commit 8465b18fa4e250d0c37772937c66466df8b2a993
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jun 24 12:45:44 2015 +0000

    Add tests for ELF comparators
---
 tests/comparators/test_elf.py             |  60 ++++++++++++++++++++++++++++++
 tests/data/elf_lib_metadata_expected_diff |   3 ++
 tests/data/elf_lib_objdump_expected_diff  |  26 +++++++++++++
 tests/data/elf_obj_expected_diff          |  26 +++++++++++++
 tests/data/test1.a                        | Bin 0 -> 1354 bytes
 tests/data/test1.o                        | Bin 0 -> 1216 bytes
 tests/data/test2.a                        | Bin 0 -> 1354 bytes
 tests/data/test2.o                        | Bin 0 -> 1216 bytes
 8 files changed, 115 insertions(+)

diff --git a/tests/comparators/test_elf.py b/tests/comparators/test_elf.py
new file mode 100644
index 0000000..718f1fe
--- /dev/null
+++ b/tests/comparators/test_elf.py
@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# debbindiff: highlight differences between two builds of Debian packages
+#
+# Copyright © 2015 Jérémy Bobbio <lunar at debian.org>
+#
+# debbindiff is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# debbindiff is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with debbindiff.  If not, see <http://www.gnu.org/licenses/>.
+
+import os.path
+import shutil
+import pytest
+from debbindiff.comparators.elf import compare_elf_files, compare_static_lib_files
+
+TEST_OBJ1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.o') 
+TEST_OBJ2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.o') 
+
+def test_obj_no_differences():
+    differences = compare_elf_files(TEST_OBJ1_PATH, TEST_OBJ1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def obj_differences():
+    return compare_elf_files(TEST_OBJ1_PATH, TEST_OBJ2_PATH)[0].details # skip container with path
+
+def test_diff(obj_differences):
+    assert len(obj_differences) == 1
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/elf_obj_expected_diff')).read()
+    assert obj_differences[0].unified_diff == expected_diff
+
+TEST_LIB1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.a') 
+TEST_LIB2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.a') 
+
+def test_lib_no_differences():
+    differences = compare_elf_files(TEST_LIB1_PATH, TEST_LIB1_PATH)
+    assert len(differences) == 0
+
+ at pytest.fixture
+def lib_differences():
+    return compare_static_lib_files(TEST_LIB1_PATH, TEST_LIB2_PATH)[0].details # skip container with path
+
+def test_lib_differences(lib_differences):
+    assert len(lib_differences) == 2
+    assert lib_differences[0].source1 == 'metadata'
+    expected_metadata_diff = open(os.path.join(os.path.dirname(__file__), '../data/elf_lib_metadata_expected_diff')).read()
+    assert lib_differences[0].unified_diff == expected_metadata_diff
+    assert 'objdump' in lib_differences[1].source1
+    expected_objdump_diff = open(os.path.join(os.path.dirname(__file__), '../data/elf_lib_objdump_expected_diff')).read()
+    assert lib_differences[1].unified_diff == expected_objdump_diff
diff --git a/tests/data/elf_lib_metadata_expected_diff b/tests/data/elf_lib_metadata_expected_diff
new file mode 100644
index 0000000..0df2063
--- /dev/null
+++ b/tests/data/elf_lib_metadata_expected_diff
@@ -0,0 +1,3 @@
+@@ -1 +1 @@
+-rw-r--r-- 1000/1000   1216 Jun 24 12:13 2015 test.o
++rw-r--r-- 1000/1000   1216 Jun 24 12:14 2015 test.o
diff --git a/tests/data/elf_lib_objdump_expected_diff b/tests/data/elf_lib_objdump_expected_diff
new file mode 100644
index 0000000..feaac29
--- /dev/null
+++ b/tests/data/elf_lib_objdump_expected_diff
@@ -0,0 +1,26 @@
+@@ -1,23 +1,23 @@
+ In archive:
+ 
+ test.o:     file format elf64-x86-64
+ 
+ Contents of section .text:
+- 0000 554889e5 b82a0000 005dc3             UH...*...].     
++ 0000 554889e5 b8ffffff ff5dc3             UH.......].     
+ Contents of section .comment:
+  0000 00474343 3a202844 65626961 6e20342e  .GCC: (Debian 4.
+  0010 372e322d 35292034 2e372e32 00        7.2-5) 4.7.2.   
+ Contents of section .eh_frame:
+  0000 14000000 00000000 017a5200 01781001  .........zR..x..
+  0010 1b0c0708 90010000 1c000000 1c000000  ................
+  0020 00000000 0b000000 00410e10 8602430d  .........A....C.
+  0030 06460c07 08000000                    .F......        
+ 
+ Disassembly of section .text:
+ 
+ 0000000000000000 <f>:
+    0:	55                   	push   %rbp
+    1:	48 89 e5             	mov    %rsp,%rbp
+-   4:	b8 2a 00 00 00       	mov    $0x2a,%eax
++   4:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
+    9:	5d                   	pop    %rbp
+    a:	c3                   	retq   
diff --git a/tests/data/elf_obj_expected_diff b/tests/data/elf_obj_expected_diff
new file mode 100644
index 0000000..4d684f0
--- /dev/null
+++ b/tests/data/elf_obj_expected_diff
@@ -0,0 +1,26 @@
+@@ -1,22 +1,22 @@
+ 
+-test1.o:     file format elf64-x86-64
++test2.o:     file format elf64-x86-64
+ 
+ Contents of section .text:
+- 0000 554889e5 b82a0000 005dc3             UH...*...].     
++ 0000 554889e5 b8ffffff ff5dc3             UH.......].     
+ Contents of section .comment:
+  0000 00474343 3a202844 65626961 6e20342e  .GCC: (Debian 4.
+  0010 372e322d 35292034 2e372e32 00        7.2-5) 4.7.2.   
+ Contents of section .eh_frame:
+  0000 14000000 00000000 017a5200 01781001  .........zR..x..
+  0010 1b0c0708 90010000 1c000000 1c000000  ................
+  0020 00000000 0b000000 00410e10 8602430d  .........A....C.
+  0030 06460c07 08000000                    .F......        
+ 
+ Disassembly of section .text:
+ 
+ 0000000000000000 <f>:
+    0:	55                   	push   %rbp
+    1:	48 89 e5             	mov    %rsp,%rbp
+-   4:	b8 2a 00 00 00       	mov    $0x2a,%eax
++   4:	b8 ff ff ff ff       	mov    $0xffffffff,%eax
+    9:	5d                   	pop    %rbp
+    a:	c3                   	retq   
diff --git a/tests/data/test1.a b/tests/data/test1.a
new file mode 100644
index 0000000..501ca17
Binary files /dev/null and b/tests/data/test1.a differ
diff --git a/tests/data/test1.o b/tests/data/test1.o
new file mode 100644
index 0000000..a94647d
Binary files /dev/null and b/tests/data/test1.o differ
diff --git a/tests/data/test2.a b/tests/data/test2.a
new file mode 100644
index 0000000..4d6f65a
Binary files /dev/null and b/tests/data/test2.a differ
diff --git a/tests/data/test2.o b/tests/data/test2.o
new file mode 100644
index 0000000..1e0bb82
Binary files /dev/null and b/tests/data/test2.o differ

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



More information about the Reproducible-commits mailing list