summaryrefslogtreecommitdiff
path: root/rdiff-backup/testing
diff options
context:
space:
mode:
authorben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-03-21 07:34:29 +0000
committerben <ben@2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109>2002-03-21 07:34:29 +0000
commita2e3c38d72877dd9142d802e76047e10cf490e19 (patch)
treefd912dd37d0afe96adf760606d65f7b302c0678e /rdiff-backup/testing
parent8c37a5bdfdd46d5cfad6e9d67925ddef9ca382bf (diff)
downloadrdiff-backup-a2e3c38d72877dd9142d802e76047e10cf490e19.tar.gz
Added hardlink support, refactored some test cases
git-svn-id: http://svn.savannah.nongnu.org/svn/rdiff-backup/trunk@7 2b77aa54-bcbc-44c9-a7ec-4f6cf2b41109
Diffstat (limited to 'rdiff-backup/testing')
-rw-r--r--rdiff-backup/testing/commontest.py231
-rw-r--r--rdiff-backup/testing/finaltest.py16
-rw-r--r--rdiff-backup/testing/highleveltest.py55
-rw-r--r--rdiff-backup/testing/regressiontest.py59
-rw-r--r--rdiff-backup/testing/roottest.py4
-rw-r--r--rdiff-backup/testing/rorpitertest.py36
-rwxr-xr-xrdiff-backup/testing/server.py32
7 files changed, 321 insertions, 112 deletions
diff --git a/rdiff-backup/testing/commontest.py b/rdiff-backup/testing/commontest.py
index 5cd66d7..ac6f109 100644
--- a/rdiff-backup/testing/commontest.py
+++ b/rdiff-backup/testing/commontest.py
@@ -1,10 +1,11 @@
-"""commontest - Some functions and constants common to all test cases"""
+"""commontest - Some functions and constants common to several test cases"""
import os
SourceDir = "../src"
AbsCurdir = os.getcwd() # Absolute path name of current directory
AbsTFdir = AbsCurdir+"/testfiles"
MiscDir = "../misc"
+__no_execute__ = 1 # Keeps the actual rdiff-backup program from running
def rbexec(src_file):
"""Changes to the source directory, execfile src_file, return"""
@@ -17,3 +18,231 @@ def Make():
os.chdir(SourceDir)
os.system("python ./Make")
os.chdir(AbsCurdir)
+
+def rdiff_backup(source_local, dest_local, src_dir, dest_dir,
+ current_time = None, extra_options = ""):
+ """Run rdiff-backup with the given options
+
+ source_local and dest_local are boolean values. If either is
+ false, then rdiff-backup will be run pretending that src_dir and
+ dest_dir, respectively, are remote. The server process will be
+ run in directories test1 and test2/tmp respectively.
+
+ src_dir and dest_dir are the source and destination
+ (mirror) directories, relative to the testing directory.
+
+ If current time is true, add the --current-time option with the
+ given number of seconds.
+
+ extra_options are just added to the command line.
+
+ """
+ if not source_local:
+ src_dir = ("cd test1; ../%s/rdiff-backup --server::../%s" %
+ (SourceDir, src_dir))
+ if not dest_local:
+ dest_dir = ("test2/tmp; ../../%s/rdiff-backup --server::../../%s" %
+ (SourceDir, dest_dir))
+
+ cmdargs = [SourceDir + "/rdiff-backup", extra_options]
+ if not (source_local and dest_local): cmdargs.append("--remote-schema %s")
+
+ if current_time: cmdargs.append("--current-time %s" % current_time)
+
+ os.system(" ".join(cmdargs))
+
+def InternalBackup(source_local, dest_local, src_dir, dest_dir,
+ current_time = None):
+ """Backup src to dest internally
+
+ This is like rdiff_backup but instead of running a separate
+ rdiff-backup script, use the separate *.py files. This way the
+ script doesn't have to be rebuild constantly, and stacktraces have
+ correct line/file references.
+
+ """
+ Globals.current_time = current_time
+ #_reset_connections()
+ remote_schema = '%s'
+
+ if not source_local:
+ src_dir = "cd test1; python ../server.py ../%s::../%s" % \
+ (SourceDir, src_dir)
+ if not dest_local:
+ dest_dir = "cd test2/tmp; python ../../server.py ../../%s::../../%s" \
+ % (SourceDir, dest_dir)
+
+ rpin, rpout = SetConnections.InitRPs([src_dir, dest_dir], remote_schema)
+ _get_main().Backup(rpin, rpout)
+ _get_main().cleanup()
+
+def InternalMirror(source_local, dest_local, src_dir, dest_dir,
+ checkpointing = None):
+ """Mirror src to dest internally, like InternalBackup"""
+ remote_schema = '%s'
+
+ if not source_local:
+ src_dir = "cd test1; python ../server.py ../%s::../%s" % \
+ (SourceDir, src_dir)
+ if not dest_local:
+ dest_dir = "cd test2/tmp; python ../../server.py ../../%s::../../%s" \
+ % (SourceDir, dest_dir)
+
+ rpin, rpout = SetConnections.InitRPs([src_dir, dest_dir], remote_schema)
+ if not rpout.lstat(): rpout.mkdir()
+ if checkpointing: # rdiff-backup-data must exist to checkpoint
+ data_dir = rpout.append("rdiff-backup-data")
+ if not data_dir.lstat(): data_dir.mkdir()
+ Globals.add_regexp(data_dir.path, 1)
+ SetConnections.UpdateGlobal('rbdir', data_dir)
+ HighLevel.Mirror(rpin, rpout, checkpointing)
+ _get_main().cleanup()
+
+def InternalRestore(mirror_local, dest_local, mirror_dir, dest_dir, time):
+ """Restore mirror_dir to dest_dir at given time
+
+ This will automatically find the increments.XXX.dir representing
+ the time specified. The mirror_dir and dest_dir are relative to
+ the testing directory and will be modified for remote trials.
+
+ """
+ remote_schema = '%s'
+ #_reset_connections()
+ if not mirror_local:
+ mirror_dir = "cd test1; python ../server.py ../%s::../%s" % \
+ (SourceDir, mirror_dir)
+ if not dest_local:
+ dest_dir = "cd test2/tmp; python ../../server.py ../../%s::../../%s" \
+ % (SourceDir, dest_dir)
+
+ mirror_rp, dest_rp = SetConnections.InitRPs([mirror_dir, dest_dir],
+ remote_schema)
+
+ def get_increment_rp(time):
+ """Return increment rp matching time"""
+ data_rp = mirror_rp.append("rdiff-backup-data")
+ for filename in data_rp.listdir():
+ rp = data_rp.append(filename)
+ if (rp.isincfile() and rp.getincbase_str() == "increments" and
+ Time.stringtotime(rp.getinctime()) == time):
+ return rp
+ assert None, ("No increments.XXX.dir found in directory "
+ "%s with that time" % data_rp.path)
+
+ _get_main().Restore(get_increment_rp(time), dest_rp)
+ _get_main().cleanup()
+
+def _reset_connections(src_rp, dest_rp):
+ """Reset some global connection information"""
+ Globals.isbackup_reader = Globals.isbackup_writer = None
+ #Globals.connections = [Globals.local_connection]
+ #Globals.connection_dict = {0: Globals.local_connection}
+ SetConnections.UpdateGlobal('rbdir', None)
+ SetConnections.UpdateGlobal('exclude_regexps', [])
+ SetConnections.UpdateGlobal('exclude_mirror_regexps', [])
+ Globals.add_regexp(dest_rp.append("rdiff-backup-data").path, 1)
+ Globals.add_regexp(src_rp.append("rdiff-backup-data").path, None)
+
+def _get_main():
+ """Set Globals.Main if it doesn't exist, and return"""
+ try: return Globals.Main
+ except AttributeError:
+ Globals.Main = Main()
+ return Globals.Main
+
+def CompareRecursive(src_rp, dest_rp, compare_hardlinks = 1):
+ """Compare src_rp and dest_rp, which can be directories
+
+ This only compares file attributes, not the actual data. This
+ will overwrite the hardlink dictionaries if compare_hardlinks is
+ specified.
+
+ """
+ if compare_hardlinks: reset_hardlink_dicts()
+ src_rp.setdata()
+ dest_rp.setdata()
+
+ Log("Comparing %s and %s, hardlinks %s" % (src_rp.path, dest_rp.path,
+ compare_hardlinks), 3)
+ dsiter1, dsiter2 = map(DestructiveStepping.Iterate_with_Finalizer,
+ [src_rp, dest_rp], [1, None])
+
+ def hardlink_equal(src_rorp, dest_rorp):
+ if src_rorp != dest_rorp: return None
+ if Hardlink.rorp_eq(src_rorp, dest_rorp): return 1
+ Log("%s: %s" % (src_rorp.index, Hardlink.get_indicies(src_rorp, 1)), 3)
+ Log("%s: %s" % (dest_rorp.index,
+ Hardlink.get_indicies(dest_rorp, None)), 3)
+ return None
+
+ if compare_hardlinks:
+ dsiter1 = Hardlink.add_rorp_iter(dsiter1, 1)
+ dsiter2 = Hardlink.add_rorp_iter(dsiter2, None)
+ result = Iter.equal(dsiter1, dsiter2, 1, hardlink_equal)
+ else: result = Iter.equal(dsiter1, dsiter2, 1)
+
+ for i in dsiter1: pass # make sure all files processed anyway
+ for i in dsiter2: pass
+ return result
+
+def reset_hardlink_dicts():
+ """Clear the hardlink dictionaries"""
+ Hardlink._src_inode_indicies = {}
+ Hardlink._src_index_indicies = {}
+ Hardlink._dest_inode_indicies = {}
+ Hardlink._dest_index_indicies = {}
+
+def BackupRestoreSeries(source_local, dest_local, list_of_dirnames,
+ compare_hardlinks = 1,
+ dest_dirname = "testfiles/output",
+ restore_dirname = "testfiles/rest_out"):
+ """Test backing up/restoring of a series of directories
+
+ The dirnames correspond to a single directory at different times.
+ After each backup, the dest dir will be compared. After the whole
+ set, each of the earlier directories will be recovered to the
+ restore_dirname and compared.
+
+ """
+ Globals.set('preserve_hardlinks', compare_hardlinks)
+ time = 10000
+ dest_rp = RPath(Globals.local_connection, dest_dirname)
+ restore_rp = RPath(Globals.local_connection, restore_dirname)
+
+ os.system(MiscDir + "/myrm " + dest_dirname)
+ for dirname in list_of_dirnames:
+ src_rp = RPath(Globals.local_connection, dirname)
+ reset_hardlink_dicts()
+ _reset_connections(src_rp, dest_rp)
+
+ InternalBackup(source_local, dest_local, dirname, dest_dirname, time)
+ time += 10000
+ _reset_connections(src_rp, dest_rp)
+ assert CompareRecursive(src_rp, dest_rp, compare_hardlinks)
+
+ time = 10000
+ for dirname in list_of_dirnames[:-1]:
+ reset_hardlink_dicts()
+ os.system(MiscDir + "/myrm " + restore_dirname)
+ InternalRestore(dest_local, source_local, dest_dirname,
+ restore_dirname, time)
+ src_rp = RPath(Globals.local_connection, dirname)
+ assert CompareRecursive(src_rp, restore_rp)
+ time += 10000
+
+def MirrorTest(source_local, dest_local, list_of_dirnames,
+ compare_hardlinks = 1,
+ dest_dirname = "testfiles/output"):
+ """Mirror each of list_of_dirnames, and compare after each"""
+ Globals.set('preserve_hardlinks', compare_hardlinks)
+ dest_rp = RPath(Globals.local_connection, dest_dirname)
+
+ os.system(MiscDir + "/myrm " + dest_dirname)
+ for dirname in list_of_dirnames:
+ src_rp = RPath(Globals.local_connection, dirname)
+ reset_hardlink_dicts()
+ _reset_connections(src_rp, dest_rp)
+
+ InternalMirror(source_local, dest_local, dirname, dest_dirname)
+ _reset_connections(src_rp, dest_rp)
+ assert CompareRecursive(src_rp, dest_rp, compare_hardlinks)
diff --git a/rdiff-backup/testing/finaltest.py b/rdiff-backup/testing/finaltest.py
index c92a7d1..a5ca5e1 100644
--- a/rdiff-backup/testing/finaltest.py
+++ b/rdiff-backup/testing/finaltest.py
@@ -73,22 +73,22 @@ class PathSetter(unittest.TestCase):
# Backing up increment1
self.exec_rb('testfiles/increment1', 'testfiles/output')
- assert RPathStatic.cmp_recursive(Local.inc1rp, Local.rpout)
+ assert CompareRecursive(Local.inc1rp, Local.rpout)
time.sleep(1)
# Backing up increment2
self.exec_rb('testfiles/increment2', 'testfiles/output')
- assert RPathStatic.cmp_recursive(Local.inc2rp, Local.rpout)
+ assert CompareRecursive(Local.inc2rp, Local.rpout)
time.sleep(1)
# Backing up increment3
self.exec_rb('testfiles/increment3', 'testfiles/output')
- assert RPathStatic.cmp_recursive(Local.inc3rp, Local.rpout)
+ assert CompareRecursive(Local.inc3rp, Local.rpout)
time.sleep(1)
# Backing up increment4
self.exec_rb('testfiles/increment4', 'testfiles/output')
- assert RPathStatic.cmp_recursive(Local.inc4rp, Local.rpout)
+ assert CompareRecursive(Local.inc4rp, Local.rpout)
# Getting restore rps
inc_paths = self.getinc_paths("increments.",
@@ -97,22 +97,22 @@ class PathSetter(unittest.TestCase):
# Restoring increment1
self.exec_rb(inc_paths[0], 'testfiles/restoretarget1')
- assert RPathStatic.cmp_recursive(Local.inc1rp, Local.rpout1)
+ assert CompareRecursive(Local.inc1rp, Local.rpout1)
# Restoring increment2
self.exec_rb(inc_paths[1], 'testfiles/restoretarget2')
- assert RPathStatic.cmp_recursive(Local.inc2rp, Local.rpout2)
+ assert CompareRecursive(Local.inc2rp, Local.rpout2)
# Restoring increment3
self.exec_rb(inc_paths[2], 'testfiles/restoretarget3')
- assert RPathStatic.cmp_recursive(Local.inc3rp, Local.rpout3)
+ assert CompareRecursive(Local.inc3rp, Local.rpout3)
# Test restoration of a few random files
vft_paths = self.getinc_paths("various_file_types.",
"testfiles/output/rdiff-backup-data/increments")
self.exec_rb(vft_paths[1], 'testfiles/vft_out')
self.refresh(Local.vft_in, Local.vft_out)
- assert RPathStatic.cmp_recursive(Local.vft_in, Local.vft_out)
+ assert CompareRecursive(Local.vft_in, Local.vft_out)
timbar_paths = self.getinc_paths("timbar.pyc.",
"testfiles/output/rdiff-backup-data/increments")
diff --git a/rdiff-backup/testing/highleveltest.py b/rdiff-backup/testing/highleveltest.py
index b1e6f8d..3bd10c3 100644
--- a/rdiff-backup/testing/highleveltest.py
+++ b/rdiff-backup/testing/highleveltest.py
@@ -1,7 +1,7 @@
import unittest
execfile("commontest.py")
-rbexec("setconnections.py")
+rbexec("main.py")
class RemoteMirrorTest(unittest.TestCase):
@@ -10,66 +10,27 @@ class RemoteMirrorTest(unittest.TestCase):
"""Start server"""
Log.setverbosity(7)
Globals.change_source_perms = 1
- self.conn = SetConnections.init_connection("./server.py")
-
- self.inrp = RPath(Globals.local_connection, "testfiles/various_file_types")
- self.outrp = RPath(self.conn, "testfiles/output")
- self.rbdir = RPath(self.conn, "testfiles/output/rdiff-backup-data")
- SetConnections.UpdateGlobal('rbdir', self.rbdir)
- self.inc1 = RPath(Globals.local_connection, "testfiles/increment1")
- self.inc2 = RPath(Globals.local_connection, "testfiles/increment2")
- self.inc3 = RPath(Globals.local_connection, "testfiles/increment3")
- self.inc4 = RPath(Globals.local_connection, "testfiles/increment4")
-
- SetConnections.BackupInitConnections(Globals.local_connection,
- self.conn)
SetConnections.UpdateGlobal('checkpoint_interval', 3)
def testMirror(self):
"""Testing simple mirror"""
- if self.outrp.lstat(): self.outrp.delete()
- HighLevel.Mirror(self.inrp, self.outrp, None)
- self.outrp.setdata()
- assert RPath.cmp_recursive(self.inrp, self.outrp)
+ MirrorTest(None, None, ["testfiles/increment1"])
def testMirror2(self):
"""Test mirror with larger data set"""
- if self.outrp.lstat(): self.outrp.delete()
- for rp in [self.inc1, self.inc2, self.inc3, self.inc4]:
- rp.setdata()
- print "----------------- Starting ", rp.path
- HighLevel.Mirror(rp, self.outrp, None)
- #if rp is self.inc2: assert 0
- assert RPath.cmp_recursive(rp, self.outrp)
- self.outrp.setdata()
+ MirrorTest(1, None, ['testfiles/increment1', 'testfiles/increment2',
+ 'testfiles/increment3', 'testfiles/increment4'])
def testMirrorWithCheckpointing(self):
"""Like testMirror but this time checkpoint"""
- if self.outrp.lstat(): self.outrp.delete()
- self.outrp.mkdir()
- self.rbdir.mkdir()
- Globals.add_regexp("testfiles/output/rdiff-backup-data", 1)
- Time.setcurtime()
- SaveState.init_filenames(None)
- HighLevel.Mirror(self.inrp, self.outrp, 1)
- self.outrp.setdata()
- assert RPath.cmp_recursive(self.inrp, self.outrp)
+ MirrorTest(None, None, ["testfiles/increment1"], 1)
def testMirrorWithCheckpointing2(self):
"""Larger data set"""
- if self.outrp.lstat(): os.system(MiscDir+"/myrm %s" % self.outrp.path)
- self.outrp.setdata()
- self.outrp.mkdir()
- self.rbdir.mkdir()
- Globals.add_regexp("testfiles/output/rdiff-backup-data", 1)
- Time.setcurtime()
- SaveState.init_filenames(None)
- for rp in [self.inc1, self.inc2, self.inc3, self.inc4]:
- print "----------------- Starting ", rp.path
- HighLevel.Mirror(rp, self.outrp, 1)
- assert RPath.cmp_recursive(rp, self.outrp)
+ MirrorTest(1, None, ['testfiles/increment1', 'testfiles/increment2',
+ 'testfiles/increment3', 'testfiles/increment4'],
+ 1)
- def tearDown(self): SetConnections.CloseConnections()
if __name__ == "__main__": unittest.main()
diff --git a/rdiff-backup/testing/regressiontest.py b/rdiff-backup/testing/regressiontest.py
index 5d4d27e..354cbbb 100644
--- a/rdiff-backup/testing/regressiontest.py
+++ b/rdiff-backup/testing/regressiontest.py
@@ -1,7 +1,7 @@
import unittest, os
execfile("commontest.py")
-rbexec("setconnections.py")
+rbexec("main.py")
"""Regression tests
@@ -128,27 +128,28 @@ class PathSetter(unittest.TestCase):
SetConnections.CloseConnections()
-class IncrementTest(PathSetter):
+class IncrementTest1(unittest.TestCase):
+ dirlist = ["testfiles/increment1", "testfiles/increment2",
+ "testfiles/increment3", "testfiles/increment4"]
+
def testLocalinc(self):
"""Test self.incrementing, and then restoring, local"""
- self.setPathnames(None, None, None, None)
- self.runtest()
+ BackupRestoreSeries(1, 1, self.dirlist)
def test_remote_src(self):
"""Increment/Restore when source directory is remote"""
- self.setPathnames('test1', '../', None, None)
- self.runtest()
+ BackupRestoreSeries(None, 1, self.dirlist)
def test_remote_dest(self):
"""Increment/Restore when target directory is remote"""
- self.setPathnames(None, None, 'test2', '../')
- self.runtest()
+ BackupRestoreSeries(1, None, self.dirlist)
def test_remote_both(self):
"""Increment/Restore when both directories are remote"""
- self.setPathnames('test1', '../', 'test2/tmp', '../../')
- self.runtest()
-
+ BackupRestoreSeries(None, None, self.dirlist)
+
+
+class IncrementTest2(PathSetter):
def OldtestRecoveryLocal(self):
"""Test to see if rdiff-backup can continue with bad increment"""
os.system(MiscDir+'/myrm testfiles/recovery_out_backup')
@@ -188,43 +189,43 @@ class IncrementTest(PathSetter):
Time.setcurtime()
SaveState.init_filenames(1)
HighLevel.Mirror(self.inc1rp, self.rpout)
- assert RPath.cmp_recursive(Local.inc1rp, Local.rpout)
+ assert CompareRecursive(Local.inc1rp, Local.rpout)
Time.setcurtime()
Time.setprevtime(999500000)
HighLevel.Mirror_and_increment(self.inc2rp, self.rpout, self.rpout_inc)
- assert RPath.cmp_recursive(Local.inc2rp, Local.rpout)
+ assert CompareRecursive(Local.inc2rp, Local.rpout)
Time.setcurtime()
Time.setprevtime(999510000)
HighLevel.Mirror_and_increment(self.inc3rp, self.rpout, self.rpout_inc)
- assert RPath.cmp_recursive(Local.inc3rp, Local.rpout)
+ assert CompareRecursive(Local.inc3rp, Local.rpout)
Time.setcurtime()
Time.setprevtime(999520000)
HighLevel.Mirror_and_increment(self.inc4rp, self.rpout, self.rpout_inc)
- assert RPath.cmp_recursive(Local.inc4rp, Local.rpout)
+ assert CompareRecursive(Local.inc4rp, Local.rpout)
print "Restoring to self.inc4"
HighLevel.Restore(999530000, self.rpout, self.get_inctup(),
self.rpout4)
- assert RPath.cmp_recursive(Local.inc4rp, Local.rpout4)
+ assert CompareRecursive(Local.inc4rp, Local.rpout4)
print "Restoring to self.inc3"
HighLevel.Restore(999520000, self.rpout, self.get_inctup(),
self.rpout3)
- assert RPath.cmp_recursive(Local.inc3rp, Local.rpout3)
+ assert CompareRecursive(Local.inc3rp, Local.rpout3)
print "Restoring to self.inc2"
HighLevel.Restore(999510000, self.rpout, self.get_inctup(),
self.rpout2)
- assert RPath.cmp_recursive(Local.inc2rp, Local.rpout2)
+ assert CompareRecursive(Local.inc2rp, Local.rpout2)
print "Restoring to self.inc1"
HighLevel.Restore(999500000, self.rpout, self.get_inctup(),
self.rpout1)
- assert RPath.cmp_recursive(Local.inc1rp, Local.rpout1)
+ assert CompareRecursive(Local.inc1rp, Local.rpout1)
def get_inctup(self):
"""Return inc tuples as expected by Restore.RestoreRecursive
@@ -288,7 +289,7 @@ class MirrorTest(PathSetter):
SaveState.init_filenames(None)
HighLevel.Mirror(self.noperms, self.noperms_out, None)
# Can't compare because we don't have the permissions to do it right
- #assert RPath.cmp_recursive(Local.noperms, Local.noperms_out)
+ #assert CompareRecursive(Local.noperms, Local.noperms_out)
def testNopermsRemote(self):
"No permissions mirroring (remote)"
@@ -296,7 +297,7 @@ class MirrorTest(PathSetter):
Time.setcurtime()
SaveState.init_filenames(None)
HighLevel.Mirror(self.noperms, self.noperms_out, checkpoint=None)
- #assert RPath.cmp_recursive(Local.noperms, Local.noperms_out)
+ #assert CompareRecursive(Local.noperms, Local.noperms_out)
def testPermSkipLocal(self):
"""Test to see if rdiff-backup will skip unreadable files"""
@@ -330,7 +331,7 @@ class MirrorTest(PathSetter):
self.refresh(self.rootfiles, self.rootfiles_out,
Local.rootfiles, Local.rootfiles_out) # add uid/gid info
HighLevel.Mirror(self.rootfiles, self.rootfiles_out)
- assert RPath.cmp_recursive(Local.rootfiles, Local.rootfiles_out)
+ assert CompareRecursive(Local.rootfiles, Local.rootfiles_out)
Globals.change_ownership = None
self.refresh(self.rootfiles, self.rootfiles_out,
Local.rootfiles, Local.rootfiles_out) # remove that info
@@ -343,7 +344,7 @@ class MirrorTest(PathSetter):
self.refresh(self.rootfiles, self.rootfiles_out,
Local.rootfiles, Local.rootfiles_out) # add uid/gid info
HighLevel.Mirror(self.rootfiles, self.rootfiles_out)
- assert RPath.cmp_recursive(Local.rootfiles, Local.rootfiles_out)
+ assert CompareRecursive(Local.rootfiles, Local.rootfiles_out)
for coon in Globals.connections:
conn.Globals.set('change_ownership', None)
self.refresh(self.rootfiles, self.rootfiles_out,
@@ -356,11 +357,11 @@ class MirrorTest(PathSetter):
self.refresh(self.rootfiles2, self.rootfiles_out2,
Local.rootfiles2, Local.rootfiles_out2) # add uid/gid info
HighLevel.Mirror(self.rootfiles2, self.rootfiles_out2)
- assert RPath.cmp_recursive(Local.rootfiles2, Local.rootfiles_out2)
+ assert CompareRecursive(Local.rootfiles2, Local.rootfiles_out2)
self.refresh(self.rootfiles2, self.rootfiles_out2,
Local.rootfiles2, Local.rootfiles_out2) # remove that info
HighLevel.Mirror(self.rootfiles21, self.rootfiles_out2)
- assert RPath.cmp_recursive(Local.rootfiles21, Local.rootfiles_out2)
+ assert CompareRecursive(Local.rootfiles21, Local.rootfiles_out2)
self.refresh(self.rootfiles21, self.rootfiles_out2,
Local.rootfiles21, Local.rootfiles_out2) # remove that info
Globals.change_source_perms = 1
@@ -387,12 +388,12 @@ class MirrorTest(PathSetter):
SaveState.init_filenames(None)
assert self.rbdir.lstat()
HighLevel.Mirror(self.inc1rp, self.rpout)
- assert RPath.cmp_recursive(Local.inc1rp, Local.rpout)
+ assert CompareRecursive(Local.inc1rp, Local.rpout)
self.deleteoutput()
HighLevel.Mirror(self.inc2rp, self.rpout)
- assert RPath.cmp_recursive(Local.inc2rp, Local.rpout)
+ assert CompareRecursive(Local.inc2rp, Local.rpout)
def run_partial_test(self):
os.system("cp -a testfiles/increment3 testfiles/output")
@@ -402,9 +403,9 @@ class MirrorTest(PathSetter):
SaveState.init_filenames(None)
HighLevel.Mirror(self.inc1rp, self.rpout)
#RPath.copy_attribs(self.inc1rp, self.rpout)
- assert RPath.cmp_recursive(Local.inc1rp, Local.rpout)
+ assert CompareRecursive(Local.inc1rp, Local.rpout)
HighLevel.Mirror(self.inc2rp, self.rpout)
- assert RPath.cmp_recursive(Local.inc2rp, Local.rpout)
+ assert CompareRecursive(Local.inc2rp, Local.rpout)
if __name__ == "__main__": unittest.main()
diff --git a/rdiff-backup/testing/roottest.py b/rdiff-backup/testing/roottest.py
index 18a0afc..2de29f0 100644
--- a/rdiff-backup/testing/roottest.py
+++ b/rdiff-backup/testing/roottest.py
@@ -136,7 +136,7 @@ class MirrorTest(PathSetter):
self.refresh(self.rootfiles, self.rootfiles_out,
Local.rootfiles, Local.rootfiles_out) # add uid/gid info
HighLevel.Mirror(self.rootfiles, self.rootfiles_out)
- assert RPath.cmp_recursive(Local.rootfiles, Local.rootfiles_out)
+ assert CompareRecursive(Local.rootfiles, Local.rootfiles_out)
Globals.change_ownership = None
self.refresh(self.rootfiles, self.rootfiles_out,
Local.rootfiles, Local.rootfiles_out) # remove that info
@@ -151,7 +151,7 @@ class MirrorTest(PathSetter):
self.refresh(self.rootfiles, self.rootfiles_out,
Local.rootfiles, Local.rootfiles_out) # add uid/gid info
HighLevel.Mirror(self.rootfiles, self.rootfiles_out)
- assert RPath.cmp_recursive(Local.rootfiles, Local.rootfiles_out)
+ assert CompareRecursive(Local.rootfiles, Local.rootfiles_out)
for coon in Globals.connections:
conn.Globals.set('change_ownership', None)
self.refresh(self.rootfiles, self.rootfiles_out,
diff --git a/rdiff-backup/testing/rorpitertest.py b/rdiff-backup/testing/rorpitertest.py
index b9d558f..28ac54b 100644
--- a/rdiff-backup/testing/rorpitertest.py
+++ b/rdiff-backup/testing/rorpitertest.py
@@ -62,25 +62,25 @@ class RORPIterTest(unittest.TestCase):
RORPIter.PatchIter(self.output, RORPIter.FromFile(diff_file))
turninto(self.inc1rp)
- assert self.compare_rps(self.output, self.inc1rp)
+ RPath.copy_attribs(self.inc1rp, self.output) # Update time
+ assert self.compare_no_times(self.inc1rp, self.output)
turninto(self.inc2rp)
- assert self.compare_rps(self.output, self.inc2rp)
-
- def compare_rps(self, rp1, rp2):
- """True if rp1 and rp2 are equal in some sense"""
- def RawIter(rp):
- """Get raw iterator of file stats based an rp1"""
- return RORPIter.ToRaw(Iter.map(lambda rp2: rp2.getRORPath(),
- RORPIter.IterateRPaths(rp)))
- ri1 = RawIter(rp1)
- ri2 = RawIter(rp2)
- try:
- rorp1 = ri1.next()
- rorp2 = ri2.next()
- assert rorp1 == rorp2, "%s %s" % (rorp1, rorp2)
- except StopIteration: pass
- return 1
- # return Iter.equal(RawIter(rp1), RawIter(rp2))
+ RPath.copy_attribs(self.inc2rp, self.output)
+ assert self.compare_no_times(self.inc2rp, self.output)
+
+ def compare_no_times(self, src_rp, dest_rp):
+ """Compare but disregard directories attributes"""
+ dsiter1, dsiter2 = map(DestructiveStepping.Iterate_with_Finalizer,
+ [src_rp, dest_rp], [1, None])
+
+ def equal(src_rorp, dest_rorp):
+ return ((src_rorp.isdir() and dest_rorp.isdir()) or
+ src_rorp == dest_rorp)
+
+ result = Iter.equal(dsiter1, dsiter2, 1, equal)
+ for i in dsiter1: pass # make sure all files processed anyway
+ for i in dsiter2: pass
+ return result
class IndexedTupleTest(unittest.TestCase):
diff --git a/rdiff-backup/testing/server.py b/rdiff-backup/testing/server.py
index b30c745..17e11ca 100755
--- a/rdiff-backup/testing/server.py
+++ b/rdiff-backup/testing/server.py
@@ -1,12 +1,30 @@
#!/usr/bin/env python
-import sys
-execfile("commontest.py")
-rbexec("setconnections.py")
+import sys, os
-def Test_SetConnGlobals(conn, name, val):
- """Used in unittesting - set one of specified connection's Global vars"""
- conn.Globals.set(name, val)
+__doc__ = """
-Log.setverbosity(9)
+This starts an rdiff-backup server using the existing source files.
+If not run from the source directory, the only argument should be
+the directory the source files are in.
+"""
+
+def print_usage():
+ print "Usage: server.py [path to source files]", __doc__
+
+if len(sys.argv) > 2:
+ print_usage()
+ sys.exit(1)
+
+try:
+ if len(sys.argv) == 2:
+ olddir = os.getcwd()
+ os.chdir(sys.argv[1])
+ execfile("setconnections.py")
+ if len(sys.argv) == 2: os.chdir(olddir)
+except (OSError, IOError):
+ print_usage()
+ raise
+
+#Log.setverbosity(9)
PipeConnection(sys.stdin, sys.stdout).Server()