ia64/xen-unstable

view tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py @ 7893:74d4d3be6b0a

Added a test to verify that devices come and go from block-list
as they are block-attach'd and block-detach'd.
author dan@guaranine.beaverton.ibm.com
date Fri Nov 18 13:02:01 2005 +0100 (2005-11-18)
parents
children 9981fa5ba62b
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2005
4 # Author: Dan Smith <danms@us.ibm.com>
6 from XmTestLib import *
8 domain = XmTestDomain()
10 try:
11 domain.start()
12 except DomainError, e:
13 FAIL(str(e))
15 try:
16 console = XmConsole(domain.getName())
17 except ConsoleError, e:
18 FAIL(str(e))
20 s, o = traceCommand("xm block-list %s" % domain.getName())
21 if s != 0:
22 FAIL("block-list returned !0 when no devices attached")
23 if o:
24 FAIL("block-list without devices reported something!")
26 s, o = traceCommand("xm block-attach %s phy:/dev/ram0 hda1 w" % domain.getName())
27 if s != 0:
28 FAIL("Unable to attach /dev/ram0->hda1")
30 s, o = traceCommand("xm block-list %s" % domain.getName())
31 if s != 0:
32 FAIL("block-list failed")
33 if not o.find("769"):
34 FAIL("block-list didn't show the block device I just attached!")
36 s, o = traceCommand("xm block-attach %s phy:/dev/ram1 hda2 w" % domain.getName())
37 if s != 0:
38 FAIL("Unable to attach /dev/ram1->hda2")
40 s, o = traceCommand("xm block-list %s" % domain.getName())
41 if s != 0:
42 FAIL("block-list failed")
43 if not o.find("770"):
44 FAIL("block-list didn't show the other block device I just attached!")
46 s, o = traceCommand("xm block-detach %s 769" % domain.getName())
47 if s != 0:
48 FAIL("block-destroy of hda1 failed")
50 s, o = traceCommand("xm block-list %s" % domain.getName())
51 if s != 0:
52 FAIL("block-list failed after detaching a device")
53 if o.find("769"):
54 FAIL("hda1 still shown in block-list after detach!")
55 if not o.find("770"):
56 FAIL("hda2 not shown after detach of hda1!")
58 s, o = traceCommand("xm block-detach %s 770" % domain.getName())
59 if s != 0:
60 FAIL("block-list failed after detaching another device")
61 if o.find("770"):
62 FAIL("hda2 still shown in block-list after detach!")
63 if o:
64 FAIL("block-list still shows something after all devices detached!")