~ubuntu-branches/ubuntu/quantal/virtinst/quantal-proposed

« back to all changes in this revision

Viewing changes to tests/capabilities.py

  • Committer: Bazaar Package Importer
  • Author(s): Soren Hansen
  • Date: 2007-11-20 13:40:28 UTC
  • Revision ID: james.westby@ubuntu.com-20071120134028-rg0pjby0jc4mycks
Tags: upstream-0.300.1+hg20071120
ImportĀ upstreamĀ versionĀ 0.300.1+hg20071120

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
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.
 
6
#
 
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.
 
11
#
 
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,
 
15
# MA 02110-1301 USA.
 
16
 
 
17
import os.path
 
18
import unittest
 
19
import virtinst.CapabilitiesParser as capabilities
 
20
 
 
21
class TestCapabilities(unittest.TestCase):
 
22
 
 
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)
 
27
        for n in features:
 
28
            self.assertEqual(features[n],        guest.features[n])
 
29
 
 
30
    def _testCapabilities(self, path, (host_arch, host_features), guests):
 
31
        caps = capabilities.parse(file(os.path.join("tests", path)).read())
 
32
 
 
33
        self.assertEqual(host_arch,     caps.host.arch)
 
34
        for n in host_features:
 
35
            self.assertEqual(host_features[n], caps.host.features[n])
 
36
 
 
37
        map(self._compareGuest, guests, caps.guests)
 
38
 
 
39
    def testCapabilities1(self):
 
40
        host = ( 'x86_64', {'vmx': capabilities.FEATURE_ON} )
 
41
 
 
42
        guests = [
 
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', {} )
 
47
        ]
 
48
 
 
49
        self._testCapabilities("capabilities-xen.xml", host, guests)
 
50
 
 
51
    def testCapabilities2(self):
 
52
        host = ( 'x86_64', {} )
 
53
 
 
54
        guests = [
 
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', {} ),
 
61
        ]
 
62
 
 
63
        self._testCapabilities("capabilities-qemu.xml", host, guests)
 
64
 
 
65
    def testCapabilities3(self):
 
66
        host = ( 'i686', { 'pae': capabilities.FEATURE_ON|capabilities.FEATURE_OFF } )
 
67
 
 
68
        guests = [
 
69
            ( 'i686', 'linux', 'test', { 'pae': capabilities.FEATURE_ON|capabilities.FEATURE_OFF } ),
 
70
        ]
 
71
 
 
72
        self._testCapabilities("capabilities-test.xml", host, guests)
 
73
 
 
74
if __name__ == "__main__":
 
75
    unittest.main()