ia64/xen-unstable

view tools/python/xen/xend/tests/test_XendConfig.py @ 13609:959e79bfe913

Fix device reordering that occurs when the config gets read into dictionaries.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author Ewan Mellor <ewan@xensource.com>
date Wed Jan 24 16:48:41 2007 +0000 (2007-01-24)
parents
children
line source
1 import unittest
3 import xen.xend.XendConfig as XendConfig
6 class test_XendConfig(unittest.TestCase):
8 def testParseFromSXP(self):
9 cfg = XendConfig.XendConfig(
10 sxp_obj = (
11 ['vm',
12 ['bootloader_args', '-q --default_args="root=/dev/sda1 ro" --extra_args="quiet" /images/VM1.sda'],
13 ['bootloader', '/usr/bin/pygrub'],
14 ['device', ['vif', ['mac', '00:16:3E:4C:D1:00'], ['script', 'vif-bridge'], ['bridge', 'xenbr0']]],
15 ['device', ['vif', ['mac', '00:16:3E:48:56:26'], ['script', 'vif-bridge'], ['bridge', 'vbridge0']]],
16 ['device', ['vbd', ['uname', 'phy:/images/VM1.sda'], ['dev', 'sda'], ['mode', 'w']]],
17 ['device', ['vbd', ['uname', 'phy:/images/VM1.sdb'], ['dev', 'sdb'], ['mode', 'w']]],
18 ['memory', '256'], ['name', 'VM1'], ['on_crash', 'restart'],
19 ['uuid', '10927a76-fe27-49b2-8f57-2970b7bbed6c'], ['vcpus', '1']
20 ]))
22 self.assertEqual(cfg['uuid'], '10927a76-fe27-49b2-8f57-2970b7bbed6c')
23 self.assertEqual(cfg['name_label'], 'VM1')
24 self.assertEqual(cfg['memory_static_max'], 256)
26 ordered_refs = cfg.ordered_device_refs()
27 self.assertEqual(cfg['devices'][ordered_refs[0]][0], 'vbd')
28 self.assertEqual(cfg['devices'][ordered_refs[1]][0], 'vbd')
29 self.assertEqual(cfg['devices'][ordered_refs[2]][0], 'vif')
30 self.assertEqual(cfg['devices'][ordered_refs[3]][0], 'vif')
31 self.assertEqual(cfg['devices'][ordered_refs[0]][1]['uname'],
32 'phy:/images/VM1.sda')
33 self.assertEqual(cfg['devices'][ordered_refs[1]][1]['uname'],
34 'phy:/images/VM1.sdb')
35 self.assertEqual(cfg['devices'][ordered_refs[2]][1]['mac'],
36 '00:16:3E:4C:D1:00')
37 self.assertEqual(cfg['devices'][ordered_refs[3]][1]['mac'],
38 '00:16:3E:48:56:26')
41 def test_suite():
42 return unittest.makeSuite(test_XendConfig)