summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-07-18 21:31:14 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2003-07-18 21:31:14 +0000
commit3f6645f4282082c2e140b52780a9a500c8212f82 (patch)
treed19611f85b77d4775ed860c0db9850d7d78f0743 /rdiff-backup/testing
parente9a90e94befd8aaf5185be59d13d946d8b121936 (diff)
downloadrdiff-backup-3f6645f4282082c2e140b52780a9a500c8212f82.tar.gz
Added Daniel Hazelbaker's resource fork code, plus detection to fs_abilities and a new unittest file.
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@345 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r--rdiff-backup/testing/fs_abilitiestest.py6
-rw-r--r--rdiff-backup/testing/resourceforktest.py53
2 files changed, 58 insertions, 1 deletions
diff --git a/rdiff-backup/testing/fs_abilitiestest.py b/rdiff-backup/testing/fs_abilitiestest.py
index c16ab46..cdbe75e 100644
--- a/rdiff-backup/testing/fs_abilitiestest.py
+++ b/rdiff-backup/testing/fs_abilitiestest.py
@@ -18,6 +18,7 @@ class FSAbilitiesTest(unittest.TestCase):
ownership = (os.getuid() == 0)
hardlinks = fsync_dirs = 1
dir_inc_perms = 1
+ resource_forks = 0
# Describes MS-Windows style file system
#dir_to_test = "/mnt/fat"
@@ -25,7 +26,8 @@ class FSAbilitiesTest(unittest.TestCase):
#chars_to_quote = "^a-z0-9_ -"
#ownership = hardlinks = 0
#fsync_dirs = 1
- #dir_inc_perms = XXX
+ #dir_inc_perms = 0
+ #resource_forks = 0
def testReadOnly(self):
"""Test basic querying read only"""
@@ -35,6 +37,7 @@ class FSAbilitiesTest(unittest.TestCase):
assert fsa.read_only == 1, fsa.read_only
assert fsa.eas == self.eas, fsa.eas
assert fsa.acls == self.acls, fsa.acls
+ assert fsa.resource_forks == self.resource_forks, fsa.resource_forks
def testReadWrite(self):
"""Test basic querying read/write"""
@@ -55,6 +58,7 @@ class FSAbilitiesTest(unittest.TestCase):
assert fsa.hardlinks == self.hardlinks, fsa.hardlinks
assert fsa.fsync_dirs == self.fsync_dirs, fsa.fsync_dirs
assert fsa.dir_inc_perms == self.dir_inc_perms, fsa.dir_inc_perms
+ assert fsa.resource_forks == self.resource_forks, fsa.resource_forks
ctq_rp = new_dir.append("chars_to_quote")
assert ctq_rp.lstat()
diff --git a/rdiff-backup/testing/resourceforktest.py b/rdiff-backup/testing/resourceforktest.py
new file mode 100644
index 0000000..09cc1d0
--- /dev/null
+++ b/rdiff-backup/testing/resourceforktest.py
@@ -0,0 +1,53 @@
+import unittest
+from commontest import *
+from rdiff_backup import rpath
+from rdiff_backup import metadata
+
+"""***NOTE***
+
+None of these tests should work unless your system supports resource
+forks. So basically these tests should only be run on Mac OS X.
+
+"""
+
+Globals.read_resource_forks = Globals.write_resource_forks = 1
+
+class ResourceForkTest(unittest.TestCase):
+ """Test dealing with Mac OS X style resource forks"""
+ tempdir = rpath.RPath(Globals.local_connection,
+ 'testfiles/resource_fork_test')
+ def make_temp(self):
+ """Make temp directory testfiles/resource_fork_test"""
+ if self.tempdir.lstat(): self.tempdir.delete()
+ self.tempdir.mkdir()
+
+ def testBasic(self):
+ """Test basic reading and writing of resource forks"""
+ self.make_temp()
+ rp = self.tempdir.append('test')
+ rp.touch()
+ assert rp.get_resource_fork() == '', rp.get_resource_fork()
+
+ s = 'new resource fork data'
+ rp.write_resource_fork(s)
+ assert rp.get_resource_fork() == s, rp.get_resource_fork()
+
+ rp2 = self.tempdir.append('test')
+ assert rp2.isreg()
+ assert rp2.get_resource_fork() == s, rp2.get_resource_fork()
+
+ def testRecord(self):
+ """Test reading, writing, and comparing of records with rforks"""
+ self.make_temp()
+ rp = self.tempdir.append('test')
+ rp.touch()
+ rp.set_resource_fork('hello')
+
+ record = metadata.RORP2Record(rp)
+ #print record
+ rorp_out = metadata.Record2RORP(record)
+ assert rorp_out == rp, (rorp_out, rp)
+ assert rorp_out.get_resource_fork() == 'hello'
+
+
+if __name__ == "__main__": unittest.main()