[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [TPM] Add 3 more test cases to the xm testsuite that extend the



# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID d85488fd2196fb09c46cefb298f10577bb077aff
# Parent  e3ad9b9c95eedaa44144e97c34024ba902dca0bf
[TPM] Add 3 more test cases to the xm testsuite that extend the
state of a PCR register and test that the value remains the same during
a suspend/resume cycle and during live and non-live local migration. 
The patch adapts existing tests to the changes in the driver (moving of
the sysfs entry). Some problems with existing tests are fixed.

Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>
---
 tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py      |   11 -
 tools/xm-test/tests/vtpm/03_vtpm-susp_res.py      |   94 +++++++-------
 tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py      |   24 ++-
 tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py      |   24 ++-
 tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py |  139 ++++++++++++++++++++++
 tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py      |  132 ++++++++++++++++++++
 tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py      |  132 ++++++++++++++++++++
 tools/xm-test/tests/vtpm/Makefile.am              |    5 
 tools/xm-test/tests/vtpm/vtpm_utils.py            |    2 
 9 files changed, 489 insertions(+), 74 deletions(-)

diff -r e3ad9b9c95ee -r d85488fd2196 
tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py
--- a/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py      Wed Jun 28 16:21:30 
2006 +0100
+++ b/tools/xm-test/tests/vtpm/02_vtpm-cat_pcrs.py      Wed Jun 28 16:22:38 
2006 +0100
@@ -14,16 +14,15 @@ import os.path
 
 config = {"vtpm":"instance=1,backend=0"}
 domain = XmTestDomain(extraConfig=config)
+domName = domain.getName()
 
 try:
     console = domain.start()
 except DomainError, e:
     if verbose:
         print e.extra
-    vtpm_cleanup(domain.getName())
-    FAIL("Unable to create domain")
-
-domName = domain.getName()
+    vtpm_cleanup(domName)
+    FAIL("Unable to create domain (%s)" % domName)
 
 try:
     console.sendInput("input")
@@ -33,11 +32,11 @@ except ConsoleError, e:
     FAIL(str(e))
 
 try:
-    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
 except ConsoleError, e:
     saveLog(console.getHistory())
     vtpm_cleanup(domName)
-    FAIL(str(e))
+    FAIL("No result from dumping the PCRs")
 
 if re.search("No such file",run["output"]):
     vtpm_cleanup(domName)
diff -r e3ad9b9c95ee -r d85488fd2196 
tools/xm-test/tests/vtpm/03_vtpm-susp_res.py
--- a/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py      Wed Jun 28 16:21:30 
2006 +0100
+++ b/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py      Wed Jun 28 16:22:38 
2006 +0100
@@ -15,6 +15,7 @@ import os.path
 
 config = {"vtpm":"instance=1,backend=0"}
 domain = XmTestDomain(extraConfig=config)
+domName = domain.getName()
 consoleHistory = ""
 
 try:
@@ -22,10 +23,8 @@ except DomainError, e:
 except DomainError, e:
     if verbose:
         print e.extra
-    vtpm_cleanup(domain.getName())
-    FAIL("Unable to create domain")
-
-domName = domain.getName()
+    vtpm_cleanup(domName)
+    FAIL("Unable to create domain (%s)" % domName)
 
 try:
     console.sendInput("input")
@@ -35,11 +34,11 @@ except ConsoleError, e:
     FAIL(str(e))
 
 try:
-    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
 except ConsoleError, e:
     saveLog(console.getHistory())
     vtpm_cleanup(domName)
-    FAIL(str(e))
+    FAIL("No result from dumping the PCRs")
 
 if re.search("No such file",run["output"]):
     vtpm_cleanup(domName)
@@ -48,50 +47,59 @@ consoleHistory = console.getHistory()
 consoleHistory = console.getHistory()
 domain.closeConsole()
 
-try:
-    status, ouptut = traceCommand("xm save %s %s.save" %
-                                  (domName, domName),
-                                  timeout=30)
+loop = 0
+while loop < 3:
+    try:
+        status, ouptut = traceCommand("xm save %s %s.save" %
+                                      (domName, domName),
+                                      timeout=30)
 
-except TimeoutError, e:
-    saveLog(consoleHistory)
-    vtpm_cleanup(domName)
-    FAIL(str(e))
+    except TimeoutError, e:
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL(str(e))
 
-if status != 0:
-    saveLog(consoleHistory)
-    vtpm_cleanup(domName)
-    FAIL("xm save did not succeed")
+    if status != 0:
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL("xm save did not succeed")
 
-try:
-    status, ouptut = traceCommand("xm restore %s.save" %
-                                  (domName),
-                                  timeout=30)
-except TimeoutError, e:
+    try:
+        status, ouptut = traceCommand("xm restore %s.save" %
+                                      (domName),
+                                      timeout=30)
+    except TimeoutError, e:
+        os.remove("%s.save" % domName)
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL(str(e))
+
     os.remove("%s.save" % domName)
-    saveLog(consoleHistory)
-    vtpm_cleanup(domName)
-    FAIL(str(e))
 
-os.remove("%s.save" % domName)
+    if status != 0:
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL("xm restore did not succeed")
 
-if status != 0:
-    saveLog(consoleHistory)
-    vtpm_cleanup(domName)
-    FAIL("xm restore did not succeed")
+    try:
+        console = domain.getConsole()
+    except ConsoleError, e:
+        vtpm_cleanup(domName)
+        FAIL(str(e))
 
-try:
-    console = domain.getConsole()
-except ConsoleError, e:
-    vtpm_cleanup(domName)
-    FAIL(str(e))
+    try:
+        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
+    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 not re.search("PCR-00:",run["output"]):
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+       FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend 
side")
+
+    loop += 1
 
 domain.closeConsole()
 
@@ -99,5 +107,3 @@ 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")
diff -r e3ad9b9c95ee -r d85488fd2196 
tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py
--- a/tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py      Wed Jun 28 16:21:30 
2006 +0100
+++ b/tools/xm-test/tests/vtpm/04_vtpm-loc_migr.py      Wed Jun 28 16:22:38 
2006 +0100
@@ -16,6 +16,7 @@ import os.path
 
 config = {"vtpm":"instance=1,backend=0"}
 domain = XmTestDomain(extraConfig=config)
+domName = domain.getName()
 consoleHistory = ""
 
 try:
@@ -23,10 +24,8 @@ except DomainError, e:
 except DomainError, e:
     if verbose:
         print e.extra
-    vtpm_cleanup(domain.getName())
-    FAIL("Unable to create domain")
-
-domName = domain.getName()
+    vtpm_cleanup(domName)
+    FAIL("Unable to create domain (%s)" % domName)
 
 try:
     console.sendInput("input")
@@ -36,11 +35,11 @@ except ConsoleError, e:
     FAIL(str(e))
 
 try:
-    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
 except ConsoleError, e:
     saveLog(console.getHistory())
     vtpm_cleanup(domName)
-    FAIL(str(e))
+    FAIL("No result from dumping the PCRs")
 
 if re.search("No such file",run["output"]):
     vtpm_cleanup(domName)
@@ -83,11 +82,17 @@ while loop < 3:
         FAIL(str(e))
 
     try:
-        run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
     except ConsoleError, e:
         saveLog(console.getHistory())
         vtpm_cleanup(domName)
-        FAIL(str(e))
+        FAIL("No result from dumping the PCRs")
+
+    if not re.search("PCR-00:",run["output"]):
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+       FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend 
side")
+
     loop += 1
 
 domain.closeConsole()
@@ -95,6 +100,3 @@ domain.stop()
 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")
diff -r e3ad9b9c95ee -r d85488fd2196 
tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py
--- a/tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py      Wed Jun 28 16:21:30 
2006 +0100
+++ b/tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py      Wed Jun 28 16:22:38 
2006 +0100
@@ -16,6 +16,7 @@ import os.path
 
 config = {"vtpm":"instance=1,backend=0"}
 domain = XmTestDomain(extraConfig=config)
+domName = domain.getName()
 consoleHistory = ""
 
 try:
@@ -23,10 +24,8 @@ except DomainError, e:
 except DomainError, e:
     if verbose:
         print e.extra
-    vtpm_cleanup(domain.getName())
-    FAIL("Unable to create domain")
-
-domName = domain.getName()
+    vtpm_cleanup(domName)
+    FAIL("Unable to create domain (%s)" % domName)
 
 try:
     console.sendInput("input")
@@ -36,11 +35,11 @@ except ConsoleError, e:
     FAIL(str(e))
 
 try:
-    run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
 except ConsoleError, e:
     saveLog(console.getHistory())
     vtpm_cleanup(domName)
-    FAIL(str(e))
+    FAIL("No result from dumping the PCRs")
 
 if re.search("No such file",run["output"]):
     vtpm_cleanup(domName)
@@ -83,11 +82,17 @@ while loop < 3:
         FAIL(str(e))
 
     try:
-        run = console.runCmd("cat /sys/devices/platform/tpm_vtpm/pcrs")
+        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
     except ConsoleError, e:
         saveLog(console.getHistory())
         vtpm_cleanup(domName)
-        FAIL(str(e))
+        FAIL("No result from dumping the PCRs")
+
+    if not re.search("PCR-00:",run["output"]):
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+       FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend 
side")
+
     loop += 1
 
 domain.closeConsole()
@@ -95,6 +100,3 @@ domain.stop()
 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")
diff -r e3ad9b9c95ee -r d85488fd2196 tools/xm-test/tests/vtpm/Makefile.am
--- a/tools/xm-test/tests/vtpm/Makefile.am      Wed Jun 28 16:21:30 2006 +0100
+++ b/tools/xm-test/tests/vtpm/Makefile.am      Wed Jun 28 16:22:38 2006 +0100
@@ -4,7 +4,10 @@ TESTS = 01_vtpm-list_pos.test \
         02_vtpm-cat_pcrs.test \
         03_vtpm-susp_res.test \
         04_vtpm-loc_migr.test \
-        05_vtpm-loc_migr.test
+        05_vtpm-loc_migr.test \
+        06_vtpm-susp_res_pcrs.test \
+        07_vtpm-mig_pcrs.test \
+        08_vtpm-mig_pcrs.test
 
 XFAIL_TESTS =
 
diff -r e3ad9b9c95ee -r d85488fd2196 tools/xm-test/tests/vtpm/vtpm_utils.py
--- a/tools/xm-test/tests/vtpm/vtpm_utils.py    Wed Jun 28 16:21:30 2006 +0100
+++ b/tools/xm-test/tests/vtpm/vtpm_utils.py    Wed Jun 28 16:22:38 2006 +0100
@@ -16,4 +16,4 @@ if output == "":
     FAIL("virtual TPM manager must be started to run this test")
 
 def vtpm_cleanup(domName):
-       traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
+    traceCommand("/etc/xen/scripts/vtpm-delete %s" % domName)
diff -r e3ad9b9c95ee -r d85488fd2196 
tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/vtpm/06_vtpm-susp_res_pcrs.py Wed Jun 28 16:22:38 
2006 +0100
@@ -0,0 +1,139 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@xxxxxxxxxx>
+
+# Positive Test: create domain with virtual TPM attached at build time,
+#                extend a pcr
+#                check list of pcrs; suspend and resume the domain and
+#                check list of pcrs again and validate extended pcr
+
+from XmTestLib import *
+from vtpm_utils import *
+import commands
+import os
+import os.path
+
+config = {"vtpm":"instance=1,backend=0"}
+domain = XmTestDomain(extraConfig=config)
+domName = domain.getName()
+consoleHistory = ""
+
+try:
+    console = domain.start()
+except DomainError, e:
+    if verbose:
+        print e.extra
+    vtpm_cleanup(domName)
+    FAIL("Unable to create domain (%s)" % domName)
+
+try:
+    console.sendInput("input")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+try:
+    run = console.runCmd("mknod /dev/tpm0 c 10 224")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("Error while creating /dev/tpm0")
+
+try:
+    run = console.runCmd("echo -ne 
\"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\"
 > /dev/tpm0")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("Error while extending PCR 0")
+
+try:
+    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("No result from dumping the PCRs")
+
+
+if re.search("No such file",run["output"]):
+    vtpm_cleanup(domName)
+    FAIL("TPM frontend support not compiled into (domU?) kernel")
+
+if not re.search("PCR-00:",run["output"]):
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: 
\n%s" % run["output"])
+
+if not re.search("PCR-00: 1E A7 BD",run["output"]):
+    saveLog(console.getHistory())
+    FAIL("Extend did not lead to expected result (1E A7 BD ...): \n%s" % 
run["output"])
+
+consoleHistory = console.getHistory()
+domain.closeConsole()
+
+loop = 0
+while loop < 3:
+    try:
+        status, ouptut = traceCommand("xm save %s %s.save" %
+                                      (domName, domName),
+                                      timeout=30)
+
+    except TimeoutError, e:
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL(str(e))
+
+    if status != 0:
+        saveLog(consoleHistory)
+        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(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL(str(e))
+
+    os.remove("%s.save" % domName)
+
+    if status != 0:
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL("xm restore did not succeed")
+
+    try:
+        console = domain.getConsole()
+    except ConsoleError, e:
+        vtpm_cleanup(domName)
+        FAIL(str(e))
+
+    try:
+        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
+    except ConsoleError, e:
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+        FAIL(str(e))
+
+    if not re.search("PCR-00:",run["output"]):
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+       FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend 
side")
+
+    if not re.search("PCR-00: 1E A7 BD",run["output"]):
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+       FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])
+
+    loop += 1
+
+domain.closeConsole()
+
+domain.stop()
+
+vtpm_cleanup(domName)
+
diff -r e3ad9b9c95ee -r d85488fd2196 
tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/vtpm/07_vtpm-mig_pcrs.py      Wed Jun 28 16:22:38 
2006 +0100
@@ -0,0 +1,132 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@xxxxxxxxxx>
+
+# Positive Test: create domain with virtual TPM attached at build time,
+#                extend a pcr
+#                check list of pcrs; locally migrate the domain and
+#                check list of pcrs again and validate extended pcr
+#                This test does local live migration.
+
+from XmTestLib import *
+from vtpm_utils import *
+import commands
+import os
+import os.path
+
+config = {"vtpm":"instance=1,backend=0"}
+domain = XmTestDomain(extraConfig=config)
+domName = domain.getName()
+consoleHistory = ""
+
+try:
+    console = domain.start()
+except DomainError, e:
+    if verbose:
+        print e.extra
+    vtpm_cleanup(domName)
+    FAIL("Unable to create domain (%s)" % domName)
+
+try:
+    console.sendInput("input")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+try:
+    run = console.runCmd("mknod /dev/tpm0 c 10 224")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("Error while creating /dev/tpm0")
+
+try:
+    run = console.runCmd("echo -ne 
\"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\"
 > /dev/tpm0")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("Error while extending PCR 0")
+
+try:
+    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("No result from dumping the PCRs")
+
+
+if re.search("No such file",run["output"]):
+    vtpm_cleanup(domName)
+    FAIL("TPM frontend support not compiled into (domU?) kernel")
+
+if not re.search("PCR-00:",run["output"]):
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: 
\n%s" % run["output"])
+
+if not re.search("PCR-00: 1E A7 BD",run["output"]):
+    saveLog(console.getHistory())
+    FAIL("Extend did not lead to expected result (1E A7 BD ...): \n%s" % 
run["output"])
+
+consoleHistory = console.getHistory()
+domain.closeConsole()
+
+old_domid = domid(domName)
+
+loop = 0
+while loop < 3:
+    try:
+        status, ouptut = traceCommand("xm migrate -l %s localhost" %
+                                      domName,
+                                      timeout=90)
+    except TimeoutError, e:
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL(str(e))
+
+    if status != 0:
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL("xm migrate did not succeed. External device migration 
activated?")
+
+
+    domName = domain.getName()
+    new_domid = domid(domName)
+
+    if (old_domid == new_domid):
+        vtpm_cleanup(domName)
+        FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
+             (old_domid,loop))
+
+    try:
+        console = domain.getConsole()
+    except ConsoleError, e:
+        vtpm_cleanup(domName)
+        FAIL(str(e))
+
+    try:
+        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
+    except ConsoleError, e:
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+        FAIL("No result from dumping the PCRs")
+
+    if not re.search("PCR-00:",run["output"]):
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+       FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend 
side")
+
+    if not re.search("PCR-00: 1E A7 BD",run["output"]):
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+       FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])
+
+    loop += 1
+
+domain.closeConsole()
+
+domain.stop()
+
+vtpm_cleanup(domName)
diff -r e3ad9b9c95ee -r d85488fd2196 
tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/xm-test/tests/vtpm/08_vtpm-mig_pcrs.py      Wed Jun 28 16:22:38 
2006 +0100
@@ -0,0 +1,132 @@
+#!/usr/bin/python
+
+# Copyright (C) International Business Machines Corp., 2006
+# Author: Stefan Berger <stefanb@xxxxxxxxxx>
+
+# Positive Test: create domain with virtual TPM attached at build time,
+#                extend a pcr
+#                check list of pcrs; locally migrate the domain and
+#                check list of pcrs again and validate extended pcr
+#                This test does local (non-live) migration.
+
+from XmTestLib import *
+from vtpm_utils import *
+import commands
+import os
+import os.path
+
+config = {"vtpm":"instance=1,backend=0"}
+domain = XmTestDomain(extraConfig=config)
+domName = domain.getName()
+consoleHistory = ""
+
+try:
+    console = domain.start()
+except DomainError, e:
+    if verbose:
+        print e.extra
+    vtpm_cleanup(domName)
+    FAIL("Unable to create domain (%s)" % domName)
+
+try:
+    console.sendInput("input")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL(str(e))
+
+try:
+    run = console.runCmd("mknod /dev/tpm0 c 10 224")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("Error while creating /dev/tpm0")
+
+try:
+    run = console.runCmd("echo -ne 
\"\\x00\\xc1\\x00\\x00\\x00\\x22\\x00\\x00\\x00\\x14\\x00\\x00\\x00\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0a\\x0b\\x0c\\x0d\\x0e\\0xf\\x10\\x11\\x12\\x13\\x14\"
 > /dev/tpm0")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("Error while extending PCR 0")
+
+try:
+    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
+except ConsoleError, e:
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("No result from dumping the PCRs")
+
+
+if re.search("No such file",run["output"]):
+    vtpm_cleanup(domName)
+    FAIL("TPM frontend support not compiled into (domU?) kernel")
+
+if not re.search("PCR-00:",run["output"]):
+    saveLog(console.getHistory())
+    vtpm_cleanup(domName)
+    FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side: 
\n%s" % run["output"])
+
+if not re.search("PCR-00: 1E A7 BD",run["output"]):
+    saveLog(console.getHistory())
+    FAIL("Extend did not lead to expected result (1E A7 BD ...): \n%s" % 
run["output"])
+
+consoleHistory = console.getHistory()
+domain.closeConsole()
+
+old_domid = domid(domName)
+
+loop = 0
+while loop < 3:
+    try:
+        status, ouptut = traceCommand("xm migrate %s localhost" %
+                                      domName,
+                                      timeout=90)
+    except TimeoutError, e:
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL(str(e))
+
+    if status != 0:
+        saveLog(consoleHistory)
+        vtpm_cleanup(domName)
+        FAIL("xm migrate did not succeed. External device migration 
activated?")
+
+
+    domName = domain.getName()
+    new_domid = domid(domName)
+
+    if (old_domid == new_domid):
+        vtpm_cleanup(domName)
+        FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
+             (old_domid,loop))
+
+    try:
+        console = domain.getConsole()
+    except ConsoleError, e:
+        vtpm_cleanup(domName)
+        FAIL(str(e))
+
+    try:
+        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
+    except ConsoleError, e:
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+        FAIL("No result from dumping the PCRs")
+
+    if not re.search("PCR-00:",run["output"]):
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+       FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend 
side")
+
+    if not re.search("PCR-00: 1E A7 BD",run["output"]):
+        saveLog(console.getHistory())
+        vtpm_cleanup(domName)
+       FAIL("Virtual TPM lost PCR 0 value: \n%s" % run["output"])
+
+    loop += 1
+
+domain.closeConsole()
+
+domain.stop()
+
+vtpm_cleanup(domName)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.