98 |
"""Test --compare-full of subdirectory, remote""" |
"""Test --compare-full of subdirectory, remote""" |
99 |
self.generic_selective_test(0, "--compare-full") |
self.generic_selective_test(0, "--compare-full") |
100 |
|
|
101 |
|
def verify(self, local): |
102 |
|
"""Used for the verify tests""" |
103 |
|
def change_file(rp): |
104 |
|
"""Given rpath, open it, and change a byte in the middle""" |
105 |
|
fp = rp.open("rb") |
106 |
|
fp.seek(int(rp.getsize()/2)) |
107 |
|
char = fp.read(1) |
108 |
|
fp.close() |
109 |
|
|
110 |
|
fp = rp.open("wb") |
111 |
|
fp.seek(int(rp.getsize()/2)) |
112 |
|
if char == 'a': fp.write('b') |
113 |
|
else: fp.write('a') |
114 |
|
fp.close() |
115 |
|
|
116 |
|
def modify_diff(): |
117 |
|
"""Write to the stph_icons.h diff""" |
118 |
|
l = [filename for filename in |
119 |
|
os.listdir('testfiles/output/rdiff-backup-data/increments') |
120 |
|
if filename.startswith('stph_icons.h')] |
121 |
|
assert len(l) == 1, l |
122 |
|
diff_rp = rpath.RPath(Globals.local_connection, |
123 |
|
'testfiles/output/rdiff-backup-data/increments/' + l[0]) |
124 |
|
change_file(diff_rp) |
125 |
|
|
126 |
|
rdiff_backup(local, local, 'testfiles/output', None, |
127 |
|
extra_options = "--verify") |
128 |
|
rdiff_backup(local, local, 'testfiles/output', None, |
129 |
|
extra_options = "--verify-at-time 10000") |
130 |
|
modify_diff() |
131 |
|
ret_val = rdiff_backup(local, local, 'testfiles/output', None, |
132 |
|
extra_options = "--verify-at-time 10000", |
133 |
|
check_return_val = 0) |
134 |
|
assert ret_val, ret_val |
135 |
|
change_file(rpath.RPath(Globals.local_connection, |
136 |
|
'testfiles/output/stph_icons.h')) |
137 |
|
ret_val = rdiff_backup(local, local, 'testfiles/output', None, |
138 |
|
extra_options = "--verify", check_return_val = 0) |
139 |
|
assert ret_val, ret_val |
140 |
|
|
141 |
|
def testVerifyLocal(self): |
142 |
|
"""Test --verify of directory, local""" |
143 |
|
self.verify(1) |
144 |
|
|
145 |
|
def testVerifyRemote(self): |
146 |
|
"""Test --verify remotely""" |
147 |
|
self.verify(0) |
148 |
|
|
149 |
if __name__ == "__main__": unittest.main() |
if __name__ == "__main__": unittest.main() |
150 |
|
|