ia64/xen-unstable

changeset 9352:25e1c3b1a9f2

Put 03_vtpm-susp_res.py in its rightful place.

Signed-off-by: Ewan Mellor <ewan@xensource.com>
author emellor@leeni.uk.xensource.com
date Tue Mar 21 09:53:00 2006 +0100 (2006-03-21)
parents e36f95b43bf1
children eb2a2529f96c
files tools/xm-test/tests/vtpm/03_vtpm-susp_res.py
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py	Tue Mar 21 09:53:00 2006 +0100
     1.3 @@ -0,0 +1,120 @@
     1.4 +#!/usr/bin/python
     1.5 +
     1.6 +# Copyright (C) International Business Machines Corp., 2006
     1.7 +# Author: Stefan Berger <stefanb@us.ibm.com>
     1.8 +
     1.9 +# Positive Test: create domain with virtual TPM attached at build time,
    1.10 +#                check list of pcrs; suspend and resume the domain and
    1.11 +#                check list of pcrs again
    1.12 +
    1.13 +from XmTestLib import *
    1.14 +import commands
    1.15 +import os
    1.16 +import os.path
    1.17 +
    1.18 +def vtpm_cleanup(domName):
    1.19 +    # Since this is only a temporary domain I clean up the domain from the
    1.20 +    # virtual TPM directory
    1.21 +    os.system("/etc/xen/scripts/vtpm-delete %s" % domName)
    1.22 +
    1.23 +if ENABLE_HVM_SUPPORT:
    1.24 +    SKIP("vtpm-list not supported for HVM domains")
    1.25 +
    1.26 +if os.path.exists("/dev/tpm0") == False:
    1.27 +    SKIP("This machine has no hardware TPM; cannot run this test")
    1.28 +
    1.29 +output = commands.getoutput("ps aux | grep vtpm_manager | grep -v grep")
    1.30 +if output == "":
    1.31 +    SKIP("virtual TPM manager must be started to run this test")
    1.32 +
    1.33 +# vtpm manager has been detected
    1.34 +config = {"vtpm":"instance=1,backend=0"}
    1.35 +domain = XmTestDomain(extraConfig=config)
    1.36 +
    1.37 +try:
    1.38 +    domain.start()
    1.39 +except DomainError, e:
    1.40 +    if verbose:
    1.41 +        print e.extra
    1.42 +    vtpm_cleanup(domain.getName())
    1.43 +    FAIL("Unable to create domain")
    1.44 +
    1.45 +domName = domain.getName()
    1.46 +
    1.47 +try:
    1.48 +    console = XmConsole(domain.getName())
    1.49 +except ConsoleError, e:
    1.50 +    vtpm_cleanup(domName)
    1.51 +    FAIL(str(e))
    1.52 +
    1.53 +try:
    1.54 +    console.sendInput("input")
    1.55 +except ConsoleError, e:
    1.56 +    saveLog(console.getHistory())
    1.57 +    vtpm_cleanup(domName)
    1.58 +    FAIL(str(e))
    1.59 +
    1.60 +try:
    1.61 +    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    1.62 +except ConsoleError, e:
    1.63 +    saveLog(console.getHistory())
    1.64 +    vtpm_cleanup(domName)
    1.65 +    FAIL(str(e))
    1.66 +
    1.67 +if re.search("No such file",run["output"]):
    1.68 +    FAIL("TPM frontend support not compiled into (domU?) kernel")
    1.69 +
    1.70 +console.closeConsole()
    1.71 +
    1.72 +try:
    1.73 +    status, ouptut = traceCommand("xm save %s %s.save" %
    1.74 +                                  (domName, domName),
    1.75 +                                  timeout=30)
    1.76 +except TimeoutError, e:
    1.77 +    saveLog(console.getHistory())
    1.78 +    vtpm_cleanup(domName)
    1.79 +    FAIL(str(e))
    1.80 +
    1.81 +if status != 0:
    1.82 +    saveLog(console.getHistory())
    1.83 +    vtpm_cleanup(domName)
    1.84 +    FAIL("xm save did not succeed")
    1.85 +
    1.86 +try:
    1.87 +    status, ouptut = traceCommand("xm restore %s.save" %
    1.88 +                                  (domName),
    1.89 +                                  timeout=30)
    1.90 +except TimeoutError, e:
    1.91 +    os.remove("%s.save" % domName)
    1.92 +    saveLog(console.getHistory())
    1.93 +    vtpm_cleanup(domName)
    1.94 +    FAIL(str(e))
    1.95 +
    1.96 +os.remove("%s.save" % domName)
    1.97 +
    1.98 +if status != 0:
    1.99 +    saveLog(console.getHistory())
   1.100 +    vtpm_cleanup(domName)
   1.101 +    FAIL("xm restore did not succeed")
   1.102 +
   1.103 +try:
   1.104 +    console = XmConsole(domain.getName())
   1.105 +except ConsoleError, e:
   1.106 +    vtpm_cleanup(domName)
   1.107 +    FAIL(str(e))
   1.108 +
   1.109 +try:
   1.110 +    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
   1.111 +except ConsoleError, e:
   1.112 +    saveLog(console.getHistory())
   1.113 +    vtpm_cleanup(domName)
   1.114 +    FAIL(str(e))
   1.115 +
   1.116 +console.closeConsole()
   1.117 +
   1.118 +domain.stop()
   1.119 +
   1.120 +vtpm_cleanup(domName)
   1.121 +
   1.122 +if not re.search("PCR-00:",run["output"]):
   1.123 +	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
     2.1 --- a/xen-unstable.hg/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py	Tue Mar 21 01:28:29 2006 +0100
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,120 +0,0 @@
     2.4 -#!/usr/bin/python
     2.5 -
     2.6 -# Copyright (C) International Business Machines Corp., 2006
     2.7 -# Author: Stefan Berger <stefanb@us.ibm.com>
     2.8 -
     2.9 -# Positive Test: create domain with virtual TPM attached at build time,
    2.10 -#                check list of pcrs; suspend and resume the domain and
    2.11 -#                check list of pcrs again
    2.12 -
    2.13 -from XmTestLib import *
    2.14 -import commands
    2.15 -import os
    2.16 -import os.path
    2.17 -
    2.18 -def vtpm_cleanup(domName):
    2.19 -    # Since this is only a temporary domain I clean up the domain from the
    2.20 -    # virtual TPM directory
    2.21 -    os.system("/etc/xen/scripts/vtpm-delete %s" % domName)
    2.22 -
    2.23 -if ENABLE_HVM_SUPPORT:
    2.24 -    SKIP("vtpm-list not supported for HVM domains")
    2.25 -
    2.26 -if os.path.exists("/dev/tpm0") == False:
    2.27 -    SKIP("This machine has no hardware TPM; cannot run this test")
    2.28 -
    2.29 -output = commands.getoutput("ps aux | grep vtpm_manager | grep -v grep")
    2.30 -if output == "":
    2.31 -    SKIP("virtual TPM manager must be started to run this test")
    2.32 -
    2.33 -# vtpm manager has been detected
    2.34 -config = {"vtpm":"instance=1,backend=0"}
    2.35 -domain = XmTestDomain(extraConfig=config)
    2.36 -
    2.37 -try:
    2.38 -    domain.start()
    2.39 -except DomainError, e:
    2.40 -    if verbose:
    2.41 -        print e.extra
    2.42 -    vtpm_cleanup(domain.getName())
    2.43 -    FAIL("Unable to create domain")
    2.44 -
    2.45 -domName = domain.getName()
    2.46 -
    2.47 -try:
    2.48 -    console = XmConsole(domain.getName())
    2.49 -except ConsoleError, e:
    2.50 -    vtpm_cleanup(domName)
    2.51 -    FAIL(str(e))
    2.52 -
    2.53 -try:
    2.54 -    console.sendInput("input")
    2.55 -except ConsoleError, e:
    2.56 -    saveLog(console.getHistory())
    2.57 -    vtpm_cleanup(domName)
    2.58 -    FAIL(str(e))
    2.59 -
    2.60 -try:
    2.61 -    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
    2.62 -except ConsoleError, e:
    2.63 -    saveLog(console.getHistory())
    2.64 -    vtpm_cleanup(domName)
    2.65 -    FAIL(str(e))
    2.66 -
    2.67 -if re.search("No such file",run["output"]):
    2.68 -    FAIL("TPM frontend support not compiled into (domU?) kernel")
    2.69 -
    2.70 -console.closeConsole()
    2.71 -
    2.72 -try:
    2.73 -    status, ouptut = traceCommand("xm save %s %s.save" %
    2.74 -                                  (domName, domName),
    2.75 -                                  timeout=30)
    2.76 -except TimeoutError, e:
    2.77 -    saveLog(console.getHistory())
    2.78 -    vtpm_cleanup(domName)
    2.79 -    FAIL(str(e))
    2.80 -
    2.81 -if status != 0:
    2.82 -    saveLog(console.getHistory())
    2.83 -    vtpm_cleanup(domName)
    2.84 -    FAIL("xm save did not succeed")
    2.85 -
    2.86 -try:
    2.87 -    status, ouptut = traceCommand("xm restore %s.save" %
    2.88 -                                  (domName),
    2.89 -                                  timeout=30)
    2.90 -except TimeoutError, e:
    2.91 -    os.remove("%s.save" % domName)
    2.92 -    saveLog(console.getHistory())
    2.93 -    vtpm_cleanup(domName)
    2.94 -    FAIL(str(e))
    2.95 -
    2.96 -os.remove("%s.save" % domName)
    2.97 -
    2.98 -if status != 0:
    2.99 -    saveLog(console.getHistory())
   2.100 -    vtpm_cleanup(domName)
   2.101 -    FAIL("xm restore did not succeed")
   2.102 -
   2.103 -try:
   2.104 -    console = XmConsole(domain.getName())
   2.105 -except ConsoleError, e:
   2.106 -    vtpm_cleanup(domName)
   2.107 -    FAIL(str(e))
   2.108 -
   2.109 -try:
   2.110 -    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
   2.111 -except ConsoleError, e:
   2.112 -    saveLog(console.getHistory())
   2.113 -    vtpm_cleanup(domName)
   2.114 -    FAIL(str(e))
   2.115 -
   2.116 -console.closeConsole()
   2.117 -
   2.118 -domain.stop()
   2.119 -
   2.120 -vtpm_cleanup(domName)
   2.121 -
   2.122 -if not re.search("PCR-00:",run["output"]):
   2.123 -	FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")