source: trunk/packages/xen-3.1/xen-3.1/tools/xm-test/tests/vtpm/03_vtpm-susp_res.py @ 34

Last change on this file since 34 was 34, checked in by hartmans, 18 years ago

Add xen and xen-common

  • Property svn:mime-type set to text/script
File size: 2.7 KB
Line 
1#!/usr/bin/python
2
3# Copyright (C) International Business Machines Corp., 2006
4# Author: Stefan Berger <stefanb@us.ibm.com>
5
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
9
10from XmTestLib import *
11from vtpm_utils import *
12import commands
13import os
14import os.path
15
16config = {"vtpm":"instance=1,backend=0"}
17domain = XmTestDomain(extraConfig=config)
18domName = domain.getName()
19consoleHistory = ""
20
21try:
22    console = domain.start()
23except DomainError, e:
24    if verbose:
25        print e.extra
26    vtpm_cleanup(domName)
27    FAIL("Unable to create domain (%s)" % domName)
28
29try:
30    console.sendInput("input")
31except ConsoleError, e:
32    saveLog(console.getHistory())
33    vtpm_cleanup(domName)
34    FAIL(str(e))
35
36try:
37    run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
38except ConsoleError, e:
39    saveLog(console.getHistory())
40    vtpm_cleanup(domName)
41    FAIL("No result from dumping the PCRs")
42
43if re.search("No such file",run["output"]):
44    vtpm_cleanup(domName)
45    FAIL("TPM frontend support not compiled into (domU?) kernel")
46
47consoleHistory = console.getHistory()
48domain.closeConsole()
49
50loop = 0
51while loop < 3:
52    try:
53        status, ouptut = traceCommand("xm save %s %s.save" %
54                                      (domName, domName),
55                                      timeout=30)
56
57    except TimeoutError, e:
58        saveLog(consoleHistory)
59        vtpm_cleanup(domName)
60        FAIL(str(e))
61
62    if status != 0:
63        saveLog(consoleHistory)
64        vtpm_cleanup(domName)
65        FAIL("xm save did not succeed")
66
67    try:
68        status, ouptut = traceCommand("xm restore %s.save" %
69                                      (domName),
70                                      timeout=30)
71    except TimeoutError, e:
72        os.remove("%s.save" % domName)
73        saveLog(consoleHistory)
74        vtpm_cleanup(domName)
75        FAIL(str(e))
76
77    os.remove("%s.save" % domName)
78
79    if status != 0:
80        saveLog(consoleHistory)
81        vtpm_cleanup(domName)
82        FAIL("xm restore did not succeed")
83
84    try:
85        console = domain.getConsole()
86    except ConsoleError, e:
87        vtpm_cleanup(domName)
88        FAIL(str(e))
89
90    try:
91        run = console.runCmd("cat /sys/devices/xen/vtpm-0/pcrs")
92    except ConsoleError, e:
93        saveLog(console.getHistory())
94        vtpm_cleanup(domName)
95        FAIL(str(e))
96
97    if not re.search("PCR-00:",run["output"]):
98        saveLog(console.getHistory())
99        vtpm_cleanup(domName)
100        FAIL("Virtual TPM is not working correctly on /dev/vtpm on backend side")
101
102    loop += 1
103
104domain.closeConsole()
105
106domain.stop()
107
108vtpm_cleanup(domName)
109
Note: See TracBrowser for help on using the repository browser.