2
# This program is free software; you can redistribute it and/or modify
3
# it under the terms of the GNU General Public License as published by
4
# the Free Software Foundation; either version 2 of the License, or
5
# (at your option) any later version.
7
# This program is distributed in the hope that it will be useful,
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
# GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License
13
# along with this program; if not, write to the Free Software
14
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
import virtinst.CapabilitiesParser as capabilities
21
class TestCapabilities(unittest.TestCase):
23
def _compareGuest(self, (arch, os_type, hypervisor_type, features), guest):
24
self.assertEqual(arch, guest.arch)
25
self.assertEqual(os_type, guest.os_type)
26
self.assertEqual(hypervisor_type, guest.hypervisor_type)
28
self.assertEqual(features[n], guest.features[n])
30
def _testCapabilities(self, path, (host_arch, host_features), guests):
31
caps = capabilities.parse(file(os.path.join("tests", path)).read())
33
self.assertEqual(host_arch, caps.host.arch)
34
for n in host_features:
35
self.assertEqual(host_features[n], caps.host.features[n])
37
map(self._compareGuest, guests, caps.guests)
39
def testCapabilities1(self):
40
host = ( 'x86_64', {'vmx': capabilities.FEATURE_ON} )
43
( 'x86_64', 'xen', 'xen', {} ),
44
( 'i686', 'xen', 'xen', { 'pae': capabilities.FEATURE_ON } ),
45
( 'i686', 'hvm', 'xen', { 'pae': capabilities.FEATURE_ON|capabilities.FEATURE_OFF } ),
46
( 'x86_64', 'hvm', 'xen', {} )
49
self._testCapabilities("capabilities-xen.xml", host, guests)
51
def testCapabilities2(self):
52
host = ( 'x86_64', {} )
55
( 'x86_64', 'hvm', 'qemu', {} ),
56
( 'i686', 'hvm', 'qemu', {} ),
57
( 'mips', 'hvm', 'qemu', {} ),
58
( 'mipsel', 'hvm', 'qemu', {} ),
59
( 'sparc', 'hvm', 'qemu', {} ),
60
( 'ppc', 'hvm', 'qemu', {} ),
63
self._testCapabilities("capabilities-qemu.xml", host, guests)
65
def testCapabilities3(self):
66
host = ( 'i686', { 'pae': capabilities.FEATURE_ON|capabilities.FEATURE_OFF } )
69
( 'i686', 'linux', 'test', { 'pae': capabilities.FEATURE_ON|capabilities.FEATURE_OFF } ),
72
self._testCapabilities("capabilities-test.xml", host, guests)
74
if __name__ == "__main__":