Skip to content
Snippets Groups Projects
Commit 2de5369c authored by Chris Lamb's avatar Chris Lamb :eyes:
Browse files

Don't run binwalk tests as root (or, more likely, under fakeroot). The latest...

Don't run binwalk tests as root (or, more likely, under fakeroot). The latest version of binwalk has some security protection against this.
parent 9e1786fa
No related branches found
No related tags found
No related merge requests found
Pipeline #344738 passed
#
# diffoscope: in-depth comparison of files, archives, and directories
#
# Copyright © 2017, 2020 Chris Lamb <lamby@debian.org>
# Copyright © 2017, 2020, 2022 Chris Lamb <lamby@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import os
import pytest
from diffoscope.comparators.binwalk import BinwalkFile
......@@ -27,13 +28,19 @@ from ..utils.nonexisting import assert_non_existing
binwalk1 = load_fixture("test1.binwalk")
binwalk2 = load_fixture("test2.binwalk")
skip_if_root = pytest.mark.skipif(
os.getuid() == 0, reason="cannot be run as root"
)
@skip_if_root
@skip_unless_module_exists("binwalk")
def test_identification(binwalk1, binwalk2):
assert isinstance(binwalk1, BinwalkFile)
assert isinstance(binwalk2, BinwalkFile)
@skip_if_root
@skip_unless_module_exists("binwalk")
def test_no_differences(binwalk1):
difference = binwalk1.compare(binwalk1)
......@@ -45,6 +52,7 @@ def comparison(binwalk1, binwalk2):
return binwalk1.compare(binwalk2)
@skip_if_root
@skip_unless_tools_exist("cpio")
@skip_unless_module_exists("binwalk")
def test_listing(comparison):
......@@ -57,6 +65,7 @@ def test_listing(comparison):
assert differences[0].details[0].unified_diff == expected_diff
@skip_if_root
@skip_unless_tools_exist("cpio")
@skip_unless_module_exists("binwalk")
def test_symlink(comparison):
......@@ -67,6 +76,7 @@ def test_symlink(comparison):
assert differences[0].details[1].unified_diff == expected_diff
@skip_if_root
@skip_unless_tools_exist("cpio")
@skip_unless_module_exists("binwalk")
def test_compare_non_existing(monkeypatch, binwalk1):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment