diff options
author | Ewan Mellor <ewan@xensource.com> | 2006-12-01 17:37:09 +0000 |
---|---|---|
committer | Ewan Mellor <ewan@xensource.com> | 2006-12-01 17:37:09 +0000 |
commit | cebaab7c6b90391742eafd652c4aebc59f0e9052 (patch) | |
tree | 5898eda3895ffd1890b47a6f93d5c212e78cd02b /tools/xm-test/tests | |
parent | c88422678e521f8a27260a2d5cffa0594c9fb300 (diff) | |
download | xen-cebaab7c6b90391742eafd652c4aebc59f0e9052.tar.gz xen-cebaab7c6b90391742eafd652c4aebc59f0e9052.tar.bz2 xen-cebaab7c6b90391742eafd652c4aebc59f0e9052.zip |
This patch provides XmTestManagedDomain and XenManagedDomain classes
similar to the XmTestDomain and XenDomain classes. I have wrapped the
xen-api for VM configuration creation, starting and stopping of VMs and
destruction of the VM configuration in the XenManagedDomain class's
methods. No device-related functions are provided through the class.
The managed domains' UUIDs are tracked and all created VMs are destroyed
upon failure or skipping of the test or by calling
xapi.vm_destroy_all().
I am adding a new grouptest 'xapi' for running xen-api tests.
Only caveat: I am using an empty username and password
(XmTestList/xapi.py) with Xend's authentication deactivated to run these
tests.
Signed-off-by: Stefan Berger <stefanb@us.ibm.com>
Diffstat (limited to 'tools/xm-test/tests')
-rw-r--r-- | tools/xm-test/tests/vtpm/09_vtpm-xapi.py | 76 | ||||
-rw-r--r-- | tools/xm-test/tests/vtpm/Makefile.am | 3 |
2 files changed, 78 insertions, 1 deletions
diff --git a/tools/xm-test/tests/vtpm/09_vtpm-xapi.py b/tools/xm-test/tests/vtpm/09_vtpm-xapi.py new file mode 100644 index 0000000000..8547a08b03 --- /dev/null +++ b/tools/xm-test/tests/vtpm/09_vtpm-xapi.py @@ -0,0 +1,76 @@ +#!/usr/bin/python + +# Copyright (C) International Business Machines Corp., 2006 +# Author: Stefan Berger <stefanb@us.ibm.com> + +# Test to test the vtpm class through the Xen-API + +from XmTestLib import xapi +from XmTestLib.XenManagedDomain import XmTestManagedDomain +from XmTestLib import * +from vtpm_utils import * +import commands +import os + +def do_test(): + domain = XmTestManagedDomain() + vm_uuid = domain.get_uuid() + + vtpmcfg = {} + vtpmcfg['type'] = "paravirtualised" + vtpmcfg['backend'] = "Domain-0" + vtpmcfg['instance'] = 1 + vtpmcfg['VM'] = vm_uuid + + server, session = xapi._connect() + + vtpm_uuid = xapi.execute(server.VTPM.create, session, vtpmcfg) + + vtpm_id = xapi.execute(server.VTPM.get_instance, session, vtpm_uuid) + vtpm_be = xapi.execute(server.VTPM.get_backend , session, vtpm_uuid) + if vtpm_be != vtpmcfg['backend']: + FAIL("vTPM's backend is in '%s', expected: '%s'" % + (vtpm_be, vtpmcfg['backend'])) + + driver = xapi.execute(server.VTPM.get_driver, session, vtpm_uuid) + if driver != vtpmcfg['type']: + FAIL("vTPM has driver type '%s', expected: '%s'" % + (driver, vtpmcfg['type'])) + + vtpm_rec = xapi.execute(server.VTPM.get_record, session, vtpm_uuid) + + if vtpm_rec['driver'] != vtpmcfg['type']: + FAIL("vTPM record shows driver type '%s', expected: '%s'" % + (vtpm_rec['driver'], vtpmcfg['type'])) + if vtpm_rec['uuid'] != vtpm_uuid: + FAIL("vTPM record shows vtpm uuid '%s', expected: '%s'" % + (vtpm_rec['uuid'], vtpm_uuid)) + if vtpm_rec['VM'] != vm_uuid: + FAIL("vTPM record shows VM uuid '%s', expected: '%s'" % + (vtpm_rec['VM'], vm_uuid)) + + success = domain.start() + + console = domain.getConsole() + + 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") + + domain.stop() + domain.destroy() + + + +try: + do_test() +finally: + #Make sure all domains are gone that were created in this test case + xapi.vm_destroy_all() diff --git a/tools/xm-test/tests/vtpm/Makefile.am b/tools/xm-test/tests/vtpm/Makefile.am index d6aae0c15b..dd67e459ec 100644 --- a/tools/xm-test/tests/vtpm/Makefile.am +++ b/tools/xm-test/tests/vtpm/Makefile.am @@ -7,7 +7,8 @@ TESTS = 01_vtpm-list_pos.test \ 05_vtpm-loc_migr.test \ 06_vtpm-susp_res_pcrs.test \ 07_vtpm-mig_pcrs.test \ - 08_vtpm-mig_pcrs.test + 08_vtpm-mig_pcrs.test \ + 09_vtpm-xapi.test XFAIL_TESTS = |