debuggers.hg

view tools/xm-test/tests/vtpm/03_vtpm-susp_res.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; suspend and resume the domain and
8 # check list of pcrs again
10 from XmTestLib import *
11 from vtpm_utils import *
12 import commands
13 import os
14 import os.path
15 import atexit
17 config = {"vtpm":"instance=1,backend=0"}
18 domain = XmTestDomain(extraConfig=config)
19 domName = domain.getName()
20 consoleHistory = ""
22 try:
23 console = domain.start()
24 except DomainError, e:
25 if verbose:
26 print e.extra
27 FAIL("Unable to create domain (%s)" % domName)
29 atexit.register(vtpm_cleanup, vtpm_get_uuid(domid(domName)))
31 try:
32 console.sendInput("input")
33 except ConsoleError, e:
34 saveLog(console.getHistory())
35 FAIL(str(e))
37 try:
38 run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
39 except ConsoleError, e:
40 saveLog(console.getHistory())
41 FAIL("No result from dumping the PCRs")
43 if re.search("No such file",run["output"]):
44 FAIL("TPM frontend support not compiled into (domU?) kernel")
46 consoleHistory = console.getHistory()
47 domain.closeConsole()
49 loop = 0
50 while loop < 3:
51 try:
52 status, ouptut = traceCommand("xm save %s %s.save" %
53 (domName, domName),
54 timeout=30)
56 except TimeoutError, e:
57 saveLog(consoleHistory)
58 FAIL(str(e))
60 if status != 0:
61 saveLog(consoleHistory)
62 FAIL("xm save did not succeed")
64 try:
65 status, ouptut = traceCommand("xm restore %s.save" %
66 (domName),
67 timeout=30)
68 except TimeoutError, e:
69 os.remove("%s.save" % domName)
70 saveLog(consoleHistory)
71 FAIL(str(e))
73 os.remove("%s.save" % domName)
75 if status != 0:
76 saveLog(consoleHistory)
77 FAIL("xm restore did not succeed")
79 try:
80 console = domain.getConsole()
81 except ConsoleError, e:
82 FAIL(str(e))
84 try:
85 run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
86 except ConsoleError, e:
87 saveLog(console.getHistory())
88 FAIL(str(e))
90 if not re.search("PCR-00:",run["output"]):
91 saveLog(console.getHistory())
92 FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
94 loop += 1
96 domain.closeConsole()
98 domain.stop()