tests: add regression test for #1386

QubesOS/qubes-issues#1386
This commit is contained in:
Marek Marczykowski-Górecki 2015-11-07 03:11:55 +01:00
parent 8275e828af
commit 6051a89227
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 27 additions and 2 deletions

View File

@ -477,7 +477,8 @@ class BackupTestsMixin(SystemTestsMixin):
self.qc.load()
def restore_backup(self, source=None, appvm=None, options=None):
def restore_backup(self, source=None, appvm=None, options=None,
expect_errors=None):
if source is None:
backupfile = os.path.join(self.backupdir,
sorted(os.listdir(self.backupdir))[-1])
@ -506,8 +507,13 @@ class BackupTestsMixin(SystemTestsMixin):
self.qc.load()
errors = []
if expect_errors is None:
expect_errors = []
while not self.error_detected.empty():
errors.append(self.error_detected.get())
current_error = self.error_detected.get()
if any(map(current_error.startswith, expect_errors)):
continue
errors.append(current_error)
self.assertTrue(len(errors) == 0,
"Error(s) detected during backup_restore_do: %s" %
'\n'.join(errors))

View File

@ -100,3 +100,22 @@ class TC_00_Backup(qubes.tests.BackupTestsMixin, qubes.tests.QubesTestCase):
self.restore_backup(source='dd if=/var/tmp/backup-test',
appvm=self.backupvm)
self.remove_vms(vms)
def test_200_restore_over_existing_directory(self):
"""
Regression test for #1386
:return:
"""
vms = self.create_backup_vms()
self.make_backup(vms)
self.remove_vms(vms)
test_dir = vms[0].dir_path
os.mkdir(test_dir)
with open(os.path.join(test_dir, 'some-file.txt'), 'w') as f:
f.write('test file\n')
self.restore_backup(
expect_errors=[
'*** Directory {} already exists! It has been moved'.format(
test_dir)
])
self.remove_vms(vms)