tests: improve "revert template changes" test

There is no more significant difference between PV and HVM. VMs are HVM
by default anyway. More important for this test is difference between
Linux (with Qubes packages installed) and other OS-es. Rename tests
accordingly. The later one is still incomplete.
This commit is contained in:
Marek Marczykowski-Górecki 2017-09-28 02:49:32 +02:00
parent 4b51c9da07
commit f0da5b21df
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -343,7 +343,7 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase):
def cleanup_template(self): def cleanup_template(self):
del self.test_template del self.test_template
def setup_pv_template(self): def setup_template(self):
self.test_template = self.app.add_new_vm( self.test_template = self.app.add_new_vm(
qubes.vm.templatevm.TemplateVM, qubes.vm.templatevm.TemplateVM,
name=self.make_vm_name("pv-clone"), name=self.make_vm_name("pv-clone"),
@ -351,26 +351,15 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase):
) )
self.addCleanup(self.cleanup_template) self.addCleanup(self.cleanup_template)
self.test_template.clone_properties(self.app.default_template) self.test_template.clone_properties(self.app.default_template)
self.test_template.features.update(self.app.default_template.features)
self.test_template.tags.update(self.app.default_template.tags)
self.loop.run_until_complete( self.loop.run_until_complete(
self.test_template.clone_disk_files(self.app.default_template)) self.test_template.clone_disk_files(self.app.default_template))
self.app.save() self.app.save()
def setup_hvm_template(self):
self.test_template = self.app.add_new_vm(
qubes.vm.templatevm.TemplateVM,
name=self.make_vm_name("hvm"),
label='red',
virt_mode='hvm',
)
self.addCleanup(self.cleanup_template)
self.loop.run_until_complete(self.test_template.create_on_disk())
self.app.save()
def get_rootimg_checksum(self): def get_rootimg_checksum(self):
p = subprocess.Popen( return subprocess.check_output(
['sha1sum', self.test_template.volumes['root'].path], ['sha1sum', self.test_template.volumes['root'].path])
stdout=subprocess.PIPE)
return p.communicate()[0]
def _do_test(self): def _do_test(self):
checksum_before = self.get_rootimg_checksum() checksum_before = self.get_rootimg_checksum()
@ -387,26 +376,26 @@ class TC_03_QvmRevertTemplateChanges(qubes.tests.SystemTestCase):
*revert_cmd)) *revert_cmd))
self.loop.run_until_complete(p.wait()) self.loop.run_until_complete(p.wait())
self.assertEqual(p.returncode, 0) self.assertEqual(p.returncode, 0)
del p
checksum_after = self.get_rootimg_checksum() checksum_after = self.get_rootimg_checksum()
self.assertEqual(checksum_before, checksum_after) self.assertEqual(checksum_before, checksum_after)
@unittest.expectedFailure @unittest.expectedFailure
def test_000_revert_pv(self): def test_000_revert_linux(self):
""" """
Test qvm-revert-template-changes for PV template Test qvm-revert-template-changes for PV template
""" """
self.setup_pv_template() self.setup_template()
self._do_test() self._do_test()
@unittest.skip('HVM not yet implemented') @unittest.skip('TODO: some non-linux system')
def test_000_revert_hvm(self): def test_001_revert_non_linux(self):
""" """
Test qvm-revert-template-changes for HVM template Test qvm-revert-template-changes for HVM template
""" """
# TODO: have some system there, so the root.img will get modified # TODO: have some system there, so the root.img will get modified
self.setup_hvm_template() self.setup_template()
self._do_test() self._do_test()
class TC_30_Gui_daemon(qubes.tests.SystemTestCase): class TC_30_Gui_daemon(qubes.tests.SystemTestCase):