skip "do not retry when permissions denied" test if running as root

we can not take away read permissions for root,
so the test would fail.
This commit is contained in:
Thomas Waldmann 2023-03-28 15:44:36 +02:00
parent 0fa44e4079
commit 2692fa1146
No known key found for this signature in database
GPG key ID: 243ACFA951F78E01
2 changed files with 12 additions and 0 deletions

View file

@ -18,6 +18,7 @@ import unittest
from ..xattr import get_all
from ..platform import get_flags
from ..platformflags import is_win32
from ..helpers import umount
from ..helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
from .. import platform
@ -66,6 +67,14 @@ def unopened_tempfile():
yield os.path.join(tempdir, "file")
def is_root():
"""return True if running with high privileges, like as root"""
if is_win32:
return False # TODO
else:
return os.getuid() == 0
@functools.lru_cache
def are_symlinks_supported():
with unopened_tempfile() as filepath:

View file

@ -25,6 +25,7 @@ from .. import (
is_utime_fully_supported,
is_birthtime_fully_supported,
same_ts_ns,
is_root,
)
from . import (
ArchiverTestCaseBase,
@ -219,6 +220,7 @@ class ArchiverTestCase(ArchiverTestCaseBase):
assert "input/file2" in out
assert "input/file3" in out
@pytest.mark.skipif(is_root(), reason="test must not be run as (fake)root")
def test_create_no_permission_file(self):
file_path = os.path.join(self.input_path, "file")
self.create_regular_file(file_path + "1", size=1000)
@ -228,6 +230,7 @@ class ArchiverTestCase(ArchiverTestCaseBase):
if is_win32:
subprocess.run(["icacls.exe", file_path + "2", "/deny", "everyone:(R)"])
else:
# note: this will NOT take away read permissions for root
os.chmod(file_path + "2", 0o000)
self.cmd(f"--repo={self.repository_location}", "rcreate", RK_ENCRYPTION)
flist = "".join(f"input/file{n}\n" for n in range(1, 4))