2
sys.path.insert(0, "../src")
4
import diffdir, patchdir
9
class RootTest(unittest.TestCase):
10
"""Test doing operations that only root can"""
11
def copyfileobj(self, infp, outfp):
12
"""Copy in fileobj to out, closing afterwards"""
15
buf = infp.read(blocksize)
18
assert not infp.close()
19
assert not outfp.close()
22
"""Delete temporary directories"""
23
assert not os.system("rm -rf testfiles/output")
24
os.mkdir("testfiles/output")
26
def total_sequence(self, filelist):
27
"""Test signatures, diffing, and patching on directory list"""
28
assert len(filelist) >= 2
30
assert not os.system("cp -a %s testfiles/output/sequence" %
32
seq_path = Path("testfiles/output/sequence")
33
sig = Path("testfiles/output/sig.tar")
34
diff = Path("testfiles/output/diff.tar")
35
for dirname in filelist[1:]:
36
new_path = Path(dirname)
37
diffdir.write_block_iter(
38
diffdir.DirSig(selection.Select(seq_path).set_iter()), sig)
40
diffdir.write_block_iter(
41
diffdir.DirDelta(selection.Select(new_path).set_iter(),
45
patchdir.Patch(seq_path, diff.open("rb"))
47
assert seq_path.compare_recursive(new_path, 1)
49
def test_basic_cycle(self):
50
"""Test cycle on dir with devices, changing uid/gid, etc."""
51
self.total_sequence(['testfiles/root1', 'testfiles/root2'])
53
def runtests(): unittest.main()
55
if __name__ == "__main__": unittest.main()