ia64/xen-unstable

view tools/xm-test/tests/block-create/09_block_attach_and_dettach_device_check_data_pos.py @ 7753:fb4f48f0116e

Tweak the usage of mke2fs to be quiet, so that the XML reports
contain less garbage
author dan@guaranine.beaverton.ibm.com
date Thu Nov 10 11:47:38 2005 +0100 (2005-11-10)
parents ecb5997f7b25
children 30f54abf9592
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2005
4 # Author: Murillo F. Bernardes <mfb@br.ibm.com>
6 import sys
7 import re
8 import time
10 from XmTestLib import *
13 # Create a domain (default XmTestDomain, with our ramdisk)
14 domain = XmTestDomain()
16 try:
17 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))
24 # Attach a console to it
25 try:
26 console = XmConsole(domain.getName(), historySaveCmds=True)
27 except ConsoleError, e:
28 FAIL(str(e))
30 try:
31 # Activate the console
32 console.sendInput("input")
33 # Run 'ls'
34 run = console.runCmd("ls")
35 except ConsoleError, e:
36 saveLog(console.getHistory())
37 FAIL(str(e))
39 s, o = traceCommand("mke2fs -q -F /dev/ram1")
40 if s != 0:
41 FAIL("mke2fs returned %i != 0" % s)
43 for i in range(10):
44 status, output = traceCommand("xm block-attach %s phy:ram1 hda1 w" % domain.getName())
45 if status != 0:
46 FAIL("xm block-attach returned invalid %i != 0" % status)
47 # verify that it comes
48 run = console.runCmd("cat /proc/partitions")
49 if not re.search("hda1", run["output"]):
50 FAIL("Failed to attach block device: /proc/partitions does not show that!")
52 console.runCmd("mkdir -p /mnt/hda1; mount /dev/hda1 /mnt/hda1")
54 if i:
55 run = console.runCmd("cat /mnt/hda1/myfile | grep %s" % (i-1))
56 if run['return']:
57 FAIL("File created was lost or not updated!")
59 console.runCmd("echo \"%s\" > /mnt/hda1/myfile" % i)
60 run = console.runCmd("cat /mnt/hda1/myfile")
61 print run['output']
62 console.runCmd("umount /mnt/hda1")
64 status, output = traceCommand("xm block-detach %s 769" % domain.getName())
65 if status != 0:
66 FAIL("xm block-detach returned invalid %i != 0" % status)
67 # verify that it goes
68 run = console.runCmd("cat /proc/partitions")
69 if re.search("hda1", run["output"]):
70 FAIL("Failed to dettach block device: /proc/partitions still showing that!")
72 # Close the console
73 console.closeConsole()
75 # Stop the domain (nice shutdown)
76 domain.stop()