[Reproducible-commits] [debbindiff] 03/06: Add tests for squashfs comparator

Jérémy Bobbio lunar at moszumanska.debian.org
Wed Jun 24 17:37:05 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 7e5edfc9bcc4788804d843073dec22c092d53654
Author: Jérémy Bobbio <lunar at debian.org>
Date:   Wed Jun 24 15:06:06 2015 +0000

    Add tests for squashfs comparator
---
 tests/comparators/test_squashfs.py           |  56 +++++++++++++++++++++++++++
 tests/data/squashfs_listing_expected_diff    |  11 ++++++
 tests/data/squashfs_superblock_expected_diff |  13 +++++++
 tests/data/test1.squashfs                    | Bin 0 -> 4096 bytes
 tests/data/test2.squashfs                    | Bin 0 -> 4096 bytes
 5 files changed, 80 insertions(+)

diff --git a/tests/comparators/test_squashfs.py b/tests/comparators/test_squashfs.py
new file mode 100644
index 0000000..b1392ec
--- /dev/null
+++ b/tests/comparators/test_squashfs.py
@@ -0,0 +1,56 @@
+#!/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 codecs
+import os.path
+import shutil
+import pytest
+from debbindiff.comparators.squashfs import compare_squashfs_files
+
+TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.squashfs')
+TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.squashfs')
+
+def test_no_differences():
+    differences = compare_squashfs_files(TEST_FILE1_PATH, TEST_FILE1_PATH)
+    assert len(differences) == 0
+
+ at pytest.mark.xfail
+def test_no_warnings(capfd, differences):
+     compare_squashfs_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+     _, err = capfd.readouterr()
+     assert err == ''
+
+ at pytest.fixture
+def differences():
+    return compare_squashfs_files(TEST_FILE1_PATH, TEST_FILE2_PATH)[0].details # skip container with path
+
+def test_superblock(differences):
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/squashfs_superblock_expected_diff')).read()
+    assert differences[0].unified_diff == expected_diff
+
+def test_listing(differences):
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/squashfs_listing_expected_diff')).read()
+    assert differences[1].unified_diff == expected_diff
+
+def test_compressed_files(differences):
+    assert differences[2].source1 == 'text'
+    assert differences[2].source2 == 'text'
+    expected_diff = open(os.path.join(os.path.dirname(__file__), '../data/text_ascii_expected_diff')).read()
+    assert differences[2].unified_diff == expected_diff
diff --git a/tests/data/squashfs_listing_expected_diff b/tests/data/squashfs_listing_expected_diff
new file mode 100644
index 0000000..06dac4a
--- /dev/null
+++ b/tests/data/squashfs_listing_expected_diff
@@ -0,0 +1,11 @@
+@@ -1,7 +1,7 @@
+ Parallel unsquashfs: Using 4 processors
+ 3 inodes (3 blocks) to write
+ 
+-drwxr-xr-x lunar/lunar              51 2015-06-24 14:47 
+-lrwxrwxrwx lunar/lunar               6 2015-06-24 14:47 /link -> broken
++drwxr-xr-x lunar/lunar              51 2015-06-24 14:50 
++lrwxrwxrwx lunar/lunar              13 2015-06-24 14:50 /link -> really-broken
+ crw-r--r-- root/root             1,  3 2015-06-24 14:47 /null
+--rw-r--r-- lunar/lunar             446 2015-06-24 14:49 /text
++-rw-r--r-- lunar/lunar             671 2015-06-24 14:49 /text
diff --git a/tests/data/squashfs_superblock_expected_diff b/tests/data/squashfs_superblock_expected_diff
new file mode 100644
index 0000000..84ccd3f
--- /dev/null
+++ b/tests/data/squashfs_superblock_expected_diff
@@ -0,0 +1,13 @@
+@@ -1,10 +1,10 @@
+ Found a valid SQUASHFS 4:0 superblock
+-Creation or last append time Wed Jun 24 14:49:50 2015
+-Filesystem size 0.55 Kbytes (0.00 Mbytes)
++Creation or last append time Wed Jun 24 14:50:09 2015
++Filesystem size 0.70 Kbytes (0.00 Mbytes)
+ Compression gzip
+ Block size 131072
+ Filesystem is exportable via NFS
+ Inodes are compressed
+ Data is compressed
+ Fragments are compressed
+ Always_use_fragments option is not specified
diff --git a/tests/data/test1.squashfs b/tests/data/test1.squashfs
new file mode 100644
index 0000000..361d32e
Binary files /dev/null and b/tests/data/test1.squashfs differ
diff --git a/tests/data/test2.squashfs b/tests/data/test2.squashfs
new file mode 100644
index 0000000..13cafe8
Binary files /dev/null and b/tests/data/test2.squashfs 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