[Reproducible-commits] [diffoscope] 01/01: Skip fsimage tests if libguestfs not supported
Reiner Herrmann
reiner at reiner-h.de
Thu Dec 3 10:10:16 UTC 2015
This is an automated email from the git hooks/post-receive script.
deki-guest pushed a commit to branch master
in repository diffoscope.
commit cdacbb76580c0ff28e8e432038789bbdc6392c0f
Author: Reiner Herrmann <reiner at reiner-h.de>
Date: Thu Dec 3 09:14:17 2015 +0100
Skip fsimage tests if libguestfs not supported
---
diffoscope/comparators/fsimage.py | 6 +++++-
tests/comparators/test_fsimage.py | 18 ++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/diffoscope/comparators/fsimage.py b/diffoscope/comparators/fsimage.py
index f6dd8b3..ca76a3a 100644
--- a/diffoscope/comparators/fsimage.py
+++ b/diffoscope/comparators/fsimage.py
@@ -42,7 +42,11 @@ class FsImageContainer(Archive):
self.g = guestfs.GuestFS (python_return_dict=True)
self.g.add_drive_opts (self.path, format="raw", readonly=1)
- self.g.launch()
+ try:
+ self.g.launch()
+ except RuntimeError:
+ logger.debug("guestfs can't be launched")
+ return None
devices = self.g.list_devices()
self.g.mount(devices[0], "/")
self.fs = self.g.list_filesystems()[devices[0]]
diff --git a/tests/comparators/test_fsimage.py b/tests/comparators/test_fsimage.py
index 91d6cec..7cdc15c 100644
--- a/tests/comparators/test_fsimage.py
+++ b/tests/comparators/test_fsimage.py
@@ -33,6 +33,17 @@ from conftest import tool_missing
TEST_FILE1_PATH = os.path.join(os.path.dirname(__file__), '../data/test1.ext4')
TEST_FILE2_PATH = os.path.join(os.path.dirname(__file__), '../data/test2.ext4')
+def guestfs_working():
+ if miss_guestfs:
+ return False
+ g = guestfs.GuestFS (python_return_dict=True)
+ g.add_drive_opts("/dev/null", format="raw", readonly=1)
+ try:
+ g.launch()
+ except RuntimeError:
+ return False
+ return True
+
@pytest.fixture
def img1():
return specialize(FilesystemFile(TEST_FILE1_PATH))
@@ -44,6 +55,9 @@ def img2():
def test_identification(img1):
assert isinstance(img1, FsImageFile)
+ at pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system')
+ at pytest.mark.skipif(tool_missing('qemu-img'), reason='missing qemu-img')
+ at pytest.mark.skipif(miss_guestfs, reason='guestfs is missing')
def test_no_differences(img1):
difference = img1.compare(img1)
assert difference is None
@@ -52,6 +66,8 @@ def test_no_differences(img1):
def differences(img1, img2):
return img1.compare(img2).details
+ at pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system')
+ at pytest.mark.skipif(tool_missing('qemu-img'), reason='missing qemu-img')
@pytest.mark.skipif(miss_guestfs, reason='guestfs is missing')
def test_differences(differences):
assert differences[0].source1 == 'test1.ext4.tar'
@@ -68,6 +84,8 @@ def test_differences(differences):
found_diff = tarinfo.unified_diff + tardiff.unified_diff + encodingdiff.unified_diff
assert expected_diff == found_diff
+ at pytest.mark.skipif(not guestfs_working(), reason='guestfs not working on the system')
+ at pytest.mark.skipif(tool_missing('qemu-img'), reason='missing qemu-img')
@pytest.mark.skipif(miss_guestfs, reason='guestfs is missing')
def test_compare_non_existing(monkeypatch, img1):
monkeypatch.setattr(Config.general, 'new_file', True)
--
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