~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to tools/xm-test/tests/block-create/04_block_attach_device_repeatedly_pos.py

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
# Copyright (C) International Business Machines Corp., 2005
 
4
# Author: Murillo F. Bernardes <mfb@br.ibm.com>
 
5
 
 
6
import re
 
7
 
 
8
from XmTestLib import *
 
9
 
 
10
if ENABLE_HVM_SUPPORT:
 
11
    SKIP("Block-attach not supported for HVM domains")
 
12
 
 
13
# Create a domain (default XmTestDomain, with our ramdisk)
 
14
domain = XmTestDomain()
 
15
 
 
16
try:
 
17
    console = domain.start()
 
18
except DomainError, e:
 
19
    if verbose:
 
20
        print "Failed to create test domain because:"
 
21
        print e.extra
 
22
    FAIL(str(e))
 
23
 
 
24
try:
 
25
    console.setHistorySaveCmds(value=True)
 
26
    # Run 'ls'
 
27
    run = console.runCmd("ls")
 
28
except ConsoleError, e:
 
29
    saveLog(console.getHistory())
 
30
    FAIL(str(e))
 
31
    
 
32
for i in range(10):
 
33
    status, output = traceCommand("xm block-attach %s phy:ram1 xvda1 w" % domain.getName())
 
34
    if i == 0 and status != 0:
 
35
        FAIL("xm block attach returned invalid %i != 0" % status)
 
36
    if i > 0 and status == 0:
 
37
        FAIL("xm block-attach (repeat) returned invalid %i > 0" % status)
 
38
    run = console.runCmd("cat /proc/partitions")
 
39
    if not re.search("xvda1", run['output']):
 
40
        FAIL("Device is not actually attached to domU")
 
41
 
 
42
# Close the console
 
43
domain.closeConsole()
 
44
 
 
45
# Stop the domain (nice shutdown)
 
46
domain.stop()