mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-21 21:57:36 +00:00
Skip xattr tests unless xattr is enabled on host
This commit is contained in:
parent
7dd937fb4e
commit
3721f04f05
3 changed files with 20 additions and 5 deletions
|
@ -33,7 +33,7 @@ class ArchiverTestCase(DarcTestCase):
|
|||
|
||||
def setUp(self):
|
||||
self.archiver = Archiver()
|
||||
self.tmpdir = tempfile.mkdtemp(dir=os.getcwd())
|
||||
self.tmpdir = tempfile.mkdtemp()
|
||||
self.repository_path = os.path.join(self.tmpdir, 'repository')
|
||||
self.repository_location = self.prefix + self.repository_path
|
||||
self.input_path = os.path.join(self.tmpdir, 'input')
|
||||
|
@ -123,7 +123,8 @@ def test_basic_functionality(self):
|
|||
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))
|
||||
xattr.set(os.path.join(self.input_path, 'file1'), b'foo', b'bar')
|
||||
if xattr.is_enabled():
|
||||
xattr.set(os.path.join(self.input_path, 'file1'), b'foo', b'bar')
|
||||
# Hard link
|
||||
os.link(os.path.join(self.input_path, 'file1'),
|
||||
os.path.join(self.input_path, 'hardlink'))
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
import tempfile
|
||||
import os
|
||||
import tempfile
|
||||
import unittest
|
||||
from darc.testsuite import DarcTestCase
|
||||
from darc.xattr import lsetxattr, llistxattr, lgetxattr, get_all, set, flistxattr, fgetxattr, fsetxattr
|
||||
from darc.xattr import lsetxattr, llistxattr, lgetxattr, get_all, set, flistxattr, fgetxattr, fsetxattr, is_enabled
|
||||
|
||||
|
||||
@unittest.skipUnless(is_enabled(), 'xattr not enabled on filesystem')
|
||||
class XattrTestCase(DarcTestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.tmpfile = tempfile.NamedTemporaryFile(dir=os.getcwd())
|
||||
self.tmpfile = tempfile.NamedTemporaryFile()
|
||||
self.symlink = os.path.join(os.path.dirname(self.tmpfile.name), 'symlink')
|
||||
os.symlink(self.tmpfile.name, self.symlink)
|
||||
|
||||
|
|
|
@ -4,12 +4,24 @@
|
|||
"""
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
from ctypes import CDLL, create_string_buffer, c_ssize_t, c_size_t, c_char_p, c_int, c_uint32, get_errno
|
||||
from ctypes.util import find_library
|
||||
|
||||
libc = CDLL(find_library('c'), use_errno=True)
|
||||
|
||||
|
||||
def is_enabled():
|
||||
"""Determine if xattr is enabled on the filesystem
|
||||
"""
|
||||
with tempfile.TemporaryFile() as fd:
|
||||
try:
|
||||
set(fd.fileno(), b'name', b'value')
|
||||
except OSError:
|
||||
return False
|
||||
return get_all(fd.fileno()) == {b'name': b'value'}
|
||||
|
||||
|
||||
def set(path_or_fd, name, value):
|
||||
if isinstance(path_or_fd, int):
|
||||
fsetxattr(path_or_fd, name, value)
|
||||
|
|
Loading…
Reference in a new issue