tests/backup: use proper logging instead of print

This commit is contained in:
Marek Marczykowski-Górecki 2016-09-25 23:00:20 +02:00
parent 016c3d8e88
commit 6d5959b31d
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -56,10 +56,8 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
except AttributeError: except AttributeError:
self.init_default_template() self.init_default_template()
self.error_detected = multiprocessing.Queue() self.error_detected = multiprocessing.Queue()
self.verbose = False
if self.verbose: self.log.debug("Creating backupvm")
print >>sys.stderr, "-> Creating backupvm"
self.backupdir = os.path.join(os.environ["HOME"], "test-backup") self.backupdir = os.path.join(os.environ["HOME"], "test-backup")
if os.path.exists(self.backupdir): if os.path.exists(self.backupdir):
@ -81,8 +79,7 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
def fill_image(self, path, size=None, sparse=False): def fill_image(self, path, size=None, sparse=False):
block_size = 4096 block_size = 4096
if self.verbose: self.log.debug("Filling %s" % path)
print >>sys.stderr, "-> Filling %s" % path
f = open(path, 'w+') f = open(path, 'w+')
if size is None: if size is None:
f.seek(0, 2) f.seek(0, 2)
@ -102,8 +99,7 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
vms = [] vms = []
vmname = self.make_vm_name('test-net') vmname = self.make_vm_name('test-net')
if self.verbose: self.log.debug("Creating %s" % vmname)
print >>sys.stderr, "-> Creating %s" % vmname
testnet = self.app.add_new_vm(qubes.vm.appvm.AppVM, testnet = self.app.add_new_vm(qubes.vm.appvm.AppVM,
name=vmname, template=template, provides_network=True, label='red') name=vmname, template=template, provides_network=True, label='red')
testnet.create_on_disk() testnet.create_on_disk()
@ -112,8 +108,7 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
self.fill_image(testnet.volumes['private'].path, 20*1024*1024) self.fill_image(testnet.volumes['private'].path, 20*1024*1024)
vmname = self.make_vm_name('test1') vmname = self.make_vm_name('test1')
if self.verbose: self.log.debug("Creating %s" % vmname)
print >>sys.stderr, "-> Creating %s" % vmname
testvm1 = self.app.add_new_vm(qubes.vm.appvm.AppVM, testvm1 = self.app.add_new_vm(qubes.vm.appvm.AppVM,
name=vmname, template=template, label='red') name=vmname, template=template, label='red')
testvm1.uses_default_netvm = False testvm1.uses_default_netvm = False
@ -123,8 +118,7 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
self.fill_image(testvm1.volumes['private'].path, 100*1024*1024) self.fill_image(testvm1.volumes['private'].path, 100*1024*1024)
vmname = self.make_vm_name('testhvm1') vmname = self.make_vm_name('testhvm1')
if self.verbose: self.log.debug("Creating %s" % vmname)
print >>sys.stderr, "-> Creating %s" % vmname
testvm2 = self.app.add_new_vm(qubes.vm.standalonevm.StandaloneVM, testvm2 = self.app.add_new_vm(qubes.vm.standalonevm.StandaloneVM,
name=vmname, name=vmname,
hvm=True, hvm=True,
@ -134,8 +128,7 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
vms.append(testvm2) vms.append(testvm2)
vmname = self.make_vm_name('template') vmname = self.make_vm_name('template')
if self.verbose: self.log.debug("Creating %s" % vmname)
print >>sys.stderr, "-> Creating %s" % vmname
testvm3 = self.app.add_new_vm(qubes.vm.templatevm.TemplateVM, testvm3 = self.app.add_new_vm(qubes.vm.templatevm.TemplateVM,
name=vmname, label='red') name=vmname, label='red')
testvm3.create_on_disk() testvm3.create_on_disk()
@ -143,8 +136,7 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
vms.append(testvm3) vms.append(testvm3)
vmname = self.make_vm_name('custom') vmname = self.make_vm_name('custom')
if self.verbose: self.log.debug("Creating %s" % vmname)
print >>sys.stderr, "-> Creating %s" % vmname
testvm4 = self.app.add_new_vm(qubes.vm.appvm.AppVM, testvm4 = self.app.add_new_vm(qubes.vm.appvm.AppVM,
name=vmname, template=testvm3, label='red') name=vmname, template=testvm3, label='red')
testvm4.create_on_disk() testvm4.create_on_disk()
@ -194,8 +186,7 @@ class BackupTestsMixin(qubes.tests.SystemTestsMixin):
for key, value in options.iteritems(): for key, value in options.iteritems():
setattr(restore_op.options, key, value) setattr(restore_op.options, key, value)
restore_info = restore_op.get_restore_info() restore_info = restore_op.get_restore_info()
if self.verbose: self.log.debug(restore_op.get_restore_summary(restore_info))
print restore_op.get_restore_summary(restore_info)
with self.assertNotRaises(qubes.exc.QubesException): with self.assertNotRaises(qubes.exc.QubesException):
restore_op.restore_do(restore_info) restore_op.restore_do(restore_info)
@ -328,8 +319,7 @@ class TC_00_Backup(BackupTestsMixin, qubes.tests.QubesTestCase):
vms = [] vms = []
vmname = self.make_vm_name('testhvm2') vmname = self.make_vm_name('testhvm2')
if self.verbose: self.log.debug("Creating %s" % vmname)
print >>sys.stderr, "-> Creating %s" % vmname
hvmtemplate = self.app.add_new_vm( hvmtemplate = self.app.add_new_vm(
qubes.vm.templatevm.TemplateVM, name=vmname, hvm=True, label='red') qubes.vm.templatevm.TemplateVM, name=vmname, hvm=True, label='red')