source: trunk/packages/xen-3.1/xen-3.1/tools/xm-test/tests/block-integrity/01_block_device_read_verify.py @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

  • Property svn:mime-type set to text/script
File size: 1.7 KB
Line 
1#!/usr/bin/python
2
3# Copyright (C) International Business Machines Corp., 2006
4# Author: Harry Butterworth <butterwo@uk.ibm.com>
5
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.
12
13import re
14
15from XmTestLib import *
16from XmTestLib.block_utils import *
17
18if ENABLE_HVM_SUPPORT:
19    SKIP("Block-attach not supported for HVM domains")
20
21domain = XmTestDomain()
22
23try:
24    console = domain.start()
25except DomainError, e:
26    FAIL(str(e))
27
28console.setHistorySaveCmds(value=True)
29
30traceCommand("cat /dev/urandom > /dev/ram1")
31
32s, o = traceCommand("md5sum /dev/ram1")
33
34dom0_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", o, re.M)
35
36block_attach(domain, "phy:ram1", "xvda1")
37
38try:
39    run = console.runCmd("md5sum /dev/xvda1")
40except ConsoleError, e:
41    FAIL(str(e))
42
43domU_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", run["output"], re.M)
44
45domain.closeConsole()
46
47domain.stop()
48
49if dom0_md5sum_match == None:
50    FAIL("Failed to get md5sum of test ram disk in dom0.")
51
52if domU_md5sum_match == None:
53    FAIL("Failed to get md5sum of test ram disk in domU.")
54
55if verbose:
56    print "md5sum dom0:"
57    print dom0_md5sum_match.group()
58    print "md5sum domU:"
59    print domU_md5sum_match.group()
60
61if dom0_md5sum_match.group() != domU_md5sum_match.group():
62    FAIL("MISCOMPARE: data read in domU did not match data provided by domO.")
Note: See TracBrowser for help on using the repository browser.