ia64/xen-unstable

view tools/xm-test/tests/block-integrity/02_block_device_write_verify.py @ 19615:13a4f4e6d0a3

x86 hvm: Correctly emulate task switches into vm86 mode.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue May 19 02:12:04 2009 +0100 (2009-05-19)
parents 52732dd77150
children
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2006
4 # Author: Harry Butterworth <butterwo@uk.ibm.com>
6 # This test imports a ram disk device as a physical device into a domU.
7 # The domU initialises the ram disk with data from /dev/urandom and calculates
8 # the md5 checksum of the data (using tee as it is written so as to avoid
9 # reading it back from the device which might potentially mask problems).
10 # The domU is stopped and the md5 checksum of the data on the device is
11 # calculated by dom0. The test succeeds if the checksums match, indicating
12 # that all the data written by domU was sucessfully committed to the device.
14 import re
16 from XmTestLib import *
17 from XmTestLib.block_utils import *
19 if ENABLE_HVM_SUPPORT:
20 SKIP("Block-attach not supported for HVM domains")
22 domain = XmTestDomain()
24 try:
25 console = domain.start()
26 except DomainError, e:
27 FAIL(str(e))
29 console.setHistorySaveCmds(value=True)
31 block_attach(domain, "phy:ram1", "xvda1")
33 console.setTimeout(120)
35 try:
36 run = console.runCmd("dd if=/dev/urandom bs=512 count=`cat /sys/block/xvda1/size` | tee /dev/xvda1 | md5sum")
37 except ConsoleError, e:
38 FAIL(str(e))
40 domU_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", run["output"], re.M)
42 domain.closeConsole()
44 domain.stop()
46 s, o = traceCommand("md5sum /dev/ram1")
48 dom0_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", o, re.M)
50 if domU_md5sum_match == None:
51 FAIL("Failed to get md5sum of data written in domU.")
53 if dom0_md5sum_match == None:
54 FAIL("Failed to get md5sum of data read back in dom0.")
56 if verbose:
57 print "md5sum domU:"
58 print domU_md5sum_match.group()
59 print "md5sum dom0:"
60 print dom0_md5sum_match.group()
62 if domU_md5sum_match.group() != dom0_md5sum_match.group():
63 FAIL("MISCOMPARE: data read in dom0 did not match data written by domU.")