Skip to content

Commit 0a553dd

Browse files
testsuite: improve haiku compatibility
haiku does not have os.mknod. and it looks like it does not have hardlinks either.
1 parent a022d56 commit 0a553dd

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/borg/testsuite/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
# Does this version of llfuse support ns precision?
3131
have_fuse_mtime_ns = hasattr(llfuse.EntryAttributes, 'st_mtime_ns') if llfuse else False
3232

33+
has_mknod = hasattr(os, 'mknod')
34+
3335
try:
3436
from pytest import raises
3537
except: # noqa

src/borg/testsuite/archiver.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
from ..logger import setup_logging
5757
from ..remote import RemoteRepository, PathNotAllowed
5858
from ..repository import Repository
59-
from . import has_lchflags, llfuse
59+
from . import has_lchflags, has_mknod, llfuse
6060
from . import BaseTestCase, changedir, environment_variable, no_selinux, same_ts_ns, granularity_sleep
6161
from . import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported, is_utime_fully_supported, is_birthtime_fully_supported
6262
from .platform import fakeroot_detected, is_darwin, is_freebsd, is_win32
@@ -367,10 +367,11 @@ def create_test_files(self, create_hardlinks=True):
367367
if has_lchflags:
368368
platform.set_flags(os.path.join(self.input_path, 'flagfile'), stat.UF_NODUMP)
369369
try:
370-
# Block device
371-
os.mknod('input/bdev', 0o600 | stat.S_IFBLK, os.makedev(10, 20))
372-
# Char device
373-
os.mknod('input/cdev', 0o600 | stat.S_IFCHR, os.makedev(30, 40))
370+
if has_mknod:
371+
# Block device
372+
os.mknod('input/bdev', 0o600 | stat.S_IFBLK, os.makedev(10, 20))
373+
# Char device
374+
os.mknod('input/cdev', 0o600 | stat.S_IFCHR, os.makedev(30, 40))
374375
# File mode
375376
os.chmod('input/dir2', 0o555) # if we take away write perms, we need root to remove contents
376377
# File owner
@@ -426,8 +427,8 @@ def test_basic_functionality(self):
426427
expected.append('input/link1')
427428
if are_hardlinks_supported():
428429
expected.append('input/hardlink')
429-
if not have_root:
430-
# we could not create these device files without (fake)root
430+
if not have_root or not has_mknod:
431+
# we could not create these device files without (fake)root or without os.mknod
431432
expected.remove('input/bdev')
432433
expected.remove('input/cdev')
433434
if has_lchflags:

0 commit comments

Comments
 (0)