From 1deeb0b17db7f4dbf6a582eacab7c577cc6fbd65 Mon Sep 17 00:00:00 2001 From: Rayyan Ansari Date: Sun, 27 Nov 2022 13:20:14 +0000 Subject: [PATCH] testsuite: archiver: do not try to create special devices on Windows Windows does not support these file types in userspace programs. --- src/borg/testsuite/archiver/__init__.py | 37 ++++++++++++++----------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/borg/testsuite/archiver/__init__.py b/src/borg/testsuite/archiver/__init__.py index a9a5da6d3..0b6e137ba 100644 --- a/src/borg/testsuite/archiver/__init__.py +++ b/src/borg/testsuite/archiver/__init__.py @@ -28,6 +28,7 @@ from ...repository import Repository from .. import has_lchflags from .. import BaseTestCase, changedir, environment_variable from .. import are_symlinks_supported, are_hardlinks_supported, are_fifos_supported +from ..platform import is_win32 RK_ENCRYPTION = "--encryption=repokey-aes-ocb" KF_ENCRYPTION = "--encryption=keyfile-chacha20-poly1305" @@ -230,23 +231,27 @@ class ArchiverTestCaseBase(BaseTestCase): os.mkfifo(os.path.join(self.input_path, "fifo1")) if has_lchflags: platform.set_flags(os.path.join(self.input_path, "flagfile"), stat.UF_NODUMP) - try: - # Block device - os.mknod("input/bdev", 0o600 | stat.S_IFBLK, os.makedev(10, 20)) - # Char device - os.mknod("input/cdev", 0o600 | stat.S_IFCHR, os.makedev(30, 40)) - # File owner - os.chown("input/file1", 100, 200) # raises OSError invalid argument on cygwin - # File mode - os.chmod("input/dir2", 0o555) # if we take away write perms, we need root to remove contents - have_root = True # we have (fake)root - except PermissionError: - have_root = False - except OSError as e: - # Note: ENOSYS "Function not implemented" happens as non-root on Win 10 Linux Subsystem. - if e.errno not in (errno.EINVAL, errno.ENOSYS): - raise + + if is_win32: have_root = False + else: + try: + # Block device + os.mknod("input/bdev", 0o600 | stat.S_IFBLK, os.makedev(10, 20)) + # Char device + os.mknod("input/cdev", 0o600 | stat.S_IFCHR, os.makedev(30, 40)) + # File owner + os.chown("input/file1", 100, 200) # raises OSError invalid argument on cygwin + # File mode + os.chmod("input/dir2", 0o555) # if we take away write perms, we need root to remove contents + have_root = True # we have (fake)root + except PermissionError: + have_root = False + except OSError as e: + # Note: ENOSYS "Function not implemented" happens as non-root on Win 10 Linux Subsystem. + if e.errno not in (errno.EINVAL, errno.ENOSYS): + raise + have_root = False time.sleep(1) # "empty" must have newer timestamp than other files self.create_regular_file("empty", size=0) return have_root