From: Stefan Berger <stefanb@us.ibm.com>
To: xen-devel@lists.xensource.com
Cc: danms@us.ltcfwd.linux.ibm.com
Subject: [PATCH][xm-test] Repost of tpm driver suspend/resume test
Date: Tue, 14 Mar 2006 13:27:59 -0500 [thread overview]
Message-ID: <1142360879.5335.5.camel@localhost.localdomain> (raw)
[-- Attachment #1: Type: text/plain, Size: 346 bytes --]
This is a repost of a previously posted patch to test suspend and resume
cycles of the TPM front- and backend.
Now that sysfs is mounted in the RAM disk of the test environment, the
test code does not need to do this anymore. This patch also simplifies
previous tests and the APIs used there.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
[-- Attachment #2: xmtest_vtpm_suspres.diff --]
[-- Type: text/x-patch, Size: 7071 bytes --]
Index: xen/xen-unstable.hg/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py
===================================================================
--- /dev/null
+++ xen/xen-unstable.hg/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py
@@ -0,0 +1,120 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@us.ibm.com>
+
+# Positive Test: create domain with virtual TPM attached at build time,
+# check list of pcrs; suspend and resume the domain and
+# check list of pcrs again
+
+from XmTestLib import *
+import commands
+import os
+import os.path
+
+def vtpm_cleanup(domName):
+ # Since this is only a temporary domain I clean up the domain from the
+ # virtual TPM directory
+ os.system("/etc/xen/scripts/vtpm-delete %s" % domName)
+
+if ENABLE_HVM_SUPPORT:
+ SKIP("vtpm-list not supported for HVM domains")
+
+if os.path.exists("/dev/tpm0") == False:
+ SKIP("This machine has no hardware TPM; cannot run this test")
+
+output = commands.getoutput("ps aux | grep vtpm_manager | grep -v grep")
+if output == "":
+ FAIL("virtual TPM manager must be started to run this test")
+
+# vtpm manager has been detected
+config = {"vtpm":"instance=1,backend=0"}
+domain = XmTestDomain(extraConfig=config)
+
+try:
+ domain.start()
+except DomainError, e:
+ if verbose:
+ print e.extra
+ vtpm_cleanup(domain.getName())
+ FAIL("Unable to create domain")
+
+domName = domain.getName()
+
+try:
+ console = XmConsole(domain.getName())
+except ConsoleError, e:
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+
+try:
+ console.sendInput("input")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+
+try:
+ run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+
+if re.search("No such file",run["output"]):
+ FAIL("TPM frontend support not compiled into (domU?) kernel")
+
+console.closeConsole()
+
+try:
+ status, ouptut = traceCommand("xm save %s %s.save" %
+ (domName, domName),
+ timeout=30)
+except TimeoutError, e:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+
+if status != 0:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL("xm save did not succeed")
+
+try:
+ status, ouptut = traceCommand("xm restore %s.save" %
+ (domName),
+ timeout=30)
+except TimeoutError, e:
+ os.remove("%s.save" % domName)
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+
+os.remove("%s.save" % domName)
+
+if status != 0:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL("xm restore did not succeed")
+
+try:
+ console = XmConsole(domain.getName())
+except ConsoleError, e:
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+
+try:
+ run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+except ConsoleError, e:
+ saveLog(console.getHistory())
+ vtpm_cleanup(domName)
+ FAIL(str(e))
+
+console.closeConsole()
+
+domain.stop()
+
+vtpm_cleanup(domName)
+
+if not re.search("PCR-00:",run["output"]):
+ FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
Index: xen/xen-unstable.hg/tools/xm-test/tests/vtpm/Makefile.am
===================================================================
--- xen.orig/xen-unstable.hg/tools/xm-test/tests/vtpm/Makefile.am
+++ xen/xen-unstable.hg/tools/xm-test/tests/vtpm/Makefile.am
@@ -2,7 +2,8 @@
SUBDIRS =
TESTS = 01_vtpm-list_pos.test \
- 02_vtpm-cat_pcrs.test
+ 02_vtpm-cat_pcrs.test \
+ 03_vtpm-susp_res.test
XFAIL_TESTS =
Index: xen/xen-unstable.hg/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py
===================================================================
--- xen.orig/xen-unstable.hg/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py
+++ xen/xen-unstable.hg/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py
@@ -1,18 +1,20 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
-# Author: Stefan Berger <stefanb@us.ibm.com)
+# Author: Stefan Berger <stefanb@us.ibm.com>
# Positive Test: create domain with virtual TPM attached at build time,
# verify list
from XmTestLib import *
+import commands
+import os
def vtpm_cleanup(domName):
- # Since this is only a temporary domain I clean up the domain from the
- # virtual TPM directory
- traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
+ # Since this is only a temporary domain I clean up the domain from the
+ # virtual TPM directory
+ os.system("/etc/xen/scripts/vtpm-delete %s" % domName)
if ENABLE_HVM_SUPPORT:
SKIP("vtpm-list not supported for HVM domains")
Index: xen/xen-unstable.hg/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py
===================================================================
--- xen.orig/xen-unstable.hg/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py
+++ xen/xen-unstable.hg/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py
@@ -1,26 +1,28 @@
#!/usr/bin/python
# Copyright (C) International Business Machines Corp., 2006
-# Author: Stefan Berger <stefanb@us.ibm.com)
+# Author: Stefan Berger <stefanb@us.ibm.com>
# Positive Test: create domain with virtual TPM attached at build time,
# check list of pcrs
from XmTestLib import *
+import commands
+import os
+import os.path
def vtpm_cleanup(domName):
- # Since this is only a temporary domain I clean up the domain from the
- # virtual TPM directory
- traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
+ # Since this is only a temporary domain I clean up the domain from the
+ # virtual TPM directory
+ os.system("/etc/xen/scripts/vtpm-delete %s" % domName)
if ENABLE_HVM_SUPPORT:
SKIP("vtpm-list not supported for HVM domains")
-status, output = traceCommand("ls /dev/tpm0")
-if re.search("No such file or directory",output):
+if os.path.exists("/dev/tpm0") == False:
SKIP("This machine has no hardware TPM; cannot run this test")
-status, output = traceCommand("ps aux | grep vtpm_manager | grep -v grep")
+output = commands.getoutput("ps aux | grep vtpm_manager | grep -v grep")
if output == "":
FAIL("virtual TPM manager must be started to run this test")
@@ -46,21 +48,11 @@ except ConsoleError, e:
try:
console.sendInput("input")
- run = console.runCmd("ls /sys")
except ConsoleError, e:
saveLog(console.getHistory())
vtpm_cleanup(domName)
FAIL(str(e))
-if re.search("No such file",run["output"]):
- try:
- run = console.runCmd("mkdir /sys")
- run = console.runCmd("mount -t sysfs /sys /sys")
- except ConsoleError, e:
- saveLog(console.getHistory())
- vtpm_cleanup(domName)
- FAIL(str(e))
-
try:
run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
except ConsoleError, e:
[-- Attachment #3: Type: text/plain, Size: 138 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xensource.com
http://lists.xensource.com/xen-devel
next reply other threads:[~2006-03-14 18:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-14 18:27 Stefan Berger [this message]
2006-03-15 9:58 ` [PATCH][xm-test] Repost of tpm driver suspend/resume test Ewan Mellor
2006-03-15 15:14 ` Daniel Stekloff
2006-03-15 17:49 ` woody marvel
2006-03-15 15:56 ` Stefan Berger
-- strict thread matches above, loose matches on Subject: below --
2006-03-15 23:57 [PATCH] [xm-test] " Stefan Berger
2006-03-21 0:28 ` Ewan Mellor
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1142360879.5335.5.camel@localhost.localdomain \
--to=stefanb@us.ibm.com \
--cc=danms@us.ltcfwd.linux.ibm.com \
--cc=xen-devel@lists.xensource.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.