ia64/xen-unstable

changeset 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 d02fd103cbc6
children 7209244ea3d1
files tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py tools/xm-test/tests/block-list/Makefile.am
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/xm-test/tests/block-list/06_block-list_checkremove_pos.py	Fri Nov 18 13:02:01 2005 +0100
     1.3 @@ -0,0 +1,66 @@
     1.4 +#!/usr/bin/python
     1.5 +
     1.6 +# Copyright (C) International Business Machines Corp., 2005
     1.7 +# Author: Dan Smith <danms@us.ibm.com>
     1.8 +
     1.9 +from XmTestLib import *
    1.10 +
    1.11 +domain = XmTestDomain()
    1.12 +
    1.13 +try:
    1.14 +    domain.start()
    1.15 +except DomainError, e:
    1.16 +    FAIL(str(e))
    1.17 +
    1.18 +try:
    1.19 +    console = XmConsole(domain.getName())
    1.20 +except ConsoleError, e:
    1.21 +    FAIL(str(e))
    1.22 +
    1.23 +s, o = traceCommand("xm block-list %s" % domain.getName())
    1.24 +if s != 0:
    1.25 +    FAIL("block-list returned !0 when no devices attached")
    1.26 +if o:
    1.27 +    FAIL("block-list without devices reported something!")
    1.28 +
    1.29 +s, o = traceCommand("xm block-attach %s phy:/dev/ram0 hda1 w" % domain.getName())
    1.30 +if s != 0:
    1.31 +    FAIL("Unable to attach /dev/ram0->hda1")
    1.32 +
    1.33 +s, o = traceCommand("xm block-list %s" % domain.getName())
    1.34 +if s != 0:
    1.35 +    FAIL("block-list failed")
    1.36 +if not o.find("769"):
    1.37 +    FAIL("block-list didn't show the block device I just attached!")
    1.38 +
    1.39 +s, o = traceCommand("xm block-attach %s phy:/dev/ram1 hda2 w" % domain.getName())
    1.40 +if s != 0:
    1.41 +    FAIL("Unable to attach /dev/ram1->hda2")
    1.42 +
    1.43 +s, o = traceCommand("xm block-list %s" % domain.getName())
    1.44 +if s != 0:
    1.45 +    FAIL("block-list failed")
    1.46 +if not o.find("770"):
    1.47 +    FAIL("block-list didn't show the other block device I just attached!")
    1.48 +
    1.49 +s, o = traceCommand("xm block-detach %s 769" % domain.getName())
    1.50 +if s != 0:
    1.51 +    FAIL("block-destroy of hda1 failed")
    1.52 +
    1.53 +s, o = traceCommand("xm block-list %s" % domain.getName())
    1.54 +if s != 0:
    1.55 +    FAIL("block-list failed after detaching a device")
    1.56 +if o.find("769"):
    1.57 +    FAIL("hda1 still shown in block-list after detach!")
    1.58 +if not o.find("770"):
    1.59 +    FAIL("hda2 not shown after detach of hda1!")
    1.60 +
    1.61 +s, o = traceCommand("xm block-detach %s 770" % domain.getName())
    1.62 +if s != 0:
    1.63 +    FAIL("block-list failed after detaching another device")
    1.64 +if o.find("770"):
    1.65 +    FAIL("hda2 still shown in block-list after detach!")
    1.66 +if o:
    1.67 +    FAIL("block-list still shows something after all devices detached!")
    1.68 +    
    1.69 +
     2.1 --- a/tools/xm-test/tests/block-list/Makefile.am	Fri Nov 18 13:01:30 2005 +0100
     2.2 +++ b/tools/xm-test/tests/block-list/Makefile.am	Fri Nov 18 13:02:01 2005 +0100
     2.3 @@ -5,7 +5,8 @@ TESTS =	01_block-list_pos.test 	\
     2.4  	02_block-list_attachbd_pos.test \
     2.5  	03_block-list_anotherbd_pos.test \
     2.6  	04_block-list_nodb_pos.test \
     2.7 -	05_block-list_nonexist_neg.test
     2.8 +	05_block-list_nonexist_neg.test \
     2.9 +	06_block-list_checkremove_pos.test
    2.10  
    2.11  XFAIL_TESTS = 
    2.12