浏览代码

tests: ignore st_rdev if file is not a block/char device, fixes #203

Thomas Waldmann 9 年之前
父节点
当前提交
48634d4e96
共有 1 个文件被更改,包括 6 次插入0 次删除
  1. 6 0
      borg/testsuite/__init__.py

+ 6 - 0
borg/testsuite/__init__.py

@@ -2,6 +2,7 @@ from contextlib import contextmanager
 import filecmp
 import filecmp
 import os
 import os
 import posix
 import posix
+import stat
 import sys
 import sys
 import sysconfig
 import sysconfig
 import time
 import time
@@ -72,6 +73,11 @@ class BaseTestCase(unittest.TestCase):
                 attrs.append('st_nlink')
                 attrs.append('st_nlink')
             d1 = [filename] + [getattr(s1, a) for a in attrs]
             d1 = [filename] + [getattr(s1, a) for a in attrs]
             d2 = [filename] + [getattr(s2, a) for a in attrs]
             d2 = [filename] + [getattr(s2, a) for a in attrs]
+            # ignore st_rdev if file is not a block/char device, fixes #203
+            if not stat.S_ISCHR(d1[1]) and not stat.S_ISBLK(d1[1]):
+                d1[4] = None
+            if not stat.S_ISCHR(d2[1]) and not stat.S_ISBLK(d2[1]):
+                d2[4] = None
             if not os.path.islink(path1) or utime_supports_fd:
             if not os.path.islink(path1) or utime_supports_fd:
                 # Older versions of llfuse do not support ns precision properly
                 # Older versions of llfuse do not support ns precision properly
                 if fuse and not have_fuse_mtime_ns:
                 if fuse and not have_fuse_mtime_ns: