Repository: borgbackup/borg

Issue:
vagrant darwin64: fakeroot fuse test failures
darwin64 VM: fakeroot -u tox -e py34

```
__________________________ ArchiverTestCase.test_fuse __________________________

self = <borg.testsuite.archiver.ArchiverTestCase testMethod=test_fuse>

    @unittest.skipUnless(has_llfuse, 'llfuse not installed')
    def test_fuse(self):
        def has_noatime(some_file):
            atime_before = os.stat(some_file).st_atime_ns
            try:
                os.close(os.open(some_file, flags_noatime))
            except PermissionError:
                return False
            else:
                atime_after = os.stat(some_file).st_atime_ns
                noatime_used = flags_noatime != flags_normal
                return noatime_used and atime_before == atime_after

        self.cmd('init', self.repository_location)
        self.create_test_files()
        have_noatime = has_noatime('input/file1')
        self.cmd('create', self.repository_location + '::archive', 'input')
        self.cmd('create', self.repository_location + '::archive2', 'input')
        if has_lchflags:
            # remove the file we did not backup, so input and output become equal
            os.remove(os.path.join('input', 'flagfile'))
        mountpoint = os.path.join(self.tmpdir, 'mountpoint')
        # mount the whole repository, archive contents shall show up in archivename subdirs of mountpoint:
        with self.fuse_mount(self.repository_location, mountpoint):
>           self.assert_dirs_equal(self.input_path, os.path.join(mountpoint, 'archive', 'input'))

.tox/py34/lib/python3.4/site-packages/borg/testsuite/archiver.py:1383: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py34/lib/python3.4/site-packages/borg/testsuite/__init__.py:142: in assert_dirs_equal
    self._assert_dirs_equal_cmp(diff)
.tox/py34/lib/python3.4/site-packages/borg/testsuite/__init__.py:145: in _assert_dirs_equal_cmp
    self.assert_equal(diff.left_only, [])
/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:247: in __getattr__
    self.methodmap[attr](self)
/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:141: in phase1
    a = dict(zip(map(os.path.normcase, self.left_list), self.left_list))
/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:247: in __getattr__
    self.methodmap[attr](self)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <filecmp.dircmp object at 0x1040ce278>

    def phase0(self): # Compare everything except common subdirectories
        self.left_list = _filter(os.listdir(self.left),
                                 self.hide+self.ignore)
>       self.right_list = _filter(os.listdir(self.right),
                                  self.hide+self.ignore)
E       PermissionError: [Errno 13] Permission denied: '/var/folders/rm/ywx69srx1kq_dtjz2ynznn000000gp/T/tmp69k9ibmu/mountpoint/archive/input'

/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:135: PermissionError
___________________ ArchiverTestCase.test_fuse_versions_view ___________________

self = <borg.testsuite.archiver.ArchiverTestCase testMethod=test_fuse_versions_view>

    @unittest.skipUnless(has_llfuse, 'llfuse not installed')
    def test_fuse_versions_view(self):
        self.cmd('init', self.repository_location)
        self.create_regular_file('test', contents=b'first')
        self.cmd('create', self.repository_location + '::archive1', 'input')
        self.create_regular_file('test', contents=b'second')
        self.cmd('create', self.repository_location + '::archive2', 'input')
        mountpoint = os.path.join(self.tmpdir, 'mountpoint')
        # mount the whole repository, archive contents shall show up in versioned view:
        with self.fuse_mount(self.repository_location, mountpoint, 'versions'):
            path = os.path.join(mountpoint, 'input', 'test')  # filename shows up as directory ...
>           files = os.listdir(path)
E           PermissionError: [Errno 13] Permission denied: '/var/folders/rm/ywx69srx1kq_dtjz2ynznn000000gp/T/tmp7hwx7e4c/mountpoint/input/test'

.tox/py34/lib/python3.4/site-packages/borg/testsuite/archiver.py:1455: PermissionError
_______________________ ArchiverTestCaseBinary.test_fuse _______________________

self = <borg.testsuite.archiver.ArchiverTestCaseBinary testMethod=test_fuse>

    @unittest.skipUnless(has_llfuse, 'llfuse not installed')
    def test_fuse(self):
        def has_noatime(some_file):
            atime_before = os.stat(some_file).st_atime_ns
            try:
                os.close(os.open(some_file, flags_noatime))
            except PermissionError:
                return False
            else:
                atime_after = os.stat(some_file).st_atime_ns
                noatime_used = flags_noatime != flags_normal
                return noatime_used and atime_before == atime_after

        self.cmd('init', self.repository_location)
        self.create_test_files()
        have_noatime = has_noatime('input/file1')
        self.cmd('create', self.repository_location + '::archive', 'input')
        self.cmd('create', self.repository_location + '::archive2', 'input')
        if has_lchflags:
            # remove the file we did not backup, so input and output become equal
            os.remove(os.path.join('input', 'flagfile'))
        mountpoint = os.path.join(self.tmpdir, 'mountpoint')
        # mount the whole repository, archive contents shall show up in archivename subdirs of mountpoint:
        with self.fuse_mount(self.repository_location, mountpoint):
>           self.assert_dirs_equal(self.input_path, os.path.join(mountpoint, 'archive', 'input'))

.tox/py34/lib/python3.4/site-packages/borg/testsuite/archiver.py:1383: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py34/lib/python3.4/site-packages/borg/testsuite/__init__.py:142: in assert_dirs_equal
    self._assert_dirs_equal_cmp(diff)
.tox/py34/lib/python3.4/site-packages/borg/testsuite/__init__.py:145: in _assert_dirs_equal_cmp
    self.assert_equal(diff.left_only, [])
/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:247: in __getattr__
    self.methodmap[attr](self)
/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:141: in phase1
    a = dict(zip(map(os.path.normcase, self.left_list), self.left_list))
/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:247: in __getattr__
    self.methodmap[attr](self)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <filecmp.dircmp object at 0x103b18400>

    def phase0(self): # Compare everything except common subdirectories
        self.left_list = _filter(os.listdir(self.left),
                                 self.hide+self.ignore)
>       self.right_list = _filter(os.listdir(self.right),
                                  self.hide+self.ignore)
E       PermissionError: [Errno 13] Permission denied: '/var/folders/rm/ywx69srx1kq_dtjz2ynznn000000gp/T/tmpqk8x28_n/mountpoint/archive/input'

/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:135: PermissionError
________________ ArchiverTestCaseBinary.test_fuse_versions_view ________________

self = <borg.testsuite.archiver.ArchiverTestCaseBinary testMethod=test_fuse_versions_view>

    @unittest.skipUnless(has_llfuse, 'llfuse not installed')
    def test_fuse_versions_view(self):
        self.cmd('init', self.repository_location)
        self.create_regular_file('test', contents=b'first')
        self.cmd('create', self.repository_location + '::archive1', 'input')
        self.create_regular_file('test', contents=b'second')
        self.cmd('create', self.repository_location + '::archive2', 'input')
        mountpoint = os.path.join(self.tmpdir, 'mountpoint')
        # mount the whole repository, archive contents shall show up in versioned view:
        with self.fuse_mount(self.repository_location, mountpoint, 'versions'):
            path = os.path.join(mountpoint, 'input', 'test')  # filename shows up as directory ...
>           files = os.listdir(path)
E           PermissionError: [Errno 13] Permission denied: '/var/folders/rm/ywx69srx1kq_dtjz2ynznn000000gp/T/tmpyg2mi4y8/mountpoint/input/test'

.tox/py34/lib/python3.4/site-packages/borg/testsuite/archiver.py:1455: PermissionError
_______________________ RemoteArchiverTestCase.test_fuse _______________________

self = <borg.testsuite.archiver.RemoteArchiverTestCase testMethod=test_fuse>

    @unittest.skipUnless(has_llfuse, 'llfuse not installed')
    def test_fuse(self):
        def has_noatime(some_file):
            atime_before = os.stat(some_file).st_atime_ns
            try:
                os.close(os.open(some_file, flags_noatime))
            except PermissionError:
                return False
            else:
                atime_after = os.stat(some_file).st_atime_ns
                noatime_used = flags_noatime != flags_normal
                return noatime_used and atime_before == atime_after

        self.cmd('init', self.repository_location)
        self.create_test_files()
        have_noatime = has_noatime('input/file1')
        self.cmd('create', self.repository_location + '::archive', 'input')
        self.cmd('create', self.repository_location + '::archive2', 'input')
        if has_lchflags:
            # remove the file we did not backup, so input and output become equal
            os.remove(os.path.join('input', 'flagfile'))
        mountpoint = os.path.join(self.tmpdir, 'mountpoint')
        # mount the whole repository, archive contents shall show up in archivename subdirs of mountpoint:
        with self.fuse_mount(self.repository_location, mountpoint):
>           self.assert_dirs_equal(self.input_path, os.path.join(mountpoint, 'archive', 'input'))

.tox/py34/lib/python3.4/site-packages/borg/testsuite/archiver.py:1383: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/py34/lib/python3.4/site-packages/borg/testsuite/__init__.py:142: in assert_dirs_equal
    self._assert_dirs_equal_cmp(diff)
.tox/py34/lib/python3.4/site-packages/borg/testsuite/__init__.py:145: in _assert_dirs_equal_cmp
    self.assert_equal(diff.left_only, [])
/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:247: in __getattr__
    self.methodmap[attr](self)
/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:141: in phase1
    a = dict(zip(map(os.path.normcase, self.left_list), self.left_list))
/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:247: in __getattr__
    self.methodmap[attr](self)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <filecmp.dircmp object at 0x103060128>

    def phase0(self): # Compare everything except common subdirectories
        self.left_list = _filter(os.listdir(self.left),
                                 self.hide+self.ignore)
>       self.right_list = _filter(os.listdir(self.right),
                                  self.hide+self.ignore)
E       PermissionError: [Errno 13] Permission denied: '/var/folders/rm/ywx69srx1kq_dtjz2ynznn000000gp/T/tmpx45wbui_/mountpoint/archive/input'

/Users/vagrant/.pyenv/versions/3.4.0/Python.framework/Versions/3.4/lib/python3.4/filecmp.py:135: PermissionError
________________ RemoteArchiverTestCase.test_fuse_versions_view ________________

self = <borg.testsuite.archiver.RemoteArchiverTestCase testMethod=test_fuse_versions_view>

    @unittest.skipUnless(has_llfuse, 'llfuse not installed')
    def test_fuse_versions_view(self):
        self.cmd('init', self.repository_location)
        self.create_regular_file('test', contents=b'first')
        self.cmd('create', self.repository_location + '::archive1', 'input')
        self.create_regular_file('test', contents=b'second')
        self.cmd('create', self.repository_location + '::archive2', 'input')
        mountpoint = os.path.join(self.tmpdir, 'mountpoint')
        # mount the whole repository, archive contents shall show up in versioned view:
        with self.fuse_mount(self.repository_location, mountpoint, 'versions'):
            path = os.path.join(mountpoint, 'input', 'test')  # filename shows up as directory ...
>           files = os.listdir(path)
E           PermissionError: [Errno 13] Permission denied: '/var/folders/rm/ywx69srx1kq_dtjz2ynznn000000gp/T/tmpn33finds/mountpoint/input/test'

.tox/py34/lib/python3.4/site-packages/borg/testsuite/archiver.py:1455: PermissionError
============================ pytest-warning summary ============================
WC1 None [pytest] section in setup.cfg files is deprecated, use [tool:pytest] instead.
 6 failed, 719 passed, 116 skipped, 3 xpassed, 1 pytest-warnings in 1579.68 seconds 
ERROR: InvocationError: '/vagrant/borg/borg/.tox/py34/bin/py.test -rs --cov=borg --cov-config=.coveragerc --benchmark-skip --pyargs borg.testsuite'
```

