debuggers.hg

view tools/xm-test/tests/vtpm/05_vtpm-loc_migr.py @ 0:7d21f7218375

Exact replica of unstable on 051908 + README-this
author Mukesh Rathor
date Mon May 19 15:34:57 2008 -0700 (2008-05-19)
parents
children
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2006
4 # Author: Stefan Berger <stefanb@us.ibm.com>
6 # Positive Test: create domain with virtual TPM attached at build time,
7 # check list of pcrs; locally migrate the domain and
8 # check list of pcrs again
9 # This test does local (non-live) migration.
11 from XmTestLib import *
12 from vtpm_utils import *
13 import commands
14 import os
15 import os.path
16 import atexit
18 config = {"vtpm":"instance=1,backend=0"}
19 domain = XmTestDomain(extraConfig=config)
20 domName = domain.getName()
21 consoleHistory = ""
23 try:
24 console = domain.start()
25 except DomainError, e:
26 if verbose:
27 print e.extra
28 FAIL("Unable to create domain (%s)" % domName)
30 atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))
32 try:
33 console.sendInput("input")
34 except ConsoleError, e:
35 saveLog(console.getHistory())
36 FAIL(str(e))
38 try:
39 run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
40 except ConsoleError, e:
41 saveLog(console.getHistory())
42 FAIL("No result from dumping the PCRs")
44 if re.search("No such file",run["output"]):
45 FAIL("TPM frontend support not compiled into (domU?) kernel")
47 consoleHistory = console.getHistory()
48 domain.closeConsole()
50 old_domid = domid(domName)
52 loop = 0
53 while loop < 3:
54 try:
55 status, ouptut = traceCommand("xm migrate %s localhost" %
56 domName,
57 timeout=90)
58 except TimeoutError, e:
59 saveLog(consoleHistory)
60 FAIL(str(e))
62 if status != 0:
63 saveLog(consoleHistory)
64 FAIL("xm migrate did not succeed. External device migration activated?")
67 domName = domain.getName()
68 new_domid = domid(domName)
70 if (old_domid == new_domid):
71 FAIL("xm migrate failed, domain id is still %s (loop=%d)" %
72 (old_domid,loop))
74 try:
75 console = domain.getConsole()
76 except ConsoleError, e:
77 FAIL(str(e))
79 try:
80 run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
81 except ConsoleError, e:
82 saveLog(console.getHistory())
83 FAIL("No result from dumping the PCRs")
85 if not re.search("PCR-00:",run["output"]):
86 saveLog(console.getHistory())
87 FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
89 loop += 1
91 domain.closeConsole()
93 domain.stop()