summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing
diff options
context:
space:
mode:
authorbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2005-10-20 19:34:51 +0000
committerbescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2005-10-20 19:34:51 +0000
commit11ec1472b7b88996c8da45a1d737e2e59e554de0 (patch)
treeef605fcb8246034a50331459db4fce7951c10d5e /rdiff-backup/testing
parent83336648d07d3f8f2ca25377468faeeba77bfd6f (diff)
downloadrdiff-backup-11ec1472b7b88996c8da45a1d737e2e59e554de0.tar.gz
Try read/write fsync for cygwin, also add --preserve-numerical-ids
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@638 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r--rdiff-backup/testing/roottest.py38
-rw-r--r--rdiff-backup/testing/user_grouptest.py39
2 files changed, 65 insertions, 12 deletions
diff --git a/rdiff-backup/testing/roottest.py b/rdiff-backup/testing/roottest.py
index 4950993..d41d9d7 100644
--- a/rdiff-backup/testing/roottest.py
+++ b/rdiff-backup/testing/roottest.py
@@ -109,7 +109,43 @@ class RootTest(unittest.TestCase):
extra_options = ("--user-mapping-file %s "
"--group-mapping-file %s" %
(user_map, group_map)))
- assert get_ownership(out_rp) == ((userid, 1), (0, 1)), \
+ assert get_ownership(out_rp) == ((userid, 0), (0, 1)), \
+ get_ownership(out_rp)
+
+ def test_numerical_mapping(self):
+ """Test --preserve-numerical-ids option
+
+ This doesn't really test much, since we don't have a
+ convenient system with different uname/ids.
+
+ """
+ def write_ownership_dir():
+ """Write the directory testfiles/root_mapping"""
+ rp = rpath.RPath(Globals.local_connection,
+ "testfiles/root_mapping")
+ re_init_dir(rp)
+ rp1 = rp.append('1')
+ rp1.touch()
+ rp2 = rp.append('2')
+ rp2.touch()
+ rp2.chown(userid, 1) # use groupid 1, usually bin
+ return rp
+
+ def get_ownership(dir_rp):
+ """Return pair (ids of dir_rp/1, ids of dir_rp2) of ids"""
+ rp1, rp2 = map(dir_rp.append, ('1', '2'))
+ assert rp1.isreg() and rp2.isreg(), (rp1.isreg(), rp2.isreg())
+ return (rp1.getuidgid(), rp2.getuidgid())
+
+ in_rp = write_ownership_dir()
+ out_rp = rpath.RPath(Globals.local_connection, 'testfiles/output')
+ if out_rp.lstat(): Myrm(out_rp.path)
+
+ assert get_ownership(in_rp) == ((0,0), (userid, 1)), \
+ get_ownership(in_rp)
+ rdiff_backup(1, 0, in_rp.path, out_rp.path,
+ extra_options = ("--preserve-numerical-ids"))
+ assert get_ownership(out_rp) == ((0,0), (userid, 1)), \
get_ownership(in_rp)
diff --git a/rdiff-backup/testing/user_grouptest.py b/rdiff-backup/testing/user_grouptest.py
index 73c8bcf..9321c53 100644
--- a/rdiff-backup/testing/user_grouptest.py
+++ b/rdiff-backup/testing/user_grouptest.py
@@ -12,6 +12,19 @@ class UserGroupTest(unittest.TestCase):
assert user_group.uid2uname(0) == "root"
assert user_group.gid2gname(0) == "root"
assert user_group.gid2gname(0) == "root"
+ # Assume no user has uid 29378
+ assert user_group.gid2gname(29378) is None
+ assert user_group.gid2gname(29378) is None
+
+ def test_basic_reverse(self):
+ """Test basic name2id. Depends on systems users/groups"""
+ user_group.uname2uid_dict = {}; user_group.gname2gid_dict = {}
+ assert user_group.uname2uid("root") == 0
+ assert user_group.uname2uid("root") == 0
+ assert user_group.gname2gid("root") == 0
+ assert user_group.gname2gid("root") == 0
+ assert user_group.uname2uid("aoeuth3t2ug89") is None
+ assert user_group.uname2uid("aoeuth3t2ug89") is None
def test_default_mapping(self):
"""Test the default user mapping"""
@@ -20,9 +33,10 @@ class UserGroupTest(unittest.TestCase):
binid = pwd.getpwnam('bin')[2]
syncid = pwd.getpwnam('sync')[2]
user_group.init_user_mapping()
- assert user_group.UserMap.get_id(0) == 0
- assert user_group.UserMap.get_id(0, 'bin') == binid
- assert user_group.UserMap.get_id(binid, 'sync') == syncid
+ assert user_group.UserMap(0) == 0
+ assert user_group.UserMap(0, 'bin') == binid
+ assert user_group.UserMap(0, 'sync') == syncid
+ assert user_group.UserMap.map_acl(0, 'aoeuth3t2ug89') is None
def test_user_mapping(self):
"""Test the user mapping file through the DefinedMap class"""
@@ -39,15 +53,18 @@ sync:0"""
daemonid = pwd.getpwnam('daemon')[2]
user_group.init_user_mapping(mapping_string)
- assert user_group.UserMap.get_id(rootid, 'root') == binid
- assert user_group.UserMap.get_id(binid, 'bin') == rootid
- assert user_group.UserMap.get_id(0) == syncid
- assert user_group.UserMap.get_id(syncid, 'sync') == 0
- assert user_group.UserMap.get_id(500) == 501
+ assert user_group.UserMap(rootid, 'root') == binid
+ assert user_group.UserMap(binid, 'bin') == rootid
+ assert user_group.UserMap(0) == syncid
+ assert user_group.UserMap(syncid, 'sync') == 0
+ assert user_group.UserMap(500) == 501
+
+ assert user_group.UserMap(501) == 501
+ assert user_group.UserMap(123, 'daemon') == daemonid
+
+ assert user_group.UserMap.map_acl(29378, 'aoeuth3t2ug89') is None
+ assert user_group.UserMap.map_acl(0, 'aoeuth3t2ug89') is syncid
- assert user_group.UserMap.get_id(501) == 501
- assert user_group.UserMap.get_id(123, 'daemon') == daemonid
-
if 0: code.InteractiveConsole(globals()).interact()
def test_overflow(self):