ia64/xen-unstable

view tools/xm-test/tests/block-integrity/01_block_device_read_verify.py @ 10114:9b11eeab4558

Add a read-verify block device test to xm-test.
author harry@localhost.localdomain
date Fri May 19 16:30:21 2006 +0100 (2006-05-19)
parents
children 5d4b9dc88218
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 initialises a ram disk in dom0 with data from /dev/urandom and
7 # then imports the ram disk device as a physical device into a domU. The md5
8 # checksum of the data in the ramdisk is calculated in dom0 and also
9 # calculated by the domU reading the data through the blk frontend and
10 # backend drivers. The test succeeds if the checksums match indicating that
11 # the domU successfully read all the correct data from the device.
13 import re
15 from XmTestLib import *
16 from XmTestLib.block_utils import *
18 if ENABLE_HVM_SUPPORT:
19 SKIP("Block-attach not supported for HVM domains")
21 domain = XmTestDomain()
23 try:
24 console = domain.start()
25 except DomainError, e:
26 FAIL(str(e))
28 console.setHistorySaveCmds(value=True)
30 traceCommand("cat /dev/urandom > /dev/ram1")
32 s, o = traceCommand("md5sum /dev/ram1")
34 dom0_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", o)
36 block_attach(domain, "phy:ram1", "hda1")
38 try:
39 run = console.runCmd("md5sum /dev/hda1")
40 except ConsoleError, e:
41 FAIL(str(e))
43 domU_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", run["output"])
45 domain.closeConsole()
47 domain.stop()
49 if dom0_md5sum_match == None:
50 FAIL("Failed to get md5sum of test ram disk in dom0.")
52 if domU_md5sum_match == None:
53 FAIL("Failed to get md5sum of test ram disk in domU.")
55 if verbose:
56 print "md5sum dom0:"
57 print dom0_md5sum_match.group()
58 print "md5sum domU:"
59 print domU_md5sum_match.group()
61 if dom0_md5sum_match.group() != domU_md5sum_match.group():
62 FAIL("MISCOMPARE: data read in domU did not match data provided by domO.")