aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xm-test/tests/vtpm/01_vtpm-list_pos.py
blob: a427bf2fdebe409dc6c5b66849d229bd5ebccf0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/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,
#                verify list


from XmTestLib import *
from vtpm_utils import *
import commands
import os

config = {"vtpm":"instance=1,backend=0"}
domain = XmTestDomain(extraConfig=config)

try:
    domain.start(noConsole=True)
except DomainError, e:
    if verbose:
        print e.extra
    vtpm_cleanup(domain.getName())
    FAIL("Unable to create domain")

domName = domain.getName()

status, output = traceCommand("xm vtpm-list %s" % domain.getId())
eyecatcher = "/local/domain/0/backend/vtpm"
where = output.find(eyecatcher)
if status != 0:
    vtpm_cleanup(domName)
    FAIL("xm vtpm-list returned bad status, expected 0, status is %i" % status)
elif where < 0:
    vtpm_cleanup(domName)
    FAIL("Fail to list virtual TPM device")

domain.stop()

vtpm_cleanup(domName)