def test_root(self): """Test changing uid/gid, devices""" self.deltmp() os.system("cp -pR testfiles/root1 testfiles/output/sequence") seq_path = Path("testfiles/output/sequence") new_path = Path("testfiles/root2") sig = Path("testfiles/output/sig.tar") diff = Path("testfiles/output/diff.tar") diffdir.write_block_iter(diffdir.DirSig(self.get_sel(seq_path)), sig) deltablock = diffdir.DirDelta(self.get_sel(new_path), sig.open("rb")) diffdir.write_block_iter(deltablock, diff) patchdir.Patch(seq_path, diff.open("rb")) # since we are not running as root, don't even both comparing, # just make sure file5 exists and file4 doesn't. file5 = seq_path.append("file5") assert file5.isreg() file4 = seq_path.append("file4") assert file4.type is None
def total_sequence(self, filelist): """Test signatures, diffing, and patching on directory list""" assert len(filelist) >= 2 self.deltmp() assert not os.system("cp -pR %s testfiles/output/sequence" % (filelist[0], )) seq_path = Path("testfiles/output/sequence") sig = Path("testfiles/output/sig.tar") diff = Path("testfiles/output/diff.tar") for dirname in filelist[1:]: new_path = Path(dirname) diffdir.write_block_iter( diffdir.DirSig(selection.Select(seq_path).set_iter()), sig) diffdir.write_block_iter( diffdir.DirDelta( selection.Select(new_path).set_iter(), sig.open("rb")), diff) patchdir.Patch(seq_path, diff.open("rb")) assert seq_path.compare_recursive(new_path, 1)
def total_sequence(self, filelist): u"""Test signatures, diffing, and patching on directory list""" assert len(filelist) >= 2 sig = Path(u"testfiles/output/sig.tar") diff = Path(u"testfiles/output/diff.tar") seq_path = Path(u"testfiles/output/sequence") new_path, old_path = None, None # set below in for loop # Write initial full backup to diff.tar for dirname in filelist: old_path, new_path = new_path, Path(dirname) if old_path: sigblock = diffdir.DirSig(self.get_sel(seq_path)) diffdir.write_block_iter(sigblock, sig) deltablock = diffdir.DirDelta(self.get_sel(new_path), sig.open(u"rb")) else: deltablock = diffdir.DirFull(self.get_sel(new_path)) diffdir.write_block_iter(deltablock, diff) patchdir.Patch(seq_path, diff.open(u"rb")) # print "#########", seq_path, new_path assert seq_path.compare_recursive(new_path, 1)