ia64/xen-unstable

changeset 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 224e9878c6d4
children 852a1fd80f42 ae0175bf0631
files tools/xm-test/configure.ac tools/xm-test/tests/Makefile.am tools/xm-test/tests/block-integrity/01_block_device_read_verify.py tools/xm-test/tests/block-integrity/Makefile.am
line diff
     1.1 --- a/tools/xm-test/configure.ac	Fri May 19 16:29:34 2006 +0100
     1.2 +++ b/tools/xm-test/configure.ac	Fri May 19 16:30:21 2006 +0100
     1.3 @@ -99,6 +99,7 @@ AC_CONFIG_FILES([
     1.4      tests/block-list/Makefile
     1.5      tests/block-create/Makefile
     1.6      tests/block-destroy/Makefile
     1.7 +    tests/block-integrity/Makefile
     1.8      tests/console/Makefile
     1.9      tests/create/Makefile
    1.10      tests/destroy/Makefile
     2.1 --- a/tools/xm-test/tests/Makefile.am	Fri May 19 16:29:34 2006 +0100
     2.2 +++ b/tools/xm-test/tests/Makefile.am	Fri May 19 16:30:21 2006 +0100
     2.3 @@ -1,14 +1,15 @@
     2.4  SUBDIRS = 	               	\
     2.5  		block-create	\
     2.6 -	  	block-list	\
     2.7 -                block-destroy   \
     2.8 +		block-list	\
     2.9 +		block-destroy   \
    2.10 +		block-integrity \
    2.11  		console		\
    2.12  		create 		\
    2.13  		destroy		\
    2.14  		dmesg		\
    2.15  		domid		\
    2.16  		domname		\
    2.17 -	 	help		\
    2.18 +		help		\
    2.19  		info		\
    2.20  		list		\
    2.21  		memmax		\
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/tools/xm-test/tests/block-integrity/01_block_device_read_verify.py	Fri May 19 16:30:21 2006 +0100
     3.3 @@ -0,0 +1,62 @@
     3.4 +#!/usr/bin/python
     3.5 +
     3.6 +# Copyright (C) International Business Machines Corp., 2006
     3.7 +# Author: Harry Butterworth <butterwo@uk.ibm.com>
     3.8 +
     3.9 +# This test initialises a ram disk in dom0 with data from /dev/urandom and
    3.10 +# then imports the ram disk device as a physical device into a domU. The md5
    3.11 +# checksum of the data in the ramdisk is calculated in dom0 and also
    3.12 +# calculated by the domU reading the data through the blk frontend and
    3.13 +# backend drivers.  The test succeeds if the checksums match indicating that
    3.14 +# the domU successfully read all the correct data from the device.
    3.15 +
    3.16 +import re
    3.17 +
    3.18 +from XmTestLib import *
    3.19 +from XmTestLib.block_utils import *
    3.20 +
    3.21 +if ENABLE_HVM_SUPPORT:
    3.22 +    SKIP("Block-attach not supported for HVM domains")
    3.23 +
    3.24 +domain = XmTestDomain()
    3.25 +
    3.26 +try:
    3.27 +    console = domain.start()
    3.28 +except DomainError, e:
    3.29 +    FAIL(str(e))
    3.30 +
    3.31 +console.setHistorySaveCmds(value=True)
    3.32 +
    3.33 +traceCommand("cat /dev/urandom > /dev/ram1")
    3.34 +
    3.35 +s, o = traceCommand("md5sum /dev/ram1")
    3.36 +
    3.37 +dom0_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", o)
    3.38 +
    3.39 +block_attach(domain, "phy:ram1", "hda1")
    3.40 +
    3.41 +try:
    3.42 +    run = console.runCmd("md5sum /dev/hda1")
    3.43 +except ConsoleError, e:
    3.44 +    FAIL(str(e))
    3.45 +
    3.46 +domU_md5sum_match = re.search(r"^[\dA-Fa-f]{32}", run["output"])
    3.47 +
    3.48 +domain.closeConsole()
    3.49 +
    3.50 +domain.stop()
    3.51 +
    3.52 +if dom0_md5sum_match == None:
    3.53 +    FAIL("Failed to get md5sum of test ram disk in dom0.")
    3.54 +
    3.55 +if domU_md5sum_match == None:
    3.56 +    FAIL("Failed to get md5sum of test ram disk in domU.")
    3.57 +
    3.58 +if verbose:
    3.59 +    print "md5sum dom0:"
    3.60 +    print dom0_md5sum_match.group()
    3.61 +    print "md5sum domU:"
    3.62 +    print domU_md5sum_match.group()
    3.63 +
    3.64 +if dom0_md5sum_match.group() != domU_md5sum_match.group():
    3.65 +    FAIL("MISCOMPARE: data read in domU did not match data provided by domO.")
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/tools/xm-test/tests/block-integrity/Makefile.am	Fri May 19 16:30:21 2006 +0100
     4.3 @@ -0,0 +1,21 @@
     4.4 +
     4.5 +SUBDIRS =
     4.6 +
     4.7 +TESTS = 01_block_device_read_verify.test
     4.8 +
     4.9 +XFAIL_TESTS = 
    4.10 +
    4.11 +EXTRA_DIST = $(TESTS) $(XFAIL_TESTS)
    4.12 +
    4.13 +TESTS_ENVIRONMENT=@TENV@
    4.14 +
    4.15 +%.test: %.py
    4.16 +	cp $< $@
    4.17 +	chmod +x $@
    4.18 +
    4.19 +clean-local: am_config_clean-local
    4.20 +
    4.21 +am_config_clean-local:
    4.22 +	rm -f *test
    4.23 +	rm -f *log
    4.24 +	rm -f *~