From 8193d3dd61da7670fbe9f68b989808841a092cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Wed, 1 Oct 2014 05:42:33 +0200 Subject: [PATCH] tests: add test restore of R1 backup --- tests/backupcompatibility.py | 54 ++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/tests/backupcompatibility.py b/tests/backupcompatibility.py index d1cc8390..5bedba4b 100644 --- a/tests/backupcompatibility.py +++ b/tests/backupcompatibility.py @@ -102,6 +102,11 @@ X-Qubes-VmName=%VMNAME% Icon=%VMDIR%/icon.png """ +QUBESXML_R1 = """ + + +""" + class BackupCompatibilityTests(unittest.TestCase): def setUp(self): self.error_detected = Queue() @@ -240,17 +245,13 @@ class BackupCompatibilityTests(unittest.TestCase): def fullpath(self, name): return os.path.join(self.backupdir, name) - def test_r2b2(self): + def create_v1_files(self, r2b2=False): appmenus_list = [ "firefox", "gnome-terminal", "evince", "evolution", "mozilla-thunderbird", "libreoffice-startcenter", "nautilus", "gedit", "gpk-update-viewer", "gpk-application" ] - f = open(self.fullpath("qubes.xml"), "w") - f.write(QUBESXML_R2B2) - f.close() - os.mkdir(self.fullpath("appvms")) os.mkdir(self.fullpath("servicevms")) os.mkdir(self.fullpath("vm-templates")) @@ -291,9 +292,10 @@ class BackupCompatibilityTests(unittest.TestCase): self.fullpath("appvms/test-custom-template-appvm")]) # HVM - subprocess.check_call( - ["/bin/cp", "-a", self.fullpath("appvms/test-standalonevm"), - self.fullpath("appvms/test-testhvm")]) + if r2b2: + subprocess.check_call( + ["/bin/cp", "-a", self.fullpath("appvms/test-standalonevm"), + self.fullpath("appvms/test-testhvm")]) # ProxyVM os.mkdir(self.fullpath("servicevms/test-testproxy")) @@ -324,9 +326,10 @@ class BackupCompatibilityTests(unittest.TestCase): "vm-templates/test-template-clone/whitelisted-appmenus.list")) self.create_whitelisted_appmenus(self.fullpath( "vm-templates/test-template-clone/vm-whitelisted-appmenus.list")) - self.create_whitelisted_appmenus(self.fullpath( - "vm-templates/test-template-clone/netvm-whitelisted-appmenus" - ".list")) + if r2b2: + self.create_whitelisted_appmenus(self.fullpath( + "vm-templates/test-template-clone/netvm-whitelisted-appmenus" + ".list")) os.symlink("/usr/share/qubes/icons/green.png", self.fullpath("vm-templates/test-template-clone/icon.png")) os.mkdir( @@ -343,6 +346,14 @@ class BackupCompatibilityTests(unittest.TestCase): "vm-templates/test-template-clone")), appmenus_list) + + def test_r2b2(self): + self.create_v1_files(r2b2=True) + + f = open(self.fullpath("qubes.xml"), "w") + f.write(QUBESXML_R2B2) + f.close() + self.restore_backup(self.backupdir, options={ 'use-default-template': True, }) @@ -357,3 +368,24 @@ class BackupCompatibilityTests(unittest.TestCase): self.assertEqual(self.qc.get_vm_by_name("test-custom-template-appvm") .template, self.qc.get_vm_by_name("test-template-clone")) + + def test_r1(self): + self.create_v1_files(r2b2=False) + + f = open(self.fullpath("qubes.xml"), "w") + f.write(QUBESXML_R1) + f.close() + + self.restore_backup(self.backupdir, options={ + 'use-default-template': True, + }) + self.reload_qc() + self.assertIsNotNone(self.qc.get_vm_by_name("test-template-clone")) + self.assertIsNotNone(self.qc.get_vm_by_name("test-testproxy")) + self.assertIsNotNone(self.qc.get_vm_by_name("test-work")) + self.assertIsNotNone(self.qc.get_vm_by_name("test-standalonevm")) + self.assertIsNotNone(self.qc.get_vm_by_name( + "test-custom-template-appvm")) + self.assertEqual(self.qc.get_vm_by_name("test-custom-template-appvm") + .template, + self.qc.get_vm_by_name("test-template-clone"))