qubesvm.py 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. #!/usr/bin/python2 -O
  2. # vim: fileencoding=utf-8
  3. # pylint: disable=protected-access
  4. #
  5. # The Qubes OS Project, https://www.qubes-os.org/
  6. #
  7. # Copyright (C) 2014-2015 Joanna Rutkowska <joanna@invisiblethingslab.com>
  8. # Copyright (C) 2014-2015 Wojtek Porczyk <woju@invisiblethingslab.com>
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License along
  21. # with this program; if not, write to the Free Software Foundation, Inc.,
  22. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  23. #
  24. import os
  25. import unittest
  26. import uuid
  27. import datetime
  28. import qubes
  29. import qubes.exc
  30. import qubes.config
  31. import qubes.vm.qubesvm
  32. import qubes.tests
  33. class TestApp(object):
  34. labels = {1: qubes.Label(1, '0xcc0000', 'red')}
  35. def __init__(self):
  36. self.domains = {}
  37. class TestProp(object):
  38. # pylint: disable=too-few-public-methods
  39. __name__ = 'testprop'
  40. class TestVM(object):
  41. # pylint: disable=too-few-public-methods
  42. app = TestApp()
  43. def __init__(self, **kwargs):
  44. self.running = False
  45. self.installed_by_rpm = False
  46. for k, v in kwargs.items():
  47. setattr(self, k, v)
  48. def is_running(self):
  49. return self.running
  50. class TC_00_setters(qubes.tests.QubesTestCase):
  51. def setUp(self):
  52. self.vm = TestVM()
  53. self.prop = TestProp()
  54. def test_000_setter_qid(self):
  55. self.assertEqual(
  56. qubes.vm.qubesvm._setter_qid(self.vm, self.prop, 5), 5)
  57. def test_001_setter_qid_lt_0(self):
  58. with self.assertRaises(ValueError):
  59. qubes.vm.qubesvm._setter_qid(self.vm, self.prop, -1)
  60. def test_002_setter_qid_gt_max(self):
  61. with self.assertRaises(ValueError):
  62. qubes.vm.qubesvm._setter_qid(self.vm,
  63. self.prop, qubes.config.max_qid + 5)
  64. def test_010_setter_name(self):
  65. self.assertEqual(
  66. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 'test_name-1'),
  67. 'test_name-1')
  68. def test_011_setter_name_not_a_string(self):
  69. # pylint: disable=invalid-name
  70. with self.assertRaises(TypeError):
  71. qubes.vm.qubesvm._setter_name(self.vm, self.prop, False)
  72. def test_012_setter_name_longer_than_31(self):
  73. # pylint: disable=invalid-name
  74. with self.assertRaises(ValueError):
  75. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 't' * 32)
  76. def test_013_setter_name_illegal_character(self):
  77. # pylint: disable=invalid-name
  78. with self.assertRaises(ValueError):
  79. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 'test#')
  80. def test_014_setter_name_first_not_letter(self):
  81. # pylint: disable=invalid-name
  82. with self.assertRaises(ValueError):
  83. qubes.vm.qubesvm._setter_name(self.vm, self.prop, '1test')
  84. def test_015_setter_name_running(self):
  85. self.vm.running = True
  86. with self.assertRaises(qubes.exc.QubesVMNotHaltedError):
  87. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 'testname')
  88. def test_016_setter_name_installed_by_rpm(self):
  89. # pylint: disable=invalid-name
  90. self.vm.installed_by_rpm = True
  91. with self.assertRaises(qubes.exc.QubesException):
  92. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 'testname')
  93. def test_017_setter_name_duplicate(self):
  94. # pylint: disable=invalid-name
  95. self.vm.app.domains['duplicate'] = TestVM(name='duplicate')
  96. with self.assertRaises(qubes.exc.QubesException):
  97. qubes.vm.qubesvm._setter_name(self.vm, self.prop, 'duplicate')
  98. @unittest.skip('test not implemented')
  99. def test_020_setter_kernel(self):
  100. pass
  101. def test_030_setter_label_object(self):
  102. label = TestApp.labels[1]
  103. self.assertIs(label,
  104. qubes.vm.qubesvm._setter_label(self.vm, self.prop, label))
  105. def test_031_setter_label_getitem(self):
  106. label = TestApp.labels[1]
  107. self.assertIs(label,
  108. qubes.vm.qubesvm._setter_label(self.vm, self.prop, 'label-1'))
  109. # there is no check for self.app.get_label()
  110. class QubesVMTestsMixin(object):
  111. property_no_default = object()
  112. def setUp(self):
  113. super(QubesVMTestsMixin, self).setUp()
  114. self.app = qubes.tests.vm.TestApp()
  115. self.app.vmm.offline_mode = True
  116. def get_vm(self, **kwargs):
  117. return qubes.vm.qubesvm.QubesVM(self.app, None,
  118. qid=1, name=qubes.tests.VMPREFIX + 'test',
  119. **kwargs)
  120. def assertPropertyValue(self, vm, prop_name, set_value, expected_value,
  121. expected_xml_content=None):
  122. # FIXME: any better exception list? or maybe all of that should be a
  123. # single exception?
  124. with self.assertNotRaises((ValueError, TypeError, KeyError)):
  125. setattr(vm, prop_name, set_value)
  126. self.assertEquals(getattr(vm, prop_name), expected_value)
  127. if expected_xml_content is not None:
  128. xml = vm.__xml__()
  129. prop_xml = xml.xpath(
  130. './properties/property[@name=\'{}\']'.format(prop_name))
  131. self.assertEquals(len(prop_xml), 1, "Property not found in XML")
  132. self.assertEquals(prop_xml[0].text, expected_xml_content)
  133. def assertPropertyInvalidValue(self, vm, prop_name, set_value):
  134. orig_value_set = True
  135. orig_value = None
  136. try:
  137. orig_value = getattr(vm, prop_name)
  138. except AttributeError:
  139. orig_value_set = False
  140. # FIXME: any better exception list? or maybe all of that should be a
  141. # single exception?
  142. with self.assertRaises((ValueError, TypeError, KeyError)):
  143. setattr(vm, prop_name, set_value)
  144. if orig_value_set:
  145. self.assertEquals(getattr(vm, prop_name), orig_value)
  146. else:
  147. with self.assertRaises(AttributeError):
  148. getattr(vm, prop_name)
  149. def assertPropertyDefaultValue(self, vm, prop_name,
  150. expected_default=property_no_default):
  151. if expected_default is self.property_no_default:
  152. with self.assertRaises(AttributeError):
  153. getattr(vm, prop_name)
  154. else:
  155. with self.assertNotRaises(AttributeError):
  156. self.assertEquals(getattr(vm, prop_name), expected_default)
  157. xml = vm.__xml__()
  158. prop_xml = xml.xpath(
  159. './properties/property[@name=\'{}\']'.format(prop_name))
  160. self.assertEquals(len(prop_xml), 0, "Property still found in XML")
  161. def _test_generic_bool_property(self, vm, prop_name, default=False):
  162. self.assertPropertyDefaultValue(vm, prop_name, default)
  163. self.assertPropertyValue(vm, prop_name, False, False, 'False')
  164. self.assertPropertyValue(vm, prop_name, True, True, 'True')
  165. delattr(vm, prop_name)
  166. self.assertPropertyDefaultValue(vm, prop_name, default)
  167. self.assertPropertyValue(vm, prop_name, 'True', True, 'True')
  168. self.assertPropertyValue(vm, prop_name, 'False', False, 'False')
  169. self.assertPropertyInvalidValue(vm, prop_name, 'xxx')
  170. self.assertPropertyValue(vm, prop_name, 123, True)
  171. self.assertPropertyInvalidValue(vm, prop_name, '')
  172. class TC_90_QubesVM(QubesVMTestsMixin,qubes.tests.QubesTestCase):
  173. def test_000_init(self):
  174. self.get_vm()
  175. def test_001_init_no_qid_or_name(self):
  176. with self.assertRaises(AssertionError):
  177. qubes.vm.qubesvm.QubesVM(self.app, None,
  178. name=qubes.tests.VMPREFIX + 'test')
  179. with self.assertRaises(AssertionError):
  180. qubes.vm.qubesvm.QubesVM(self.app, None,
  181. qid=1)
  182. def test_003_init_fire_domain_init(self):
  183. class TestVM2(qubes.vm.qubesvm.QubesVM):
  184. event_fired = False
  185. @qubes.events.handler('domain-init')
  186. def on_domain_init(self, event): # pylint: disable=unused-argument
  187. self.__class__.event_fired = True
  188. TestVM2(self.app, None, qid=1, name=qubes.tests.VMPREFIX + 'test')
  189. self.assertTrue(TestVM2.event_fired)
  190. def test_004_uuid_autogen(self):
  191. vm = self.get_vm()
  192. self.assertTrue(hasattr(vm, 'uuid'))
  193. def test_100_qid(self):
  194. vm = self.get_vm()
  195. self.assertIsInstance(vm.qid, int)
  196. with self.assertRaises(AttributeError):
  197. vm.qid = 2
  198. def test_110_name(self):
  199. vm = self.get_vm()
  200. self.assertIsInstance(vm.name, basestring)
  201. def test_120_uuid(self):
  202. my_uuid = uuid.uuid4()
  203. vm = self.get_vm(uuid=my_uuid)
  204. self.assertIsInstance(vm.uuid, uuid.UUID)
  205. self.assertIs(vm.uuid, my_uuid)
  206. with self.assertRaises(AttributeError):
  207. vm.uuid = uuid.uuid4()
  208. @unittest.skip('TODO: how to not fail on making an icon symlink here?')
  209. def test_130_label(self):
  210. vm = self.get_vm()
  211. self.assertPropertyDefaultValue(vm, 'label')
  212. self.assertPropertyValue(vm, 'label', self.app.labels[1],
  213. self.app.labels[1], 'label-1')
  214. del vm.label
  215. self.assertPropertyDefaultValue(vm, 'label')
  216. self.assertPropertyValue(vm, 'label', 'red',
  217. self.app.labels[1], 'label-1')
  218. self.assertPropertyValue(vm, 'label', 'label-1',
  219. self.app.labels[1], 'label-1')
  220. def test_131_label_invalid(self):
  221. vm = self.get_vm()
  222. self.assertPropertyInvalidValue(vm, 'label', 'invalid')
  223. self.assertPropertyInvalidValue(vm, 'label', 123)
  224. def test_150_hvm(self):
  225. vm = self.get_vm()
  226. self._test_generic_bool_property(vm, 'hvm')
  227. def test_160_memory(self):
  228. vm = self.get_vm()
  229. self.assertPropertyDefaultValue(vm, 'memory', 400)
  230. self.assertPropertyValue(vm, 'memory', 500, 500, '500')
  231. del vm.memory
  232. self.assertPropertyDefaultValue(vm, 'memory', 400)
  233. self.assertPropertyValue(vm, 'memory', '500', 500, '500')
  234. def test_161_memory_invalid(self):
  235. vm = self.get_vm()
  236. self.assertPropertyInvalidValue(vm, 'memory', -100)
  237. self.assertPropertyInvalidValue(vm, 'memory', '-100')
  238. self.assertPropertyInvalidValue(vm, 'memory', '')
  239. # TODO: higher than maxmem
  240. # TODO: human readable setter (500M, 4G)?
  241. def test_170_maxmem(self):
  242. vm = self.get_vm()
  243. self.assertPropertyDefaultValue(vm, 'maxmem',
  244. self.app.host.memory_total / 1024 / 2)
  245. self.assertPropertyValue(vm, 'maxmem', 500, 500, '500')
  246. del vm.maxmem
  247. self.assertPropertyDefaultValue(vm, 'maxmem',
  248. self.app.host.memory_total / 1024 / 2)
  249. self.assertPropertyValue(vm, 'maxmem', '500', 500, '500')
  250. def test_171_maxmem_invalid(self):
  251. vm = self.get_vm()
  252. self.assertPropertyInvalidValue(vm, 'maxmem', -100)
  253. self.assertPropertyInvalidValue(vm, 'maxmem', '-100')
  254. self.assertPropertyInvalidValue(vm, 'maxmem', '')
  255. # TODO: lower than memory
  256. # TODO: human readable setter (500M, 4G)?
  257. def test_180_internal(self):
  258. vm = self.get_vm(label='red')
  259. self._test_generic_bool_property(vm, 'internal', False)
  260. def test_190_vcpus(self):
  261. vm = self.get_vm()
  262. self.assertPropertyDefaultValue(vm, 'vcpus', self.app.host.no_cpus)
  263. self.assertPropertyValue(vm, 'vcpus', 3, 3, '3')
  264. del vm.vcpus
  265. self.assertPropertyDefaultValue(vm, 'vcpus', self.app.host.no_cpus)
  266. self.assertPropertyValue(vm, 'vcpus', '3', 3, '3')
  267. def test_191_vcpus_invalid(self):
  268. vm = self.get_vm()
  269. self.assertPropertyInvalidValue(vm, 'vcpus', 0)
  270. self.assertPropertyInvalidValue(vm, 'vcpus', -2)
  271. self.assertPropertyInvalidValue(vm, 'vcpus', '-2')
  272. self.assertPropertyInvalidValue(vm, 'vcpus', '')
  273. def test_200_debug(self):
  274. vm = self.get_vm()
  275. self._test_generic_bool_property(vm, 'debug', False)
  276. def test_210_installed_by_rpm(self):
  277. vm = self.get_vm()
  278. self._test_generic_bool_property(vm, 'installed_by_rpm', False)
  279. def test_220_include_in_backups(self):
  280. vm = self.get_vm()
  281. self._test_generic_bool_property(vm, 'include_in_backups', True)
  282. def test_240_firewall_conf(self):
  283. vm = self.get_vm()
  284. self.assertPropertyDefaultValue(vm, 'firewall_conf', 'firewall.xml')
  285. self.assertPropertyValue(vm, 'firewall_conf', 'other.xml',
  286. 'other.xml', 'other.xml')
  287. del vm.firewall_conf
  288. self.assertPropertyDefaultValue(vm, 'firewall_conf',
  289. 'firewall.xml')
  290. @unittest.expectedFailure
  291. def test_241_firewall_conf_invalid(self):
  292. vm = self.get_vm()
  293. self.assertPropertyInvalidValue(vm, 'firewall_conf', None)
  294. @qubes.tests.skipUnlessDom0
  295. def test_250_kernel(self):
  296. kernels = os.listdir(os.path.join(
  297. qubes.config.qubes_base_dir,
  298. qubes.config.system_path['qubes_kernels_base_dir']))
  299. if not len(kernels):
  300. self.skipTest('Needs at least one kernel installed')
  301. self.app.default_kernel = kernels[0]
  302. vm = self.get_vm()
  303. self.assertPropertyDefaultValue(vm, 'kernel', kernels[0])
  304. self.assertPropertyValue(vm, 'kernel', kernels[-1], kernels[-1],
  305. kernels[-1])
  306. del vm.kernel
  307. self.assertPropertyDefaultValue(vm, 'kernel', kernels[0])
  308. @qubes.tests.skipUnlessDom0
  309. def test_251_kernel_invalid(self):
  310. vm = self.get_vm()
  311. self.assertPropertyInvalidValue(vm, 'kernel', 123)
  312. self.assertPropertyInvalidValue(vm, 'kernel', 'invalid')
  313. def test_260_kernelopts(self):
  314. vm = self.get_vm()
  315. self.assertPropertyDefaultValue(vm, 'kernelopts',
  316. qubes.config.defaults['kernelopts'])
  317. self.assertPropertyValue(vm, 'kernelopts', 'some options',
  318. 'some options', 'some options')
  319. del vm.kernelopts
  320. self.assertPropertyDefaultValue(vm, 'kernelopts',
  321. qubes.config.defaults['kernelopts'])
  322. self.assertPropertyValue(vm, 'kernelopts', '',
  323. '', '')
  324. # TODO?
  325. # self.assertPropertyInvalidValue(vm, 'kernelopts', None),
  326. @unittest.skip('test not implemented')
  327. def test_261_kernelopts_pcidevs(self):
  328. vm = self.get_vm()
  329. # how to do that here? use dummy DeviceManager/DeviceCollection?
  330. # Disable events?
  331. vm.devices['pci'].attach('something')
  332. self.assertPropertyDefaultValue(vm, 'kernelopts',
  333. qubes.config.defaults['kernelopts_pcidevs'])
  334. def test_270_qrexec_timeout(self):
  335. vm = self.get_vm()
  336. self.assertPropertyDefaultValue(vm, 'qrexec_timeout', 60)
  337. self.assertPropertyValue(vm, 'qrexec_timeout', 3, 3, '3')
  338. del vm.qrexec_timeout
  339. self.assertPropertyDefaultValue(vm, 'qrexec_timeout', 60)
  340. self.assertPropertyValue(vm, 'qrexec_timeout', '3', 3, '3')
  341. def test_271_qrexec_timeout_invalid(self):
  342. vm = self.get_vm()
  343. self.assertPropertyInvalidValue(vm, 'qrexec_timeout', -2)
  344. self.assertPropertyInvalidValue(vm, 'qrexec_timeout', '-2')
  345. self.assertPropertyInvalidValue(vm, 'qrexec_timeout', '')
  346. def test_280_autostart(self):
  347. vm = self.get_vm()
  348. # FIXME any better idea to not involve systemctl call at this stage?
  349. vm.events_enabled = False
  350. self._test_generic_bool_property(vm, 'autostart', False)
  351. @qubes.tests.skipUnlessDom0
  352. def test_281_autostart_systemd(self):
  353. vm = self.get_vm()
  354. self.assertFalse(os.path.exists(
  355. '/etc/systemd/system/multi-user.target.wants/'
  356. 'qubes-vm@{}.service'.format(vm.name)),
  357. "systemd service enabled before setting autostart")
  358. vm.autostart = True
  359. self.assertTrue(os.path.exists(
  360. '/etc/systemd/system/multi-user.target.wants/'
  361. 'qubes-vm@{}.service'.format(vm.name)),
  362. "systemd service not enabled by autostart=True")
  363. vm.autostart = False
  364. self.assertFalse(os.path.exists(
  365. '/etc/systemd/system/multi-user.target.wants/'
  366. 'qubes-vm@{}.service'.format(vm.name)),
  367. "systemd service not disabled by autostart=False")
  368. vm.autostart = True
  369. del vm.autostart
  370. self.assertFalse(os.path.exists(
  371. '/etc/systemd/system/multi-user.target.wants/'
  372. 'qubes-vm@{}.service'.format(vm.name)),
  373. "systemd service not disabled by resetting autostart")
  374. @unittest.skip('TODO')
  375. def test_300_qrexec_installed(self):
  376. vm = self.get_vm()
  377. self._test_generic_bool_property(vm, 'qrexec_installed', True)
  378. @unittest.skip('TODO')
  379. def test_301_qrexec_installed_default(self):
  380. vm = self.get_vm()
  381. vm.hvm = False
  382. self.assertPropertyDefaultValue(vm, 'qrexec_installed', True)
  383. vm.hvm = True
  384. self.assertPropertyDefaultValue(vm, 'qrexec_installed', False)
  385. # TODO: check inheritance from a template - in appvm copy of this test
  386. @unittest.skip('TODO')
  387. def test_310_guiagent_installed(self):
  388. vm = self.get_vm()
  389. self._test_generic_bool_property(vm, 'guiagent_installed', True)
  390. # TODO: check inheritance from a template - in appvm copy of this test
  391. @unittest.skip('TODO')
  392. def test_311_guiagent_installed_default(self):
  393. vm = self.get_vm()
  394. vm.hvm = False
  395. self.assertPropertyDefaultValue(vm, 'guiagent_installed', True)
  396. vm.hvm = True
  397. self.assertPropertyDefaultValue(vm, 'guiagent_installed', False)
  398. # TODO: check inheritance from a template - in appvm copy of this test
  399. @unittest.skip('TODO')
  400. def test_320_seamless_gui_mode(self):
  401. vm = self.get_vm()
  402. self._test_generic_bool_property(vm, 'seamless_gui_mode')
  403. # TODO: reject setting to True when guiagent_installed is false
  404. def test_330_mac(self):
  405. vm = self.get_vm()
  406. # TODO: calculate proper default here
  407. default_mac = vm.mac
  408. self.assertIsNotNone(default_mac)
  409. self.assertPropertyDefaultValue(vm, 'mac', default_mac)
  410. self.assertPropertyValue(vm, 'mac', '00:11:22:33:44:55',
  411. '00:11:22:33:44:55', '00:11:22:33:44:55')
  412. del vm.mac
  413. self.assertPropertyDefaultValue(vm, 'mac', default_mac)
  414. def test_331_mac_invalid(self):
  415. vm = self.get_vm()
  416. self.assertPropertyInvalidValue(vm, 'mac', 123)
  417. self.assertPropertyInvalidValue(vm, 'mac', 'invalid')
  418. self.assertPropertyInvalidValue(vm, 'mac', '00:11:22:33:44:55:66')
  419. def test_340_default_user(self):
  420. vm = self.get_vm()
  421. self.assertPropertyDefaultValue(vm, 'default_user', 'user')
  422. self.assertPropertyValue(vm, 'default_user', 'someuser', 'someuser',
  423. 'someuser')
  424. del vm.default_user
  425. self.assertPropertyDefaultValue(vm, 'default_user', 'user')
  426. self.assertPropertyValue(vm, 'default_user', 123, '123', '123')
  427. # TODO: check propagation for template-based VMs
  428. @unittest.skip('TODO')
  429. def test_350_timezone(self):
  430. vm = self.get_vm()
  431. self.assertPropertyDefaultValue(vm, 'timezone', 'localtime')
  432. self.assertPropertyValue(vm, 'timezone', 0, 0, '0')
  433. del vm.timezone
  434. self.assertPropertyDefaultValue(vm, 'timezone', 'localtime')
  435. self.assertPropertyValue(vm, 'timezone', '0', 0, '0')
  436. self.assertPropertyValue(vm, 'timezone', -3600, -3600, '-3600')
  437. self.assertPropertyValue(vm, 'timezone', 7200, 7200, '7200')
  438. @unittest.skip('TODO')
  439. def test_350_timezone_invalid(self):
  440. vm = self.get_vm()
  441. self.assertPropertyInvalidValue(vm, 'timezone', 'xxx')
  442. @unittest.skip('TODO')
  443. def test_360_drive(self):
  444. vm = self.get_vm()
  445. self.assertPropertyDefaultValue(vm, 'drive', None)
  446. # self.execute_tests('drive', [
  447. # ('hd:dom0:/tmp/drive.img', 'hd:dom0:/tmp/drive.img', True),
  448. # ('hd:/tmp/drive.img', 'hd:dom0:/tmp/drive.img', True),
  449. # ('cdrom:dom0:/tmp/drive.img', 'cdrom:dom0:/tmp/drive.img', True),
  450. # ('cdrom:/tmp/drive.img', 'cdrom:dom0:/tmp/drive.img', True),
  451. # ('/tmp/drive.img', 'cdrom:dom0:/tmp/drive.img', True),
  452. # ('hd:drive.img', '', False),
  453. # ('drive.img', '', False),
  454. # ])
  455. @unittest.skip('TODO')
  456. def test_370_pci_strictreset(self):
  457. vm = self.get_vm()
  458. self._test_generic_bool_property(vm, 'pci_strictreset')
  459. def test_400_backup_timestamp(self):
  460. vm = self.get_vm()
  461. timestamp = datetime.datetime(2016, 1, 1, 12, 14, 2)
  462. timestamp_str = timestamp.strftime('%s')
  463. self.assertPropertyDefaultValue(vm, 'backup_timestamp', None)
  464. self.assertPropertyValue(vm, 'backup_timestamp', timestamp,
  465. timestamp, timestamp_str)
  466. del vm.backup_timestamp
  467. self.assertPropertyDefaultValue(vm, 'backup_timestamp', None)
  468. self.assertPropertyValue(vm, 'backup_timestamp', timestamp_str,
  469. timestamp)
  470. def test_401_backup_timestamp_invalid(self):
  471. vm = self.get_vm()
  472. self.assertPropertyInvalidValue(vm, 'backup_timestamp', 'xxx')
  473. self.assertPropertyInvalidValue(vm, 'backup_timestamp', None)