diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-25 08:18:43 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-25 08:18:43 +0000 |
commit | 3f23be3b6e8f61de2ef2d8408c474e22df8cfeb9 (patch) | |
tree | 103076fa7e3c0e636b3ca77f6a58fb5a7664801e /rdiff-backup/testing/roottest.py | |
parent | 39f64abf52669a32d2d58a7a056b89e6aa5feae7 (diff) | |
download | rdiff-backup-3f23be3b6e8f61de2ef2d8408c474e22df8cfeb9.tar.gz |
More changes in preparation for 0.11.2
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@284 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing/roottest.py')
-rw-r--r-- | rdiff-backup/testing/roottest.py | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/rdiff-backup/testing/roottest.py b/rdiff-backup/testing/roottest.py index 81292b2..6193893 100644 --- a/rdiff-backup/testing/roottest.py +++ b/rdiff-backup/testing/roottest.py @@ -10,7 +10,7 @@ that are meant to be run as root. Globals.set('change_source_perms', None) Globals.counter = 0 -log.Log.setverbosity(4) +log.Log.setverbosity(6) def Run(cmd): print "Running: ", cmd @@ -33,9 +33,9 @@ class NonRoot(unittest.TestCase): """ user = 'ben' - def make_root_dir(self): + def make_root_dirs(self): """Make directory createable only by root""" - rp = rpath.RPath(Globals.local_connection, "testfiles/root_out") + rp = rpath.RPath(Globals.local_connection, "testfiles/root_out1") if rp.lstat(): Myrm(rp.path) rp.mkdir() rp1 = rp.append("1") @@ -48,39 +48,59 @@ class NonRoot(unittest.TestCase): rp3.chown(2, 2) rp4 = rp.append("dev") rp4.makedev('c', 4, 28) - return rp + + sp = rpath.RPath(Globals.local_connection, "testfiles/root_out2") + if sp.lstat(): Myrm(sp.path) + Run("cp -a %s %s" % (rp.path, sp.path)) + rp2 = sp.append("2") + rp2.chown(2, 2) + rp3 = sp.append("3") + rp3.chown(1, 1) + assert not CompareRecursive(rp, sp, compare_ownership = 1) + + return rp, sp + + def backup(self, input_rp, output_rp, time): + backup_cmd = ("rdiff-backup --no-compare-inode " + "--current-time %s %s %s" % + (time, input_rp.path, output_rp.path)) + Run("su %s -c '%s'" % (self.user, backup_cmd)) + + def restore(self, dest_rp, restore_rp, time = None): + assert restore_rp.path == "testfiles/rest_out" + Myrm(restore_rp.path) + if time is None: time = "now" + restore_cmd = "rdiff-backup -r %s %s %s" % (time, dest_rp.path, + restore_rp.path,) + Run(restore_cmd) def test_non_root(self): """Main non-root -> root test""" Myrm("testfiles/output") - input_rp = self.make_root_dir() + input_rp1, input_rp2 = self.make_root_dirs() Globals.change_ownership = 1 output_rp = rpath.RPath(Globals.local_connection, "testfiles/output") restore_rp = rpath.RPath(Globals.local_connection, "testfiles/rest_out") empty_rp = rpath.RPath(Globals.local_connection, "testfiles/empty") - backup_cmd = "rdiff-backup %s %s" % (input_rp.path, output_rp.path) - Run("su %s -c '%s'" % (self.user, backup_cmd)) + self.backup(input_rp1, output_rp, 1000000) + self.restore(output_rp, restore_rp) + assert CompareRecursive(input_rp1, restore_rp, compare_ownership = 1) - Myrm("testfiles/rest_out") - restore_cmd = "rdiff-backup -r now %s %s" % (output_rp.path, - restore_rp.path,) - Run(restore_cmd) - assert CompareRecursive(input_rp, restore_rp) + self.backup(input_rp2, output_rp, 2000000) + self.restore(output_rp, restore_rp) + assert CompareRecursive(input_rp2, restore_rp, compare_ownership = 1) - backup_cmd = "rdiff-backup %s %s" % (empty_rp.path, output_rp.path) - Run("su %s -c '%s'" % (self.user, backup_cmd)) + self.backup(empty_rp, output_rp, 3000000) + self.restore(output_rp, restore_rp) + assert CompareRecursive(empty_rp, restore_rp, compare_ownership = 1) + + self.restore(output_rp, restore_rp, 1000000) + assert CompareRecursive(input_rp1, restore_rp, compare_ownership = 1) - Myrm("testfiles/rest_out") - Run(restore_cmd) - assert CompareRecursive(empty_rp, restore_rp) + self.restore(output_rp, restore_rp, 2000000) + assert CompareRecursive(input_rp2, restore_rp, compare_ownership = 1) - Myrm("testfiles/rest_out") - restore_cmd = "rdiff-backup -r 1 %s %s" % (output_rp.path, - restore_rp.path,) - Run(restore_cmd) - assert CompareRecursive(input_rp, restore_rp) - if __name__ == "__main__": unittest.main() |