diff options
author | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-01 08:13:05 +0000 |
---|---|---|
committer | bescoto <bescoto@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109> | 2003-02-01 08:13:05 +0000 |
commit | 64976e6afefff455ee9515218942a65c6ff5eede (patch) | |
tree | cbe6d3965de77e0ebf6159eec15f24730cc5bf60 /rdiff-backup/testing | |
parent | a5207ada368bf6a9eb31e8c094124dbf2cc1175e (diff) | |
download | rdiff-backup-64976e6afefff455ee9515218942a65c6ff5eede.tar.gz |
Re-added --windows-mode option
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@273 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r-- | rdiff-backup/testing/FilenameMappingtest.py | 31 | ||||
-rw-r--r-- | rdiff-backup/testing/commontest.py | 2 | ||||
-rw-r--r-- | rdiff-backup/testing/finaltest.py | 53 |
3 files changed, 64 insertions, 22 deletions
diff --git a/rdiff-backup/testing/FilenameMappingtest.py b/rdiff-backup/testing/FilenameMappingtest.py new file mode 100644 index 0000000..66ab786 --- /dev/null +++ b/rdiff-backup/testing/FilenameMappingtest.py @@ -0,0 +1,31 @@ +import unittest +from commontest import * +from rdiff_backup import FilenameMapping + +class FilenameMappingTest(unittest.TestCase): + """Test the FilenameMapping class, for quoting filenames""" + def setUp(self): + """Just initialize quoting - assume windows mode""" + FilenameMapping.set_init_quote_vals() + + def testBasicQuote(self): + """Test basic quoting and unquoting""" + filenames = ["hello", "HeLLo", "EUOeu/EUOeu", ":", "::::EU", "/:/:"] + for filename in filenames: + quoted = FilenameMapping.quote(filename) + assert FilenameMapping.unquote(quoted) == filename, filename + + def testQuotedRPath(self): + """Test the QuotedRPath class""" + + def testQuotedSepBase(self): + """Test get_quoted_sep_base function""" + path = ("/usr/local/mirror_metadata" + ".1969-12-31;08421;05833;05820-07;05800.data.gz") + qrp = FilenameMapping.get_quoted_sep_base(path) + assert qrp.base == "/usr/local", qrp.base + assert len(qrp.index) == 1, qrp.index + assert (qrp.index[0] == + "mirror_metadata.1969-12-31T21:33:20-07:00.data.gz") + +if __name__ == "__main__": unittest.main() diff --git a/rdiff-backup/testing/commontest.py b/rdiff-backup/testing/commontest.py index dae825a..1e6fa82 100644 --- a/rdiff-backup/testing/commontest.py +++ b/rdiff-backup/testing/commontest.py @@ -5,7 +5,7 @@ from rdiff_backup.rpath import RPath from rdiff_backup import Globals, Hardlink, SetConnections, Main, \ selection, lazy, Time, rpath -SourceDir = "../src" +SourceDir = "../rdiff_backup" AbsCurdir = os.getcwd() # Absolute path name of current directory AbsTFdir = AbsCurdir+"/testfiles" MiscDir = "../misc" diff --git a/rdiff-backup/testing/finaltest.py b/rdiff-backup/testing/finaltest.py index ae48462..60bc072 100644 --- a/rdiff-backup/testing/finaltest.py +++ b/rdiff-backup/testing/finaltest.py @@ -1,6 +1,6 @@ import unittest, os, re, sys, time from commontest import * -from rdiff_backup import Globals, log, rpath, robust +from rdiff_backup import Globals, log, rpath, robust, FilenameMapping """Regression tests""" @@ -43,7 +43,7 @@ class PathSetter(unittest.TestCase): def reset_schema(self): self.rb_schema = SourceDir + \ - "/../rdiff-backup -v7 --remote-schema './chdir-wrapper2 %s' " + "/../rdiff-backup -v5 --remote-schema './chdir-wrapper2 %s' " def refresh(self, *rp_list): """Reread data for the given rps""" @@ -60,20 +60,21 @@ class PathSetter(unittest.TestCase): def exec_rb(self, time, *args): """Run rdiff-backup on given arguments""" arglist = [] - if time: arglist.append("--current-time %s" % str(time)) + if time: arglist.extend(["--current-time", str(time)]) arglist.append(self.src_prefix + args[0]) if len(args) > 1: arglist.append(self.dest_prefix + args[1]) assert len(args) == 2 - cmdstr = self.rb_schema + ' '.join(arglist) + argstring = ' '.join(map(lambda s: "'%s'" % (s,), arglist)) + cmdstr = self.rb_schema + argstring print "executing " + cmdstr assert not os.system(cmdstr) def exec_rb_extra_args(self, time, extra_args, *args): """Run rdiff-backup on given arguments""" arglist = [] - if time: arglist.append("--current-time %s" % str(time)) + if time: arglist.extend(["--current-time", str(time)]) arglist.append(self.src_prefix + args[0]) if len(args) > 1: arglist.append(self.dest_prefix + args[1]) @@ -166,14 +167,19 @@ class PathSetter(unittest.TestCase): "testfiles/output/rdiff-backup-data/increments/nochange")) assert nochange_incs == 1 or nochange_incs == 0, nochange_incs - def getinc_paths(self, basename, directory): + def getinc_paths(self, basename, directory, quoted = 0): """Return increment.______.dir paths""" - dirrp = rpath.RPath(Globals.local_connection, directory) - incfiles = [filename for filename in robust.listrp(dirrp) - if filename.startswith(basename)] - incfiles.sort() - incrps = map(lambda f: rpath.RPath(lc, directory+"/"+f), incfiles) - return map(lambda x: x.path, filter(rpath.RPath.isincfile, incrps)) + if quoted: + FilenameMapping.set_init_quote_vals() + dirrp = FilenameMapping.QuotedRPath(Globals.local_connection, + directory) + else: dirrp = rpath.RPath(Globals.local_connection, directory) + incbasenames = [filename for filename in robust.listrp(dirrp) + if filename.startswith(basename)] + incbasenames.sort() + incrps = map(dirrp.append, incbasenames) + return map(lambda x: x.path, + filter(lambda incrp: incrp.isincfile(), incrps)) class Final(PathSetter): @@ -204,7 +210,7 @@ class Final(PathSetter): self.exec_rb(None, '../../../../../../proc', 'testfiles/procoutput') def testProcRemote(self): - """Test mirroring proc""" + """Test mirroring proc remote""" Myrm("testfiles/procoutput") self.set_connections(None, None, "test2/tmp/", "../../") self.exec_rb(None, '../../../../../../proc', 'testfiles/procoutput') @@ -226,12 +232,13 @@ class Final(PathSetter): Globals.time_separator = "_" inc_paths = self.getinc_paths("increments.", - "testfiles/output/rdiff-backup-data") + "testfiles/output/rdiff-backup-data", 1) Globals.time_separator = ":" - assert len(inc_paths) == 1 + assert len(inc_paths) == 1, inc_paths # Restore increment2 self.exec_rb(None, inc_paths[0], 'testfiles/restoretarget2') - assert CompareRecursive(Local.inc2rp, Local.rpout2) + assert CompareRecursive(Local.inc2rp, Local.rpout2, + compare_hardlinks = 0) # Now check to make sure no ":" in output directory popen_fp = os.popen("find testfiles/output -name '*:*' | wc") @@ -242,6 +249,10 @@ class Final(PathSetter): class FinalSelection(PathSetter): """Test selection options""" + def run(cmd): + print "Executing: ", cmd + assert not os.system(cmd) + def testSelLocal(self): """Quick backup testing a few selection options""" self.delete_tmpdirs() @@ -277,11 +288,11 @@ testfiles/increment2/changed_dir""") # Test selective restoring mirror_rp = rpath.RPath(Globals.local_connection, "testfiles/output") restore_filename = get_increment_rp(mirror_rp, 10000).path - assert not os.system(self.rb_schema + - "--include testfiles/restoretarget1/various_file_types/" - "regular_file " - "--exclude '**' " + - restore_filename + " testfiles/restoretarget1") + self.run(self.rb_schema + + "--include testfiles/restoretarget1/various_file_types/" + "regular_file " + "--exclude '**' " + + restore_filename + " testfiles/restoretarget1") assert os.lstat("testfiles/restoretarget1/various_file_types/" "regular_file") self.assertRaises(OSError, os.lstat, "testfiles/restoretarget1/tester") |