adminvm.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #!/usr/bin/python2 -O
  2. # vim: fileencoding=utf-8
  3. #
  4. # The Qubes OS Project, https://www.qubes-os.org/
  5. #
  6. # Copyright (C) 2014-2015 Joanna Rutkowska <joanna@invisiblethingslab.com>
  7. # Copyright (C) 2014-2015 Wojtek Porczyk <woju@invisiblethingslab.com>
  8. #
  9. # This program is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation; either version 2 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This program is distributed in the hope that it will be useful,
  15. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. # GNU General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License along
  20. # with this program; if not, write to the Free Software Foundation, Inc.,
  21. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. #
  23. import unittest
  24. import qubes
  25. import qubes.exc
  26. import qubes.vm
  27. import qubes.vm.adminvm
  28. import qubes.tests
  29. @qubes.tests.skipUnlessDom0
  30. class TC_00_AdminVM(qubes.tests.QubesTestCase):
  31. def setUp(self):
  32. try:
  33. self.app = qubes.tests.vm.TestApp()
  34. self.vm = qubes.vm.adminvm.AdminVM(self.app,
  35. xml=None, qid=0, name='dom0')
  36. except: # pylint: disable=bare-except
  37. if self.id().endswith('.test_000_init'):
  38. raise
  39. self.skipTest('setup failed')
  40. def test_000_init(self):
  41. pass
  42. def test_100_xid(self):
  43. self.assertEqual(self.vm.xid, 0)
  44. def test_101_libvirt_domain(self):
  45. self.assertIs(self.vm.libvirt_domain, None)
  46. def test_200_libvirt_netvm(self):
  47. self.assertIs(self.vm.netvm, None)
  48. def test_300_is_running(self):
  49. self.assertTrue(self.vm.is_running())
  50. def test_301_get_power_state(self):
  51. self.assertEqual(self.vm.get_power_state(), 'Running')
  52. def test_302_get_mem(self):
  53. self.assertGreater(self.vm.get_mem(), 0)
  54. @unittest.skip('mock object does not support this')
  55. def test_303_get_mem_static_max(self):
  56. self.assertGreater(self.vm.get_mem_static_max(), 0)
  57. def test_304_get_disk_utilization(self):
  58. self.assertEqual(self.vm.get_disk_utilization(), 0)
  59. def test_305_get_disk_utilization_private_img(self):
  60. # pylint: disable=invalid-name
  61. self.assertEqual(self.vm.get_disk_utilization_private_img(), 0)
  62. def test_306_get_private_img_sz(self):
  63. self.assertEqual(self.vm.get_private_img_sz(), 0)
  64. def test_307_verify_files(self):
  65. self.assertEqual(self.vm.get_private_img_sz(), 0)
  66. def test_310_start(self):
  67. with self.assertRaises(qubes.exc.QubesException):
  68. self.vm.start()
  69. @unittest.skip('this functionality is undecided')
  70. def test_311_suspend(self):
  71. with self.assertRaises(qubes.exc.QubesException):
  72. self.vm.suspend()