The fuse tests work without fakeroot:

```
(borg-env) This-MacBook-Pro:borg vagrant$ py.test -k fuse
============================= test session starts ==============================
platform darwin -- Python 3.5.2, pytest-3.0.1, py-1.4.31, pluggy-0.3.1
benchmark: 3.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=5.00us max_time=1.00s calibration_precision=10 warmup=False warmup_iterations=100000)
Tests enabled: fuse, hardlinks, root, atime/mtime, modes, symlinks, BSD flags
Tests disabled: 
rootdir: /vagrant/borg/borg, inifile: setup.cfg
plugins: benchmark-3.0.0, cov-2.3.1
collected 844 items 

src/borg/testsuite/archiver.py ............

============================= 832 tests deselected =============================
======== 12 passed, 832 deselected, 1 pytest-warnings in 52.28 seconds =========

```



Discussion:

Resolving patch:
diff --git a/borg/testsuite/archiver.py b/borg/testsuite/archiver.py
--- a/borg/testsuite/archiver.py
+++ b/borg/testsuite/archiver.py
@@ -211,6 +211,7 @@ def setUp(self):
         os.environ['BORG_KEYS_DIR'] = self.keys_path
         os.environ['BORG_CACHE_DIR'] = self.cache_path
         os.mkdir(self.input_path)
+        os.chmod(self.input_path, 0o777)  # avoid troubles with fakeroot / FUSE
         os.mkdir(self.output_path)
         os.mkdir(self.keys_path)
         os.mkdir(self.cache_path)


Test patch: