cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# $Id$
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# pylint: disable=C0302
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox Specific base testdriver.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__copyright__ = \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCopyright (C) 2010-2014 Oracle Corporation
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncavailable from http://www.virtualbox.org. This file is free software;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncGeneral Public License (GPL) as published by the Free Software
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncThe contents of this file may alternatively be used under the terms
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncof the Common Development and Distribution License Version 1.0
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox OSE distribution, in which case the provisions of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCDDL are applicable instead of those of the GPL.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncYou may elect to license modified versions of this file under the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncterms and conditions of either the GPL or the CDDL or both.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync"""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__version__ = "$Revision$"
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Standard Python imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport os
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport platform
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport sys
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport threading
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport time
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport traceback
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncimport datetime
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Figure out where the validation kit lives and make sure it's in the path.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsynctry: __file__
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncexcept: __file__ = sys.argv[0];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncg_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncif g_ksValidationKitDir not in sys.path:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sys.path.append(g_ksValidationKitDir);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Validation Kit imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom common import utils;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver import base;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver import reporter;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver import vboxcon;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncfrom testdriver import vboxtestvms;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Exception and Error Unification Hacks.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Note! This is pretty gross stuff. Be warned!
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# TODO: Find better ways of doing these things, preferrably in vboxapi.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncComException = None; # pylint: disable=C0103
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync__fnComExceptionGetAttr__ = None; # pylint: disable=C0103
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef __MyDefaultGetAttr(oSelf, sName):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ __getattribute__/__getattr__ default fake."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = oSelf.__dict__[sName];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = dir(oSelf)[sName];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oAttr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef __MyComExceptionGetAttr(oSelf, sName):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ ComException.__getattr__ wrapper - both XPCOM and COM. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = __fnComExceptionGetAttr__(oSelf, sName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except AttributeError:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if platform.system() == 'Windows':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sName == 'errno':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = __fnComExceptionGetAttr__(oSelf, 'hresult');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sName == 'msg':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = __fnComExceptionGetAttr__(oSelf, 'strerror');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sName == 'hresult':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = __fnComExceptionGetAttr__(oSelf, 'errno');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sName == 'strerror':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = __fnComExceptionGetAttr__(oSelf, 'msg');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sName == 'excepinfo':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sName == 'argerror':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #print '__MyComExceptionGetAttr(,%s) -> "%s"' % (sName, oAttr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oAttr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef __deployExceptionHacks__(oNativeComExceptionClass):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Deploys the exception and error hacks that helps unifying COM and XPCOM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync exceptions and errors.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync global ComException # pylint: disable=C0103
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync global __fnComExceptionGetAttr__ # pylint: disable=C0103
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Hook up our attribute getter for the exception class (ASSUMES new-style).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if __fnComExceptionGetAttr__ is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync __fnComExceptionGetAttr__ = getattr(oNativeComExceptionClass, '__getattr__');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync __fnComExceptionGetAttr__ = getattr(oNativeComExceptionClass, '__getattribute__');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync __fnComExceptionGetAttr__ = __MyDefaultGetAttr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync setattr(oNativeComExceptionClass, '__getattr__', __MyComExceptionGetAttr)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Make the modified classes accessible (are there better ways to do this?)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComException = oNativeComExceptionClass
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Utility functions.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef isIpAddrValid(sIpAddr):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if a IPv4 address looks valid. This will return false for
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync localhost and similar.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sIpAddr is None: return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if len(sIpAddr.split('.')) != 4: return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sIpAddr.endswith('.0'): return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sIpAddr.endswith('.255'): return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sIpAddr.startswith('127.'): return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sIpAddr.startswith('169.254.'): return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sIpAddr.startswith('192.0.2.'): return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sIpAddr.startswith('224.0.0.'): return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef stringifyErrorInfo(oErrInfo):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Stringifies the error information in a IVirtualBoxErrorInfo object.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns string with error info.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync rc = oErrInfo.resultCode;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sText = oErrInfo.text;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sIid = oErrInfo.interfaceID;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sComponent = oErrInfo.component;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sRet = 'bad error object (%s)?' % (oErrInfo,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync traceback.print_exc();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sRet = 'rc=%s text="%s" IID=%s component=%s' % (ComError.toString(rc), sText, sIid, sComponent);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sRet;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef reportError(oErr, sText):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Report a VirtualBox error on oErr. oErr can be IVirtualBoxErrorInfo
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or IProgress. Anything else is ignored.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns the same a reporter.error().
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oErrObj = oErr.errorInfo; # IProgress.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oErrObj = oErr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error(sText);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return reporter.error(stringifyErrorInfo(oErrObj));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Classes
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync#
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass ComError(object):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Unified COM and XPCOM status code repository.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This works more like a module than a class since it's replacing a module.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The VBOX_E_XXX bits:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync __VBOX_E_BASE = -2135228416;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_OBJECT_NOT_FOUND = __VBOX_E_BASE + 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_INVALID_VM_STATE = __VBOX_E_BASE + 2;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_VM_ERROR = __VBOX_E_BASE + 3;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_FILE_ERROR = __VBOX_E_BASE + 4;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_IPRT_ERROR = __VBOX_E_BASE + 5;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_PDM_ERROR = __VBOX_E_BASE + 6;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_INVALID_OBJECT_STATE = __VBOX_E_BASE + 7;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_HOST_ERROR = __VBOX_E_BASE + 8;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_NOT_SUPPORTED = __VBOX_E_BASE + 9;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_XML_ERROR = __VBOX_E_BASE + 10;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_INVALID_SESSION_STATE = __VBOX_E_BASE + 11;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_OBJECT_IN_USE = __VBOX_E_BASE + 12;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBOX_E_DONT_CALL_AGAIN = __VBOX_E_BASE + 13;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Reverse lookup table.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync dDecimalToConst = {}; # pylint: disable=C0103
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.GenError('No instances, please');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync @staticmethod
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def copyErrors(oNativeComErrorClass):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Copy all error codes from oNativeComErrorClass to this class and
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync install compatability mappings.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # First, add the VBOX_E_XXX constants to dDecimalToConst.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sAttr in dir(ComError):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sAttr.startswith('VBOX_E'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = getattr(ComError, sAttr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.dDecimalToConst[oAttr] = sAttr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Copy all error codes from oNativeComErrorClass to this class.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sAttr in dir(oNativeComErrorClass):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sAttr[0].isupper():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = getattr(oNativeComErrorClass, sAttr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync setattr(ComError, sAttr, oAttr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if type(oAttr) is int:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.dDecimalToConst[oAttr] = sAttr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Install mappings to the other platform.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if platform.system() == 'Windows':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.NS_OK = ComError.S_OK;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.NS_ERROR_FAILURE = ComError.E_FAIL;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.NS_ERROR_ABORT = ComError.E_ABORT;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.NS_ERROR_NULL_POINTER = ComError.E_POINTER;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.NS_ERROR_NO_INTERFACE = ComError.E_NOINTERFACE;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.NS_ERROR_INVALID_ARG = ComError.E_INVALIDARG;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.NS_ERROR_OUT_OF_MEMORY = ComError.E_OUTOFMEMORY;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.NS_ERROR_NOT_IMPLEMENTED = ComError.E_NOTIMPL;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.NS_ERROR_UNEXPECTED = ComError.E_UNEXPECTED;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.E_ACCESSDENIED = -2147024891; # see VBox/com/defs.h
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.S_OK = ComError.NS_OK;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.E_FAIL = ComError.NS_ERROR_FAILURE;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.E_ABORT = ComError.NS_ERROR_ABORT;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.E_POINTER = ComError.NS_ERROR_NULL_POINTER;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.E_NOINTERFACE = ComError.NS_ERROR_NO_INTERFACE;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.E_INVALIDARG = ComError.NS_ERROR_INVALID_ARG;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.E_OUTOFMEMORY = ComError.NS_ERROR_OUT_OF_MEMORY;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.E_NOTIMPL = ComError.NS_ERROR_NOT_IMPLEMENTED;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.E_UNEXPECTED = ComError.NS_ERROR_UNEXPECTED;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.DISP_E_EXCEPTION = -2147352567; # For COM compatability only.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync @staticmethod
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def equal(oXcpt, hr):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the ComException e is not equal to the COM status code hr.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This takes DISP_E_EXCEPTION & excepinfo into account.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This method can be used with any Exception derivate, however it will
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync only return True for classes similar to the two ComException variants.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if platform.system() == 'Windows':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The DISP_E_EXCEPTION + excptinfo fun needs checking up, only
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # empirical info on it so far.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hrXcpt = oXcpt.hresult;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except AttributeError:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if hrXcpt == ComError.DISP_E_EXCEPTION and oXcpt.excepinfo is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hrXcpt = oXcpt.excepinfo[5];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hrXcpt = oXcpt.errno;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except AttributeError:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return hrXcpt == hr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync @staticmethod
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def notEqual(oXcpt, hr):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the ComException e is not equal to the COM status code hr.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync See equal() for more details.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return not ComError.equal(oXcpt, hr)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync @staticmethod
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def toString(hr):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Converts the specified COM status code to a string.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sStr = ComError.dDecimalToConst[int(hr)];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except KeyError:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hrLong = long(hr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sStr = '%#x (%d)' % (hrLong, hrLong);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sStr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass Build(object): # pylint: disable=R0903
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync A VirtualBox build.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Note! After dropping the installation of VBox from this code and instead
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync realizing that with the vboxinstall.py wrapper driver, this class is
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync of much less importance and contains unnecessary bits and pieces.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, oDriver, strInstallPath):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Construct a build object from a build file name and/or install path.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Initialize all members first.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oDriver = oDriver;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sInstallPath = strInstallPath;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSdkPath = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSrcRoot = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sKind = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sDesignation = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sType = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sOs = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sArch = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sGuestAdditionsIso = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Figure out the values as best we can.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if strInstallPath is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Both parameters are None, which means we're falling back on a
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # build in the development tree.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sKind = "development";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sType is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sType = os.environ.get("KBUILD_TYPE", os.environ.get("BUILD_TYPE", "release"));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sOs is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sOs = os.environ.get("KBUILD_TARGET", os.environ.get("BUILD_TARGET", oDriver.sHost));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sArch is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sArch = os.environ.get("KBUILD_TARGET_ARCH", os.environ.get("BUILD_TARGET_ARCH", oDriver.sHostArch));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sOut = os.path.join('out', self.sOs + '.' + self.sArch, self.sType);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sSearch = os.environ.get('VBOX_TD_DEV_TREE', os.path.dirname(__file__)); # Env.var. for older trees or testboxscript.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidat = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(0, 10): # pylint: disable=W0612
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sBldDir = os.path.join(sSearch, sOut);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isdir(sBldDir):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidat = os.path.join(sBldDir, 'bin', 'VBoxSVC' + base.exeSuff());
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isfile(sCandidat):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSdkPath = os.path.join(sBldDir, 'bin/sdk');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidat = os.path.join(sBldDir, 'dist/VirtualBox.app/Contents/MacOS/VBoxSVC');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isfile(sCandidat):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSdkPath = os.path.join(sBldDir, 'dist/sdk');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sSearch = os.path.abspath(os.path.join(sSearch, '..'));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sCandidat is None or not os.path.isfile(sCandidat):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.GenError();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sInstallPath = os.path.abspath(os.path.dirname(sCandidat));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSrcRoot = os.path.abspath(sSearch);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sDesignation = os.environ.get('TEST_BUILD_DESIGNATION', None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sDesignation is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oFile = utils.openNoInherit(os.path.join(self.sSrcRoot, sOut, 'revision.kmk'), 'r');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync s = oFile.readline();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oFile.close();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync import re;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oMatch = re.search("VBOX_SVN_REV=(\\d+)", s);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oMatch is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sDesignation = oMatch.group(1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sDesignation is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sDesignation = 'XXXXX'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # We've been pointed to an existing installation, this could be
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # in the out dir of a svn checkout, untarred VBoxAll or a real
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # installation directory.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sKind = "preinstalled";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sType = "release";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sOs = oDriver.sHost;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sArch = oDriver.sHostArch;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sInstallPath = os.path.abspath(strInstallPath);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSdkPath = os.path.join(self.sInstallPath, 'sdk');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSrcRoot = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sDesignation = os.environ.get('TEST_BUILD_DESIGNATION', 'XXXXX');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo Much more work is required here.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Do some checks.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sVMMR0 = os.path.join(self.sInstallPath, 'VMMR0.r0');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sVMMR0) and utils.getHostOs() == 'solaris': # solaris is special.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sVMMR0 = os.path.join(self.sInstallPath, 'amd64' if utils.getHostArch() == 'amd64' else 'i386', 'VMMR0.r0');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sVMMR0):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.GenError('%s is missing' % (sVMMR0,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Guest additions location is different on windows for some _stupid_ reason.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sOs == 'win' and self.sKind != 'development':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sGuestAdditionsIso = '%s/VBoxGuestAdditions.iso' % (self.sInstallPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sOs == 'darwin':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sGuestAdditionsIso = '%s/VBoxGuestAdditions.iso' % (self.sInstallPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sGuestAdditionsIso = '%s/additions/VBoxGuestAdditions.iso' % (self.sInstallPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # __init__ end;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def dump(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Status dumper for debugging. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox.Build: sInstallPath= '%s'" % self.sInstallPath;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox.Build: sSdkPath = '%s'" % self.sSdkPath;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox.Build: sSrcRoot = '%s'" % self.sSrcRoot;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox.Build: sKind = '%s'" % self.sKind;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox.Build: sDesignation= '%s'" % self.sDesignation;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox.Build: sType = '%s'" % self.sType;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox.Build: sOs = '%s'" % self.sOs;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox.Build: sArch = '%s'" % self.sArch;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def isDevBuild(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Returns True if it's development build (kind), otherwise False. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.sKind == 'development';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass EventHandlerBase(object):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Base class for both Console and VirtualBox event handlers.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, dArgs, fpApiVer, sName = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr = dArgs['oVBoxMgr'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oEventSrc = dArgs['oEventSrc']; # Console/VirtualBox for < 3.3
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oListener = dArgs['oListener'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fPassive = self.oListener != None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sName = sName
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fShutdown = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oThread = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fpApiVer = fpApiVer;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def threadForPassiveMode(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The thread procedure for the event processing thread.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync assert self.fPassive is not None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while not self.fShutdown:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvt = self.oEventSrc.getEvent(self.oListener, 500);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.oVBoxMgr.xcptIsDeadInterface(): reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else: reporter.log('threadForPassiveMode/%s: interface croaked (ignored)' % (self.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oEvt:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.handleEvent(oEvt);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oEventSrc.eventProcessed(self.oListener, oEvt);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.unregister(fWaitForThread = False);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def startThreadForPassiveMode(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Called when working in passive mode.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oThread = threading.Thread(target = self.threadForPassiveMode, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync args=(), name=('PAS-%s' % (self.sName,)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oThread.setDaemon(True)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oThread.start();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def unregister(self, fWaitForThread = True):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Unregister the event handler.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fShutdown = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oEventSrc is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer < 3.3:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oEventSrc.unregisterCallback(self.oListener);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('unregisterCallback failed on %s' % (self.oListener,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oEventSrc.unregisterListener(self.oListener);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxMgr.xcptIsDeadInterface():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('unregisterListener failed on %s because of dead interface (%s)'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (self.oListener, self.oVBoxMgr.xcptToString(),));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('unregisterListener failed on %s' % (self.oListener,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oThread is not None \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and self.oThread != threading.current_thread():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oThread.join();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oThread = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync _ = fWaitForThread;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def handleEvent(self, oEvt):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Compatibility wrapper that child classes implement.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync _ = oEvt;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync @staticmethod
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def registerDerivedEventHandler(oVBoxMgr, fpApiVer, oSubClass, dArgsCopy,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSrcParent, sSrcParentNm, sICallbackNm,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fMustSucceed = True, sLogSuffix = ''):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Registers the callback / event listener.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync dArgsCopy['oVBoxMgr'] = oVBoxMgr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync dArgsCopy['oListener'] = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fpApiVer < 3.3:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync dArgsCopy['oEventSrc'] = oSrcParent;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oRet = oVBoxMgr.createCallback(sICallbackNm, oSubClass, dArgsCopy);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('%s::registerCallback(%s) failed%s' % (sSrcParentNm, oRet, sLogSuffix));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSrcParent.registerCallback(oRet);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oRet;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except Exception, oXcpt:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fMustSucceed or ComError.notEqual(oXcpt, ComError.E_UNEXPECTED):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('%s::registerCallback(%s)%s' % (sSrcParentNm, oRet, sLogSuffix));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fPassive = sys.platform == 'win32'; # or webservices.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEventSrc = oSrcParent.eventSource;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync dArgsCopy['oEventSrc'] = oEventSrc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fPassive:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oListener = oRet = oVBoxMgr.createListener(oSubClass, dArgsCopy);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oListener = oEventSrc.createListener();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync dArgsCopy['oListener'] = oListener;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oRet = oSubClass(dArgsCopy);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('%s::eventSource.createListener(%s) failed%s' % (sSrcParentNm, oListener, sLogSuffix));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEventSrc.registerListener(oListener, [vboxcon.VBoxEventType_Any], not fPassive);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except Exception, oXcpt:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fMustSucceed or ComError.notEqual(oXcpt, ComError.E_UNEXPECTED):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('%s::eventSource.registerListener(%s) failed%s' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (sSrcParentNm, oListener, sLogSuffix));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fPassive:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sys.platform == 'win32':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from win32com.server.util import unwrap # pylint: disable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oRet = unwrap(oRet);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oRet.oListener = oListener;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oRet.startThreadForPassiveMode();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oRet;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass ConsoleEventHandlerBase(EventHandlerBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Base class for handling IConsole events.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The class has IConsoleCallback (<=3.2) compatible callback methods which
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync the user can override as needed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Note! This class must not inherit from object or we'll get type errors in VBoxPython.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, dArgs, sName = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oSession = dArgs['oSession'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oConsole = dArgs['oConsole'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sName is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sName = self.oSession.sName;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync EventHandlerBase.__init__(self, dArgs, self.oSession.fpApiVer, sName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: disable=C0111,R0913,W0613
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMousePointerShapeChange(self, fVisible, fAlpha, xHot, yHot, cx, cy, abShape):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onMousePointerShapeChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMouseCapabilityChange(self, fSupportsAbsolute, *aArgs): # Extra argument was added in 3.2.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onMouseCapabilityChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onKeyboardLedsChange(self, fNumLock, fCapsLock, fScrollLock):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onKeyboardLedsChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onStateChange(self, eState):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onStateChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onAdditionsStateChange(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onAdditionsStateChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onNetworkAdapterChange(self, oNic):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onNetworkAdapterChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSerialPortChange(self, oPort):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onSerialPortChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onParallelPortChange(self, oPort):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onParallelPortChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onStorageControllerChange(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onStorageControllerChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMediumChange(self, attachment):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onMediumChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onCPUChange(self, iCpu, fAdd):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onCPUChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onVRDPServerChange(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onVRDPServerChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onRemoteDisplayInfoChange(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onRemoteDisplayInfoChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onUSBControllerChange(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onUSBControllerChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onUSBDeviceStateChange(self, oDevice, fAttached, oError):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onUSBDeviceStateChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSharedFolderChange(self, fGlobal):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onSharedFolderChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onRuntimeError(self, fFatal, sErrId, sMessage):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onRuntimeError/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onCanShowWindow(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onCanShowWindow/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onShowWindow(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onShowWindow/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=C0111,R0913,W0613
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def handleEvent(self, oEvt):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Compatibility wrapper.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtBase = self.oVBoxMgr.queryInterface(oEvt, 'IEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eType = oEvtBase.type;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if eType == vboxcon.VBoxEventType_OnRuntimeError:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtIt = self.oVBoxMgr.queryInterface(oEvtBase, 'IRuntimeErrorEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.onRuntimeError(oEvtIt.fatal, oEvtIt.id, oEvtIt.message)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo implement the other events.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if eType != vboxcon.VBoxEventType_OnMousePointerShapeChanged:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('%s/%s' % (str(eType), self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass VirtualBoxEventHandlerBase(EventHandlerBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Base class for handling IVirtualBox events.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The class has IConsoleCallback (<=3.2) compatible callback methods which
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync the user can override as needed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Note! This class must not inherit from object or we'll get type errors in VBoxPython.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, dArgs, sName = "emanon"):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr = dArgs['oVBoxMgr'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox = dArgs['oVBox'];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync EventHandlerBase.__init__(self, dArgs, self.oVBox.fpApiVer, sName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: disable=C0111,W0613
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMachineStateChange(self, sMachineId, eState):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMachineDataChange(self, sMachineId):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onExtraDataCanChange(self, sMachineId, sKey, sValue):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The COM bridge does tuples differently. Not very funny if you ask me... ;-)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxMgr.type == 'MSCOM':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return '', 0, True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True, ''
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onExtraDataChange(self, sMachineId, sKey, sValue):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMediumRegistered(self, sMediumId, eMediumType, fRegistered):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMachineRegistered(self, sMachineId, fRegistered):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSessionStateChange(self, sMachineId, eState):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSnapshotTaken(self, sMachineId, sSnapshotId):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSnapshotDiscarded(self, sMachineId, sSnapshotId):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSnapshotChange(self, sMachineId, sSnapshotId):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onGuestPropertyChange(self, sMachineId, sName, sValue, sFlags):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=C0111,W0613
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def handleEvent(self, oEvt):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Compatibility wrapper.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtBase = self.oVBoxMgr.queryInterface(oEvt, 'IEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eType = oEvtBase.type;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if eType == vboxcon.VBoxEventType_OnMachineStateChanged:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtIt = self.oVBoxMgr.queryInterface(oEvtBase, 'IMachineStateChangedEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.onMachineStateChange(oEvtIt.machineId, oEvtIt.state)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif eType == vboxcon.VBoxEventType_OnGuestPropertyChanged:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtIt = self.oVBoxMgr.queryInterface(oEvtBase, 'IGuestPropertyChangedEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.onGuestPropertyChange(oEvtIt.machineId, oEvtIt.name, oEvtIt.value, oEvtIt.flags);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo implement the other events.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('%s/%s' % (str(eType), self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass SessionConsoleEventHandler(ConsoleEventHandlerBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync For catching machine state changes and waking up the task machinery at that point.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self, dArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ConsoleEventHandlerBase.__init__(self, dArgs);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMachineStateChange(self, sMachineId, eState): # pylint: disable=W0613
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Just interrupt the wait loop here so it can check again. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr.interruptWaitEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass TestDriver(base.TestDriver): # pylint: disable=R0902
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This is the VirtualBox test driver.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def __init__(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync base.TestDriver.__init__(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fImportedVBoxApi = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fpApiVer = 3.2;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oBuild = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoRemoteSessions = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoVMs = []; ## @todo not sure if this list will be of any use.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oTestVmManager = vboxtestvms.TestVmManager(self.sResourcePath);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oTestVmSet = vboxtestvms.TestVmSet();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSessionTypeDef = 'headless';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSessionType = self.sSessionTypeDef;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fEnableVrdp = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.uVrdpBasePortDef = 6000;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.uVrdpBasePort = self.uVrdpBasePortDef;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sDefBridgedNic = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fUseDefaultSvc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSelfGroups = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSelfFlags = 'time';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSelfDest = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSessionGroups = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSessionFlags = 'time';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSessionDest = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSvcGroups = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSvcFlags = 'time';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSvcDest = '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSelfLogFile = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxSvcLogFile = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxSvcPidFile = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fVBoxSvcInDebugger = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxValidationKit = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxValidationKitIso = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxBootSectors = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fAlwaysUploadLogs = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fAlwaysUploadScreenshots = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Quietly detect build and validation kit.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._detectBuild(False);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._detectValidationKit(False);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Make sure all debug logs goes to the scratch area unless
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # specified otherwise (more of this later on).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if 'VBOX_LOG_DEST' not in os.environ:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_DEST'] = 'dir=%s' % (self.sScratchPath);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def dump(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Dump object state, for debugging.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync base.TestDriver.dump(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: fImportedVBoxApi = '%s'" % self.fImportedVBoxApi;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: fpApiVer = '%s'" % self.fpApiVer;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: oBuild = '%s'" % self.oBuild;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: oVBoxMgr = '%s'" % self.oVBoxMgr;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: oVBox = '%s'" % self.oVBox;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: aoRemoteSessions = '%s'" % self.aoRemoteSessions;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: aoVMs = '%s'" % self.aoVMs;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: sVBoxValidationKit = '%s'" % self.sVBoxValidationKit;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: sVBoxValidationKitIso = '%s'" % self.sVBoxValidationKitIso;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print >> sys.stderr, "testdriver.vbox: sVBoxBootSectors = '%s'" % self.sVBoxBootSectors;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oBuild is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oBuild.dump();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _detectBuild(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This is used internally to try figure a locally installed build when
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync running tests manually.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oBuild is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Try dev build first since that's where I'll be using it first..
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oBuild = Build(self, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except base.GenError:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Try default installation locations.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sHost == 'win':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sProgFiles = os.environ.get('ProgramFiles', 'C:\\Program Files');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asLocs = [
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.path.join(sProgFiles, 'Oracle', 'VirtualBox'),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.path.join(sProgFiles, 'OracleVM', 'VirtualBox'),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.path.join(sProgFiles, 'Sun', 'VirtualBox'),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sHost == 'solaris':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asLocs = [ '/opt/VirtualBox-3.2', '/opt/VirtualBox-3.1', '/opt/VirtualBox-3.0', '/opt/VirtualBox' ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sHost == 'darwin':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asLocs = [ '/Applications/VirtualBox.app/Contents/MacOS' ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sHost == 'linux':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asLocs = [ '/opt/VirtualBox-3.2', '/opt/VirtualBox-3.1', '/opt/VirtualBox-3.0', '/opt/VirtualBox' ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asLocs = [ '/opt/VirtualBox' ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if 'VBOX_INSTALL_PATH' in os.environ:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asLocs.insert(0, os.environ['VBOX_INSTALL_PATH']);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sLoc in asLocs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oBuild = Build(self, sLoc);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except base.GenError:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fQuiet:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('failed to find VirtualBox installation');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _detectValidationKit(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This is used internally by the constructor to try locate an unzipped
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBox Validation Kit somewhere in the immediate proximity.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sVBoxValidationKit is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Normally it's found where we're running from, which is the same as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # the script directly on the testboxes.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asCandidates = [self.sScriptPath, ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if g_ksValidationKitDir not in asCandidates:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asCandidates.append(g_ksValidationKitDir);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.getcwd() not in asCandidates:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asCandidates.append(os.getcwd());
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oBuild is not None and self.oBuild.sInstallPath not in asCandidates:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asCandidates.append(self.oBuild.sInstallPath);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # When working out of the tree, we'll search the current directory
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # as well as parent dirs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sDir in list(asCandidates):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(10):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sDir = os.path.dirname(sDir);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sDir not in asCandidates:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asCandidates.append(sDir);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Do the searching.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidate = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(len(asCandidates)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidate = asCandidates[i];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isfile(os.path.join(sCandidate, 'VBoxValidationKit.iso')):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidate = os.path.join(sCandidate, 'validationkit');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isfile(os.path.join(sCandidate, 'VBoxValidationKit.iso')):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidate = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = sCandidate is not None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is False:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fQuiet:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('failed to find VBox Validation Kit installation (candidates: %s)' % (asCandidates,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidate = os.path.join(self.sScriptPath, 'validationkit'); # Don't leave the values as None.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Set the member values.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxValidationKit = sCandidate;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxValidationKitIso = os.path.join(sCandidate, 'VBoxValidationKit.iso');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxBootSectors = os.path.join(sCandidate, 'bootsectors');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def importVBoxApi(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Import the 'vboxapi' module from the VirtualBox build we're using and
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync instantiate the two basic objects.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This will try detect an development or installed build if no build has
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync been associated with the driver yet.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fImportedVBoxApi:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo split up this messy function.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Make sure we've got our own VirtualBox config and VBoxSVC (on XPCOM at least).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.fUseDefaultSvc:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_USER_HOME'] = os.path.join(self.sScratchPath, 'VBoxUserHome');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sUser = os.environ.get('USERNAME', os.environ.get('USER', os.environ.get('LOGNAME', 'unknown')));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_IPC_SOCKETID'] = sUser + '-VBoxTest';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Do the detecting.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._detectBuild();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oBuild is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Avoid crashing when loading the 32-bit module (or whatever it is that goes bang).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oBuild.sArch == 'x86' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and self.sHost == 'darwin' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and platform.architecture()[0] == '64bit' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and self.oBuild.sKind == 'development' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and os.getenv('VERSIONER_PYTHON_PREFER_32_BIT') != 'yes':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print "WARNING: 64-bit python on darwin, 32-bit VBox development build => crash"
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print "WARNING: bash-3.2$ /usr/bin/python2.5 ./testdriver"
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print "WARNING: or"
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print "WARNING: bash-3.2$ VERSIONER_PYTHON_PREFER_32_BIT=yes ./testdriver"
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Start VBoxSVC and load the vboxapi bits.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self._startVBoxSVC() is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync assert(self.oVBoxSvcProcess is not None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sSavedSysPath = sys.path;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._setupVBoxApi();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sys.path = sSavedSysPath;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Adjust the default machine folder.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fImportedVBoxApi and not self.fUseDefaultSvc and self.fpApiVer >= 4.0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sNewFolder = os.path.join(self.sScratchPath, 'VBoxUserHome', 'Machines');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.systemProperties.defaultMachineFolder = sNewFolder;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fImportedVBoxApi = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt("defaultMachineFolder exception (sNewFolder=%s)" % (sNewFolder,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Kill VBoxSVC on failure.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxMgr is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._stopVBoxSVC();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync assert(self.oVBoxSvcProcess is None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.fImportedVBoxApi;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _startVBoxSVC(self): # pylint: disable=R0915
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Starts VBoxSVC. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync assert(self.oVBoxSvcProcess is None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Setup vbox logging for VBoxSVC now and start it manually. This way
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # we can control both logging and shutdown.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxSvcLogFile = '%s/VBoxSVC-debug.log' % (self.sScratchPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: os.remove(self.sVBoxSvcLogFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG'] = self.sLogSvcGroups;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_FLAGS'] = '%s append' % (self.sLogSvcFlags,); # Append becuse of VBoxXPCOMIPCD.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sLogSvcDest:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_DEST'] = self.sLogSvcDest;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_DEST'] = 'file=%s' % (self.sVBoxSvcLogFile,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOXSVC_RELEASE_LOG_FLAGS'] = 'time append';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Always leave a pid file behind so we can kill it during cleanup-before.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxSvcPidFile = '%s/VBoxSVC.pid' % (self.sScratchPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fWritePidFile = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsFudge = 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sVBoxSVC = '%s/VBoxSVC' % (self.oBuild.sInstallPath,); ## @todo .exe and stuff.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fVBoxSvcInDebugger:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', ):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Start VBoxSVC in gdb in a new terminal.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #sTerm = '/usr/bin/gnome-terminal'; - doesn't work, some fork+exec stuff confusing us.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sTerm = '/usr/bin/xterm';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sTerm): sTerm = '/usr/X11/bin/xterm';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sTerm): sTerm = '/usr/X11R6/bin/xterm';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sTerm): sTerm = '/usr/bin/xterm';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sTerm): sTerm = 'xterm';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sGdb = '/usr/bin/gdb';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sGdb): sGdb = '/usr/local/bin/gdb';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sGdb): sGdb = '/usr/sfw/bin/gdb';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sGdb): sGdb = 'gdb';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sGdbCmdLine = '%s --args %s --pidfile %s' % (sGdb, sVBoxSVC, self.sVBoxSvcPidFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('term="%s" gdb="%s"' % (sTerm, sGdbCmdLine));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['SHELL'] = self.sOrgShell; # Non-working shell may cause gdb and/or the term problems.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess = base.Process.spawnp(sTerm, sTerm, '-e', sGdbCmdLine);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['SHELL'] = self.sOurShell;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxSvcProcess is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Press enter or return after starting VBoxSVC in the debugger...');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sys.stdin.read(1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fWritePidFile = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sHost == 'win':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sWinDbg = 'c:\\Program Files\\Debugging Tools for Windows\\windbg.exe';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sWinDbg): sWinDbg = 'c:\\Program Files\\Debugging Tools for Windows (x64)\\windbg.exe';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sWinDbg): sWinDbg = 'c:\\Programme\\Debugging Tools for Windows\\windbg.exe'; # Localization rulez! pylint: disable=C0301
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sWinDbg): sWinDbg = 'c:\\Programme\\Debugging Tools for Windows (x64)\\windbg.exe';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sWinDbg): sWinDbg = 'windbg'; # WinDbg must be in the path; better than nothing.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Assume that everything WinDbg needs is defined using the environment variables.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # See WinDbg help for more information.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('windbg="%s"' % (sWinDbg));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess = base.Process.spawn(sWinDbg, sWinDbg, sVBoxSVC + base.exeSuff());
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxSvcProcess is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Press enter or return after starting VBoxSVC in the debugger...');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sys.stdin.read(1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fWritePidFile = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo add a pipe interface similar to xpcom if feasible, i.e. if
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # we can get actual handle values for pipes in python.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('Port me!');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else: # Run without a debugger attached.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', ):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # XPCOM - We can use a pipe to let VBoxSVC notify us when it's ready.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iPipeR, iPipeW = os.pipe();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['NSPR_INHERIT_FDS'] = 'vboxsvc:startup-pipe:5:0x%x' % (iPipeW,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2("NSPR_INHERIT_FDS=%s" % (os.environ['NSPR_INHERIT_FDS']));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess = base.Process.spawn(sVBoxSVC, sVBoxSVC, '--auto-shutdown'); # SIGUSR1 requirement.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: # Try make sure we get the SIGINT and not VBoxSVC.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.setpgid(self.oVBoxSvcProcess.getPid(), 0); # pylint: disable=E1101
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.setpgid(0, 0); # pylint: disable=E1101
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.close(iPipeW);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sResponse = os.read(iPipeR, 32);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sResponse = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.close(iPipeR);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sResponse is None or sResponse.strip() != 'READY':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('VBoxSVC failed starting up... (sResponse=%s)' % (sResponse,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.oVBoxSvcProcess.wait(5000):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess.terminate(2500);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess.wait(5000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.sHost == 'win':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Windows - Just fudge it for now.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsFudge = 2000;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess = base.Process.spawn(sVBoxSVC, sVBoxSVC);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('Port me!');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Enable automatic crash reporting if we succeeded.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxSvcProcess is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess.enableCrashReporting('crash/report/svc', 'crash/dump/svc');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Fudge and pid file.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxSvcProcess != None and not self.oVBoxSvcProcess.wait(cMsFudge):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fWritePidFile:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iPid = self.oVBoxSvcProcess.getPid();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oFile = utils.openNoInherit(self.sVBoxSvcPidFile, "w+");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oFile.write('%s' % (iPid,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oFile.close();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('sPidFile=%s' % (self.sVBoxSvcPidFile,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('VBoxSVC PID=%u' % (iPid,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Finally add the task so we'll notice when it dies in a relatively timely manner.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.addTask(self.oVBoxSvcProcess);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: os.remove(self.sVBoxSvcPidFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.oVBoxSvcProcess != None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _killVBoxSVCByPidFile(self, sPidFile):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Kill a VBoxSVC given the pid from it's pid file. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Read the pid file.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sPidFile):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oFile = utils.openNoInherit(sPidFile, "r");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sPid = oFile.readline().strip();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oFile.close();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('sPidfile=%s' % (sPidFile,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Convert the pid to an integer and validate the range a little bit.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iPid = long(sPid);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('sPidfile=%s sPid="%s"' % (sPidFile, sPid));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iPid <= 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('negative pid - sPidfile=%s sPid="%s" iPid=%d' % (sPidFile, sPid, iPid));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Take care checking that it's VBoxSVC we're about to inhume.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if base.processCheckPidAndName(iPid, "VBoxSVC") is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Ignoring stale VBoxSVC pid file (pid=%s)' % (iPid,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Loop thru our different ways of getting VBoxSVC to terminate.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for aHow in [ [ base.sendUserSignal1, 5000, 'Dropping VBoxSVC a SIGUSR1 hint...'], \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync [ base.processInterrupt, 5000, 'Dropping VBoxSVC a SIGINT hint...'], \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync [ base.processTerminate, 7500, 'VBoxSVC is still around, killing it...'] ]:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(aHow[2]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if aHow[0](iPid) is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync msStart = base.timestampMilli();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while base.timestampMilli() - msStart < 5000 \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and base.processExists(iPid):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync time.sleep(0.2);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = not base.processExists(iPid);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Successfully killed VBoxSVC (pid=%s)' % (iPid,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Failed to kill VBoxSVC (pid=%s)' % (iPid,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _stopVBoxSVC(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Stops VBoxSVC. Try the polite way first.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxSvcProcess:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(self.oVBoxSvcProcess);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess.enableCrashReporting(None, None); # Disables it.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxSvcProcess is not None \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and not self.fVBoxSvcInDebugger:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # by process object.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxSvcProcess.isRunning():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Dropping VBoxSVC a SIGUSR1 hint...');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.oVBoxSvcProcess.sendUserSignal1() \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or not self.oVBoxSvcProcess.wait(5000):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Dropping VBoxSVC a SIGINT hint...');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.oVBoxSvcProcess.interrupt() \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or not self.oVBoxSvcProcess.wait(5000):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('VBoxSVC is still around, killing it...');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess.terminate();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess.wait(7500);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('VBoxSVC is no longer running...');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.oVBoxSvcProcess.isRunning():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # by pid file.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._killVBoxSVCByPidFile('%s/VBoxSVC.pid' % (self.sScratchPath,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _setupVBoxApi(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Import and set up the vboxapi.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The caller saves and restores sys.path.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Setup vbox logging for self (the test driver).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSelfLogFile = '%s/VBoxTestDriver.log' % (self.sScratchPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: os.remove(self.sSelfLogFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG'] = self.sLogSelfGroups;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_FLAGS'] = '%s append' % (self.sLogSelfFlags, );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sLogSelfDest:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_DEST'] = self.sLogSelfDest;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_DEST'] = 'file=%s' % (self.sSelfLogFile,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_RELEASE_LOG_FLAGS'] = 'time append';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Hack the sys.path + environment so the vboxapi can be found.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sys.path.insert(0, self.oBuild.sInstallPath);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oBuild.sSdkPath is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sys.path.insert(0, os.path.join(self.oBuild.sSdkPath, 'installer'))
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sys.path.insert(1, os.path.join(self.oBuild.sSdkPath, 'bindings', 'xpcom', 'python'))
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_PROGRAM_PATH'] = self.oBuild.sInstallPath;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log("sys.path: %s" % (sys.path));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: disable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from vboxapi import VirtualBoxManager
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sHost == 'win':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from pythoncom import com_error as NativeComExceptionClass # pylint: disable=E0611
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync import winerror as NativeComErrorClass
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from xpcom import Exception as NativeComExceptionClass
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from xpcom import nsError as NativeComErrorClass
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync traceback.print_exc();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync __deployExceptionHacks__(NativeComExceptionClass)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ComError.copyErrors(NativeComErrorClass);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Create the manager.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr = VirtualBoxManager(None, None)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('VirtualBoxManager exception');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Figure the API version.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVBox = self.oVBoxMgr.getVirtualBox();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sVer = oVBox.version;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('Failed to get VirtualBox version, assuming 4.0.0');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sVer = "4.0.0";
dd1ed7dae880ecef88e32d742f9192c519c18f44vboxsync if sVer.startswith("5.0") or (sVer.startswith("4.3.5") and len(sVer) == 6):
dd1ed7dae880ecef88e32d742f9192c519c18f44vboxsync self.fpApiVer = 5.0;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sVer.startswith("4.3") or (sVer.startswith("4.2.5") and len(sVer) == 6):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fpApiVer = 4.3;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sVer.startswith("4.2."):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fpApiVer = 4.2; ## @todo Fudge: Add (proper) 4.2 API support. Unmount medium etc?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sVer.startswith("4.1.") or (sVer.startswith("4.0.5") and len(sVer) == 6):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fpApiVer = 4.1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sVer.startswith("4.0."):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fpApiVer = 4.0;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sVer.startswith("3.2."):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fpApiVer = 3.2;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sVer.startswith("3.1."):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fpApiVer = 3.1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sVer.startswith("3.0."):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fpApiVer = 3.0;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.GenError('Unknown version "%s"' % (sVer,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._patchVBoxMgr();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testdriver.vboxwrappers import VirtualBoxWrapper;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox = VirtualBoxWrapper(oVBox, self.oVBoxMgr, self.fpApiVer, self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync vboxcon.goHackModuleClass.oVBoxMgr = self.oVBoxMgr; # VBoxConstantWrappingHack.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync vboxcon.fpApiVer = self.fpApiVer
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fImportedVBoxApi = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Found version %s (%s)' % (self.fpApiVer, sVer));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt("getVirtualBox exception");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _patchVBoxMgr(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Glosses over missing self.oVBoxMgr methods on older VBox versions.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _xcptGetResult(oSelf, oXcpt = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync _ = oSelf;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oXcpt is None: oXcpt = sys.exc_info()[1];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sys.platform == 'win32':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync import winerror; # pylint: disable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hrXcpt = oXcpt.hresult;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if hrXcpt == winerror.DISP_E_EXCEPTION:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hrXcpt = oXcpt.excepinfo[5];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hrXcpt = oXcpt.error;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return hrXcpt;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _xcptIsDeadInterface(oSelf, oXcpt = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oSelf.xcptGetStatus(oXcpt) in [
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 0x80004004, -2147467260, # NS_ERROR_ABORT
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 0x800706be, -2147023170, # NS_ERROR_CALL_FAILED (RPC_S_CALL_FAILED)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 0x800706ba, -2147023174, # RPC_S_SERVER_UNAVAILABLE.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 0x800706be, -2147023170, # RPC_S_CALL_FAILED.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 0x800706bf, -2147023169, # RPC_S_CALL_FAILED_DNE.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 0x80010108, -2147417848, # RPC_E_DISCONNECTED.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 0x800706b5, -2147023179, # RPC_S_UNKNOWN_IF
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _xcptIsOurXcptKind(oSelf, oXcpt = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync _ = oSelf;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oXcpt is None: oXcpt = sys.exc_info()[1];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sys.platform == 'win32':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from pythoncom import com_error as NativeComExceptionClass # pylint: disable=F0401,E0611
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from xpcom import Exception as NativeComExceptionClass # pylint: disable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return isinstance(oXcpt, NativeComExceptionClass);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _xcptIsEqual(oSelf, oXcpt, hrStatus):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hrXcpt = oSelf.xcptGetResult(oXcpt);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return hrXcpt == hrStatus or hrXcpt == hrStatus - 0x100000000;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _xcptToString(oSelf, oXcpt):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync _ = oSelf;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oXcpt is None: oXcpt = sys.exc_info()[1];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return str(oXcpt);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Add utilities found in newer vboxapi revision.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not hasattr(self.oVBoxMgr, 'xcptIsDeadInterface'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync import types;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr.xcptGetResult = types.MethodType(_xcptGetResult, self.oVBoxMgr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr.xcptIsDeadInterface = types.MethodType(_xcptIsDeadInterface, self.oVBoxMgr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr.xcptIsOurXcptKind = types.MethodType(_xcptIsOurXcptKind, self.oVBoxMgr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr.xcptIsEqual = types.MethodType(_xcptIsEqual, self.oVBoxMgr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr.xcptToString = types.MethodType(_xcptToString, self.oVBoxMgr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _teardownVBoxApi(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Drop all VBox object references and shutdown com/xpcom.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.fImportedVBoxApi:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoRemoteSessions = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoVMs = [];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync import gc
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync gc.collect();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fImportedVBoxApi = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sHost == 'win':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass; ## TODO shutdown COM if possible/necessary?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from xpcom import _xpcom as _xpcom; # pylint: disable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync hrc = _xpcom.NS_ShutdownXPCOM();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cIfs = _xpcom._GetInterfaceCount(); # pylint: disable=W0212
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cObjs = _xpcom._GetGatewayCount(); # pylint: disable=W0212
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cObjs == 0 and cIfs == 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('actionCleanupAfter: NS_ShutdownXPCOM -> %s, nothing left behind.' % (hrc, ));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('actionCleanupAfter: NS_ShutdownXPCOM -> %s, leaving %s objects and %s interfaces behind...' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (hrc, cObjs, cIfs));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if hasattr(_xpcom, '_DumpInterfaces'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync _xpcom._DumpInterfaces(); # pylint: disable=W0212
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('actionCleanupAfter: _DumpInterfaces failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync gc.collect();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync time.sleep(0.5); # fudge factory
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _powerOffAllVms(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Tries to power off all running VMs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oSession in self.aoRemoteSessions:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync uPid = oSession.getPid();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if uPid is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('_powerOffAllVms: PID is %s for %s, trying to kill it.' % (uPid, oSession.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync base.processKill(uPid);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('_powerOffAllVms: No PID for %s' % (oSession.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.close();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Build type, OS and arch getters.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getBuildType(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get the build type.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self._detectBuild():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return 'release';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.oBuild.sType;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getBuildOs(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get the build OS.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self._detectBuild():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.sHost;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.oBuild.sOs;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getBuildArch(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get the build arch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self._detectBuild():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.sHostArch;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.oBuild.sArch;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getGuestAdditionsIso(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get the path to the guest addition iso.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self._detectBuild():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.oBuild.sGuestAdditionsIso;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Override everything from the base class so the testdrivers don't have to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # check whether we have overridden a method or not.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def showUsage(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync rc = base.TestDriver.showUsage(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Generic VirtualBox Options:');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-session-type <type>');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Sets the session type. Typical values are: gui, headless, sdl');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Default: %s' % (self.sSessionTypeDef));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vrdp, --no-vrdp');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Enables VRDP, ports starting at 6000');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Default: --vrdp');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vrdp-base-port <port>');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Sets the base for VRDP port assignments.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Default: %s' % (self.uVrdpBasePortDef));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-default-bridged-nic <interface>');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Sets the default interface for bridged networking.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Default: autodetect');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-use-svc-defaults');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Use default locations and files for VBoxSVC. This is useful');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' for automatically configuring the test VMs for debugging.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-self-log');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger group settings for the testdriver.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-self-log-flags');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger flags settings for the testdriver.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-self-log-dest');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger destination settings for the testdriver.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-session-log');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VM session logger group settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-session-log-flags');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VM session logger flags.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-session-log-dest');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VM session logger destination settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-svc-log');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBoxSVC logger group settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-svc-log-flags');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBoxSVC logger flag settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-svc-log-dest');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBoxSVC logger destination settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-log');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger group settings for everyone.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-log-flags');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger flags settings for everyone.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-log-dest');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger destination settings for everyone.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-svc-debug');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Start VBoxSVC in a debugger');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-always-upload-logs');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Whether to always upload log files, or only do so on failure.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' --vbox-always-upload-screenshots');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Whether to always upload final screen shots, or only do so on failure.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oTestVmSet is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oTestVmSet.showUsage();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return rc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def parseOption(self, asArgs, iArg): # pylint: disable=R0915
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if asArgs[iArg] == '--vbox-session-type':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-session-type" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSessionType = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vrdp':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fEnableVrdp = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--no-vrdp':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fEnableVrdp = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vrdp-base-port':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vrdp-base-port" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: self.uVrdpBasePort = int(asArgs[iArg]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: raise base.InvalidOption('The "--vrdp-base-port" value "%s" is not a valid integer', asArgs[iArg]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.uVrdpBasePort <= 0 or self.uVrdpBasePort >= 65530:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vrdp-base-port" value "%s" is not in the valid range (1..65530)', asArgs[iArg]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-default-bridged-nic':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-default-bridged-nic" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sDefBridgedNic = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-use-svc-defaults':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fUseDefaultSvc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-self-log':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-self-log" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSelfGroups = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-self-log-flags':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-self-log-flags" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSelfFlags = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-self-log-dest':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-self-log-dest" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSelfDest = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-session-log':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-session-log" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSessionGroups = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-session-log-flags':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-session-log-flags" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSessionFlags = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-session-log-dest':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-session-log-dest" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSessionDest = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-svc-log':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-svc-log" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSvcGroups = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-svc-log-flags':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-svc-log-flags" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSvcFlags = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-svc-log-dest':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-svc-log-dest" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSvcDest = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-log':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-log" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSelfGroups = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSessionGroups = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSvcGroups = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-log-flags':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-svc-flags" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSelfFlags = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSessionFlags = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSvcFlags = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-log-dest':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iArg += 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iArg >= len(asArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-log-dest" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSelfDest = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSessionDest = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sLogSvcDest = asArgs[iArg];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-svc-debug':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fVBoxSvcInDebugger = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-always-upload-logs':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fAlwaysUploadLogs = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-always-upload-screenshots':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.fAlwaysUploadScreenshots = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Relevant for selecting VMs to test?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oTestVmSet is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iRc = self.oTestVmSet.parseOption(asArgs, iArg);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if iRc != iArg:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return iRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Hand it to the base class.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.parseOption(self, asArgs, iArg);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return iArg + 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def completeOptions(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.completeOptions(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getResourceSet(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oTestVmSet is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.oTestVmSet.getResourceSet();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.getResourceSet(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionExtract(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.actionExtract(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionVerify(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.actionVerify(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionConfig(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.actionConfig(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionExecute(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.actionExecute(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionCleanupBefore(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Kill any VBoxSVC left behind by a previous test run.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._killVBoxSVCByPidFile('%s/VBoxSVC.pid' % (self.sScratchPath,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.actionCleanupBefore(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionCleanupAfter(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Clean up the VBox bits and then call the base driver.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync If your test driver overrides this, it should normally call us at the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync end of the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Kill any left over VM processes.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._powerOffAllVms();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Drop all VBox object references and shutdown xpcom then
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # terminating VBoxSVC, with extreme prejudice if need be.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._teardownVBoxApi();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._stopVBoxSVC();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Add the VBoxSVC and testdriver debug+release log files.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fAlwaysUploadLogs or reporter.getErrorCount() > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sVBoxSvcLogFile is not None and os.path.isfile(self.sVBoxSvcLogFile):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(self.sVBoxSvcLogFile, 'log/debug/svc', 'Debug log file for VBoxSVC');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxSvcLogFile = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sSelfLogFile is not None and os.path.isfile(self.sSelfLogFile):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(self.sSelfLogFile, 'log/debug/client', 'Debug log file for the test driver');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSelfLogFile = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sVBoxSvcRelLog = os.path.join(self.sScratchPath, 'VBoxUserHome', 'VBoxSVC.log');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isfile(sVBoxSvcRelLog):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sVBoxSvcRelLog, 'log/release/svc', 'Release log file for VBoxSVC');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sSuff in [ '.1', '.2', '.3', '.4', '.5', '.6', '.7', '.8' ]:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isfile(sVBoxSvcRelLog + sSuff):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sVBoxSvcRelLog + sSuff, 'log/release/svc', 'Release log file for VBoxSVC');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Testbox debugging - START - TEMPORARY, REMOVE ASAP.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', ):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print '> ls -la %s' % (os.path.join(self.sScratchPath, 'VBoxUserHome'),);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync utils.processCall(['ls', '-la', os.path.join(self.sScratchPath, 'VBoxUserHome')]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync print '> ls -la %s' % (self.sScratchPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync utils.processCall(['ls', '-la', self.sScratchPath]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Testbox debugging - END - TEMPORARY, REMOVE ASAP.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Finally, call the base driver to wipe the scratch space.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.actionCleanupAfter(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def actionAbort(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Terminate VBoxSVC if we've got a pid file.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._killVBoxSVCByPidFile('%s/VBoxSVC.pid' % (self.sScratchPath,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.actionAbort(self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onExit(self, iRc):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Stop VBoxSVC if we've started it.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxSvcProcess is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('*** Shutting down the VBox API... (iRc=%s)' % (iRc,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._powerOffAllVms();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._teardownVBoxApi();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._stopVBoxSVC();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('*** VBox API shutdown done.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.onExit(self, iRc);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Task wait method override.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def notifyAboutReadyTask(self, oTask):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Overriding base.TestDriver.notifyAboutReadyTask.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr.interruptWaitEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('vbox.notifyAboutReadyTask: called interruptWaitEvents');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('vbox.notifyAboutReadyTask');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.notifyAboutReadyTask(self, oTask);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def waitForTasksSleepWorker(self, cMsTimeout):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Overriding base.TestDriver.waitForTasksSleepWorker.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync rc = self.oVBoxMgr.waitForEvents(int(cMsTimeout));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync _ = rc; #reporter.log2('vbox.waitForTasksSleepWorker(%u): true (waitForEvents -> %s)' % (cMsTimeout, rc));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except KeyboardInterrupt:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('vbox.waitForTasksSleepWorker');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Utility methods.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def processEvents(self, cMsTimeout = 0):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Processes events, returning after the first batch has been processed
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or the time limit has been reached.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Only Ctrl-C exception, no return.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxMgr.waitForEvents(cMsTimeout);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except KeyboardInterrupt:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def processPendingEvents(self):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ processEvents(0) - no waiting. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.processEvents(0);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def sleep(self, cSecs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Sleep for a specified amount of time, processing XPCOM events all the while.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout = long(cSecs * 1000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync msStart = base.timestampMilli();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processEvents(0);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsElapsed = base.timestampMilli() - msStart;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cMsElapsed > cMsTimeout:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #reporter.log2('cMsTimeout=%s - cMsElapsed=%d => %s' % (cMsTimeout, cMsElapsed, cMsTimeout - cMsElapsed));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processEvents(cMsTimeout - cMsElapsed);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _logVmInfoUnsafe(self, oVM): # pylint: disable=R0915,R0912
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Internal worker for logVmInfo that is wrapped in try/except.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This is copy, paste, search, replace and edit of infoCmd from vboxshell.py.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oOsType = self.oVBox.getGuestOSType(oVM.OSTypeId)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Name: %s" % (oVM.name));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" ID: %s" % (oVM.id));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" OS Type: %s - %s" % (oVM.OSTypeId, oOsType.description));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Machine state: %s" % (oVM.state));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Session state: %s" % (oVM.sessionState));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Session PID: %u (%#x)" % (oVM.sessionPID, oVM.sessionPID));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Session PID: %u (%#x)" % (oVM.sessionPid, oVM.sessionPid));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Session Type: %s" % (oVM.sessionType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" CPUs: %s" % (oVM.CPUCount));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" RAM: %sMB" % (oVM.memorySize));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" VRAM: %sMB" % (oVM.VRAMSize));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Monitors: %s" % (oVM.monitorCount));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Firmware: %s" % (oVM.firmwareType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" HwVirtEx: %s" % (oVM.getHWVirtExProperty(vboxcon.HWVirtExPropertyType_Enabled)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" VPID support: %s" % (oVM.getHWVirtExProperty(vboxcon.HWVirtExPropertyType_VPID)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Nested paging: %s" % (oVM.getHWVirtExProperty(vboxcon.HWVirtExPropertyType_NestedPaging)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.2 and hasattr(vboxcon, 'CPUPropertyType_LongMode'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Long-mode: %s" % (oVM.getCPUProperty(vboxcon.CPUPropertyType_LongMode)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 3.2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" PAE: %s" % (oVM.getCPUProperty(vboxcon.CPUPropertyType_PAE)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Synthetic CPU: %s" % (oVM.getCPUProperty(vboxcon.CPUPropertyType_Synthetic)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" PAE: %s" % (oVM.getCpuProperty(vboxcon.CpuPropertyType_PAE)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Synthetic CPU: %s" % (oVM.getCpuProperty(vboxcon.CpuPropertyType_Synthetic)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" ACPI: %s" % (oVM.BIOSSettings.ACPIEnabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" IO-APIC: %s" % (oVM.BIOSSettings.IOAPICEnabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 3.2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" HPET: %s" % (oVM.HPETEnabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" HPET: %s" % (oVM.hpetEnabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" 3D acceleration: %s" % (oVM.accelerate3DEnabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" 2D acceleration: %s" % (oVM.accelerate2DVideoEnabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" TeleporterEnabled: %s" % (oVM.teleporterEnabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" TeleporterPort: %s" % (oVM.teleporterPort));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" TeleporterAddress: %s" % (oVM.teleporterAddress));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" TeleporterPassword: %s" % (oVM.teleporterPassword));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Clipboard mode: %s" % (oVM.clipboardMode));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" VRDP server: %s" % (oVM.VRDEServer.enabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: sPorts = oVM.VRDEServer.getVRDEProperty("TCP/Ports");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: sPorts = "";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" VRDP server ports: %s" % (sPorts));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" VRDP auth: %s (%s)" % (oVM.VRDEServer.authType, oVM.VRDEServer.authLibrary));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" VRDP server: %s" % (oVM.VRDPServer.enabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" VRDP server ports: %s" % (oVM.VRDPServer.ports));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Last changed: %s" % (oVM.lastStateChange));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoControllers = self.oVBoxMgr.getArray(oVM, 'storageControllers')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if aoControllers:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Controllers:");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oCtrl in aoControllers:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" %s %s bus: %s type: %s" % (oCtrl.name, oCtrl.controllerType, oCtrl.bus, oCtrl.controllerType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoAttachments = self.oVBoxMgr.getArray(oVM, 'mediumAttachments')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if aoAttachments:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Attachments:");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oAtt in aoAttachments:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCtrl = "Controller: %s port: %s device: %s type: %s" % (oAtt.controller, oAtt.port, oAtt.device, oAtt.type);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oMedium = oAtt.medium
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oAtt.type == vboxcon.DeviceType_HardDisk:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" %s: HDD" % sCtrl);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Id: %s" % (oMedium.id));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Name: %s" % (oMedium.name));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Format: %s" % (oMedium.format));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Location: %s" % (oMedium.location));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oAtt.type == vboxcon.DeviceType_DVD:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" %s: DVD" % sCtrl);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oMedium:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Id: %s" % (oMedium.id));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Name: %s" % (oMedium.name));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oMedium.hostDrive:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Host DVD %s" % (oMedium.location));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oAtt.passthrough:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" [passthrough mode]");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Virtual image: %s" % (oMedium.location));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Size: %s" % (oMedium.size));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" empty");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oAtt.type == vboxcon.DeviceType_Floppy:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" %s: Floppy" % sCtrl);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oMedium:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Id: %s" % (oMedium.id));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Name: %s" % (oMedium.name));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oMedium.hostDrive:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Host floppy: %s" % (oMedium.location));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Virtual image: %s" % (oMedium.location));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Size: %s" % (oMedium.size));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" empty");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Network Adapter:");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for iSlot in range(0, 32):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: oNic = oVM.getNetworkAdapter(iSlot)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not oNic.enabled:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2(" slot #%d found but not enabled, skipping" % (iSlot,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync continue;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oNic.adapterType == vboxcon.NetworkAdapterType_Am79C973: sType = "PCNet";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oNic.adapterType == vboxcon.NetworkAdapterType_Am79C970A: sType = "PCNetOld";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oNic.adapterType == vboxcon.NetworkAdapterType_I82545EM: sType = "E1000";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oNic.adapterType == vboxcon.NetworkAdapterType_I82540EM: sType = "E1000Desk";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oNic.adapterType == vboxcon.NetworkAdapterType_I82543GC: sType = "E1000Srv2";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oNic.adapterType == vboxcon.NetworkAdapterType_Virtio: sType = "Virtio";
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else: sType = "unknown %s" % (oNic.adapterType);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" slot #%d: type: %s (%s) MAC Address: %s lineSpeed: %s" % \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (iSlot, sType, oNic.adapterType, oNic.MACAddress, oNic.lineSpeed) );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oNic.attachmentType == vboxcon.NetworkAttachmentType_NAT:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: NAT (%s)" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.1:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" nat-network: %s" % (oNic.NATNetwork,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oNic.attachmentType == vboxcon.NetworkAttachmentType_Bridged:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: Bridged (%s)" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.1:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" hostInterface: %s" % (oNic.bridgedInterface));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" hostInterface: %s" % (oNic.hostInterface));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oNic.attachmentType == vboxcon.NetworkAttachmentType_Internal:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: Internal (%s)" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" intnet-name: %s" % (oNic.internalNetwork,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oNic.attachmentType == vboxcon.NetworkAttachmentType_HostOnly:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: HostOnly (%s)" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.1:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" hostInterface: %s" % (oNic.hostOnlyInterface));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" hostInterface: %s" % (oNic.hostInterface));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.1:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oNic.attachmentType == vboxcon.NetworkAttachmentType_Generic:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: Generic (%s)" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" generic-driver: %s" % (oNic.GenericDriver));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: unknown-%s" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: unknown-%s" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oNic.traceEnabled:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" traceFile: %s" % (oNic.traceFile));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def logVmInfo(self, oVM): # pylint: disable=R0915,R0912
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Logs VM configuration details.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This is copy, past, search, replace and edit of infoCmd from vboxshell.py.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self._logVmInfoUnsafe(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def logVmInfoByName(self, sName):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync logVmInfo + getVmByName.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.logVmInfo(self.getVmByName(sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def tryFindGuestOsId(self, sIdOrDesc):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Takes a guest OS ID or Description and returns the ID.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync If nothing matching it is found, the input is returned unmodified.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sIdOrDesc == 'Solaris (64 bit)':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sIdOrDesc = 'Oracle Solaris 10 5/09 and earlier (64 bit)';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoGuestTypes = self.oVBoxMgr.getArray(self.oVBox, 'GuestOSTypes');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oGuestOS in aoGuestTypes:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sId = oGuestOS.id;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sDesc = oGuestOS.description;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sIdOrDesc == sId or sIdOrDesc == sDesc:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sIdOrDesc = sId;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sIdOrDesc
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def resourceFindVmHd(self, sVmName, sFlavor):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Search the test resources for the most recent VM HD.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns path relative to the test resource root.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo implement a proper search algo here.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return '4.2/' + sFlavor + '/' + sVmName + '/t-' + sVmName + '.vdi';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # VM Api wrappers that logs errors, hides exceptions and other details.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: disable=R0913,R0914
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def createTestVM(self, sName, iGroup, sHd = None, cMbRam = None, cCpus = 1, fVirtEx = None, fNestedPaging = None, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sDvdImage = None, sKind = "Other", fIoApic = None, fPae = None, fFastBootLogo = True, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eNic0Type = None, eNic0AttachType = None, sNic0NetName = 'default', sNic0MacAddr = 'grouped', \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sFloppy = None, fNatForwardingForTxs = None, sHddControllerType = 'IDE Controller', \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fVmmDevTestingPart = None, fVmmDevTestingMmio = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Creates a test VM with a immutable HD from the test resources.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.importVBoxApi():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # create + register the VM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.2: # Introduces grouping (third parameter, empty for now).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.oVBox.createMachine("", sName, [], self.tryFindGuestOsId(sKind), "");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.fpApiVer >= 4.0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.oVBox.createMachine("", sName, self.tryFindGuestOsId(sKind), "", False);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif self.fpApiVer >= 3.2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.oVBox.createMachine(sName, self.tryFindGuestOsId(sKind), "", "", False);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.oVBox.createMachine(sName, self.tryFindGuestOsId(sKind), "", "");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM.saveSettings();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.registerMachine(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.3:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = oVM.deleteConfig(None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = oVM.delete(None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.waitOnProgress(oProgress);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: oVM.deleteSettings();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to create vm "%s"' % (sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Configure the VM.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = self.openSession(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setupPreferredConfig();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and cMbRam is not None :
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setRamSize(cMbRam);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and cCpus is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setCpuCount(cCpus);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and fVirtEx is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.enableVirtEx(fVirtEx);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and fNestedPaging is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.enableNestedPaging(fNestedPaging);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and fIoApic is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.enableIoApic(fIoApic);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and fPae is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.enablePae(fPae);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and sDvdImage is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.attachDvd(sDvdImage);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and sHd is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.attachHd(sHd, sHddControllerType);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and sFloppy is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.attachFloppy(sFloppy);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and eNic0Type is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setNicType(eNic0Type, 0);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and (eNic0AttachType is not None or (sNic0NetName is not None and sNic0NetName != 'default')):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setNicAttachment(eNic0AttachType, sNic0NetName, 0);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and sNic0MacAddr is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sNic0MacAddr == 'grouped':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sNic0MacAddr = '%02u' % (iGroup);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setNicMacAddress(sNic0MacAddr, 0);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and fNatForwardingForTxs is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setupNatForwardingForTxs();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and fFastBootLogo is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setupBootLogo(fFastBootLogo);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and self.fEnableVrdp:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setupVrdp(True, self.uVrdpBasePort + iGroup);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and fVmmDevTestingPart is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.enableVmmDevTestingPart(fVmmDevTestingPart, fVmmDevTestingMmio);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc: fRc = oSession.saveSettings();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fRc: oSession.discardSettings(True);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.close();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fRc:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: self.oVBox.unregisterMachine(oVM.id);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.3:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = oVM.deleteConfig(None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = oVM.delete(None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.waitOnProgress(oProgress);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: oVM.deleteSettings();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('created "%s" with name "%s"' % (oVM.id, sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoVMs.append(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.logVmInfo(oVM); # testing...
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oVM;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=R0913,R0914
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def addTestMachine(self, sNameOrId, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Adds an already existing (that is, configured) test VM to the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync test VM list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # find + add the VM to the list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.oVBox.findMachine(sNameOrId);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('Port me!'); ## @todo Add support for older version < 4.0.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('could not find vm "%s"' % (sNameOrId,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoVMs.append(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fQuiet:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Added "%s" with name "%s"' % (oVM.id, sNameOrId));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.logVmInfo(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oVM;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def openSession(self, oVM):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Opens a session for the VM. Returns the a Session wrapper object that
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync will automatically close the session when the wrapper goes out of scope.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync On failure None is returned and an error is logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sUuid = oVM.id;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to get the UUID for VM "%s"' % (oVM,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # This loop is a kludge to deal with us racing the closing of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # direct session of a previous VM run. See waitOnDirectSessionClose.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(10):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer <= 3.2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = self.oVBoxMgr.openMachineSession(sUuid);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = self.oVBoxMgr.openMachineSession(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if i == 9:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to open session for "%s" ("%s")' % (sUuid, oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if i > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('warning: failed to open session for "%s" ("%s") - retrying in %u secs' % (sUuid, oVM, i));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.waitOnDirectSessionClose(oVM, 5000 + i * 1000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testdriver.vboxwrappers import SessionWrapper;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return SessionWrapper(oSession, oVM, self.oVBox, self.oVBoxMgr, self, False);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getVmByName(self, sName):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get a test VM by name. Returns None if not found, logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Look it up in our 'cache'.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oVM in self.aoVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #reporter.log2('cur: %s / %s (oVM=%s)' % (oVM.name, oVM.id, oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM.name == sName:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oVM;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to get the name from the VM "%s"' % (oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Look it up the standard way.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.addTestMachine(sName, fQuiet = True);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getVmByUuid(self, sUuid):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get a test VM by uuid. Returns None if not found, logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Look it up in our 'cache'.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for oVM in self.aoVMs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM.id == sUuid:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oVM;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to get the UUID from the VM "%s"' % (oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Look it up the standard way.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.addTestMachine(sUuid, fQuiet = True);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def waitOnProgress(self, oProgress, cMsTimeout = 1000000, fErrorOnTimeout = True, cMsInterval = 1000):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Waits for a progress object to complete. Returns the status code.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wait for progress no longer than cMsTimeout time period.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync tsStart = datetime.datetime.now()
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oProgress.completed:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return -1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync tsNow = datetime.datetime.now()
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync tsDelta = tsNow - tsStart
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if ((tsDelta.microseconds + tsDelta.seconds * 1000000) / 1000) > cMsTimeout:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fErrorOnTimeout:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorTimeout('Timeout while waiting for progress.')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return -1
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: oProgress.waitForCompletion(cMsInterval);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: return -2;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: rc = oProgress.resultCode;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: rc = -2;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return rc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def waitOnDirectSessionClose(self, oVM, cMsTimeout):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Waits for the VM process to close it's current direct session.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns None.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Get the original values so we're not subject to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eCurState = oVM.sessionState;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCurType = sOrgType = oVM.sessionType;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iCurPid = iOrgPid = oVM.sessionPID;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iCurPid = iOrgPid = oVM.sessionPid;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except Exception, oXcpt:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if ComError.notEqual(oXcpt, ComError.E_ACCESSDENIED):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync msStart = base.timestampMilli();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while iCurPid == iOrgPid \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and sCurType == sOrgType \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and sCurType != '' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and base.timestampMilli() - msStart < cMsTimeout \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and ( eCurState == vboxcon.SessionState_Unlocking \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or eCurState == vboxcon.SessionState_Spawning \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or eCurState == vboxcon.SessionState_Locked):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processEvents(1000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eCurState = oVM.sessionState;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCurType = oVM.sessionType;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iCurPid = oVM.sessionPID if self.fpApiVer >= 4.2 else oVM.sessionPid;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except Exception, oXcpt:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if ComError.notEqual(oXcpt, ComError.E_ACCESSDENIED):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def uploadStartupLogFile(self, oVM, sVmName):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Uploads the VBoxStartup.log when present.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLogFile = os.path.join(oVM.logFolder, 'VBoxStartup.log');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isfile(sLogFile):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sLogFile, 'log/release/vm', '%s startup log' % (sVmName, ),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sAltName = '%s-%s' % (sVmName, os.path.basename(sLogFile),));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def startVmEx(self, oVM, fWait = True, sType = None, sName = None, asEnv = None): # pylint: disable=R0914,R0915
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Start the VM, returning the VM session and progress object on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The session is also added to the task list and to the aoRemoteSessions set.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asEnv is a list of string on the putenv() form.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync On failure (None, None) is returned and an error is logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Massage and check the input.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sType is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sType = self.sSessionType;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sName is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: sName = oVM.name;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: sName = 'bad-vm-handle';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('startVmEx: sName=%s fWait=%s sType=%s' % (sName, fWait, sType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo Do this elsewhere.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Hack alert. Disables all annoying GUI popups.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sType == 'gui' and len(self.aoRemoteSessions) == 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.setExtraData('GUI/Input/AutoCapture', 'false');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 3.2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.setExtraData('GUI/LicenseAgreed', '8');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.setExtraData('GUI/LicenseAgreed', '7');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.setExtraData('GUI/RegistrationData', 'triesLeft=0');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.setExtraData('GUI/SUNOnlineData', 'triesLeft=0');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.setExtraData('GUI/SuppressMessages', 'confirmVMReset,remindAboutMouseIntegrationOn,'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'remindAboutMouseIntegrationOff,remindAboutPausedVMInput,confirmInputCapture,'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'confirmGoingFullscreen,remindAboutInaccessibleMedia,remindAboutWrongColorDepth,'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'confirmRemoveMedium,allPopupPanes,allMessageBoxes,all');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.setExtraData('GUI/UpdateDate', 'never');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.setExtraData('GUI/PreventBetaWarning', self.oVBox.version);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The UUID for the name.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sUuid = oVM.id;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to get the UUID for VM "%s"' % (oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.processPendingEvents();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Construct the environment.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLogFile = '%s/VM-%s.log' % (self.sScratchPath, sUuid);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: os.remove(sLogFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sLogSessionDest:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLogDest = self.sLogSessionDest;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLogDest = 'file=%s' % sLogFile;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEnv = 'VBOX_LOG=%s\nVBOX_LOG_FLAGS=%s\nVBOX_LOG_DEST=%s\nVBOX_RELEASE_LOG_FLAGS=append time' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (self.sLogSessionGroups, self.sLogSessionFlags, sLogDest,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sType == 'gui':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEnv += '\nVBOX_GUI_DBG_ENABLED=1'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if asEnv is not None and len(asEnv) > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sEnv += '\n' + ('\n'.join(asEnv));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Shortcuts for local testing.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = oWrapped = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTestVM = self.oTestVmSet.findTestVmByName(sName) if self.oTestVmSet is not None else None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTestVM is not None \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and oTestVM.fSnapshotRestoreCurrent is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM.state is vboxcon.MachineState_Running:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('Machine "%s" already running.' % (sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oWrapped = self.openSession(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('Checking if snapshot for machine "%s" exists.' % (sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSessionWrapperRestore = self.openSession(oVM);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oSessionWrapperRestore is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSnapshotCur = oVM.currentSnapshot;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oSnapshotCur is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('Restoring snapshot for machine "%s".' % (sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSessionWrapperRestore.restoreSnapshot(oSnapshotCur);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('Current snapshot for machine "%s" restored.' % (sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('warning: no current snapshot for machine "%s" found.' % (sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSessionWrapperRestore.close();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Open a remote session, wait for this operation to complete.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # (The loop is a kludge to deal with us racing the closing of the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # direct session of a previous VM run. See waitOnDirectSessionClose.)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oWrapped is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for i in range(10):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer < 4.3 \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or (self.fpApiVer == 4.3 and not hasattr(self.oVBoxMgr, 'getSessionObject')):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = self.oVBoxMgr.mgr.getSessionObject(self.oVBox); # pylint: disable=E1101
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = self.oVBoxMgr.getSessionObject(self.oVBox); # pylint: disable=E1101
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer < 3.3:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = self.oVBox.openRemoteSession(oSession, sUuid, sType, sEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = oVM.launchVMProcess(oSession, sType, sEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if i == 9:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to start VM "%s" ("%s"), aborting.' % (sUuid, sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if i >= 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('warning: failed to start VM "%s" ("%s") - retrying in %u secs.' % (sUuid, oVM, i)); # pylint: disable=C0301
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.waitOnDirectSessionClose(oVM, 5000 + i * 1000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fWait and oProgress is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync rc = self.waitOnProgress(oProgress);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if rc < 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.waitOnDirectSessionClose(oVM, 5000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.close();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reportError(oProgress, 'failed to open session for "%s"' % (sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.uploadStartupLogFile(oVM, sName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('waitOnProgress -> %s' % (rc,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wrap up the session object and push on to the list before returning it.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oWrapped is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testdriver.vboxwrappers import SessionWrapper;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oWrapped = SessionWrapper(oSession, oVM, self.oVBox, self.oVBoxMgr, self, True, sName, sLogFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oWrapped.registerEventHandlerForTask();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoRemoteSessions.append(oWrapped);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oWrapped is not self.aoRemoteSessions[len(self.aoRemoteSessions) - 1]:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('not by reference: oWrapped=%s aoRemoteSessions[%s]=%s'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (oWrapped, len(self.aoRemoteSessions) - 1,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoRemoteSessions[len(self.aoRemoteSessions) - 1]));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.addTask(oWrapped);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('startVmEx: oSession=%s, oSessionWrapper=%s, oProgress=%s' % (oSession, oWrapped, oProgress));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testdriver.vboxwrappers import ProgressWrapper;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (oWrapped, ProgressWrapper(oProgress, self.oVBoxMgr, self,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 'starting %s' % (sName,)) if oProgress else None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def startVm(self, oVM, sType=None, sName = None, asEnv = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Simplified version of startVmEx. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession, _ = self.startVmEx(oVM, True, sType, sName, asEnv = asEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oSession;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def startVmByNameEx(self, sName, fWait=True, sType=None, asEnv = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Start the VM, returning the VM session and progress object on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The session is also added to the task list and to the aoRemoteSessions set.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync On failure (None, None) is returned and an error is logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.getVmByName(sName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.startVmEx(oVM, fWait, sType, sName, asEnv = asEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def startVmByName(self, sName, sType=None, asEnv = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Start the VM, returning the VM session on success. The session is
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync also added to the task list and to the aoRemoteSessions set.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync On failure None is returned and an error is logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession, _ = self.startVmByNameEx(sName, True, sType, asEnv = asEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return oSession;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def terminateVmBySession(self, oSession, oProgress = None, fTakeScreenshot = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Terminates the VM specified by oSession and adds the release logs to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync the test report.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This will try archive this by using powerOff, but will resort to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync tougher methods if that fails.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The session will always be removed from the task list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The session will be closed unless we fail to kill the process.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The session will be removed from the remote session list if closed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The progress object (a wrapper!) is for teleportation and similar VM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync operations, it will be attempted canceled before powering off the VM.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Failures are logged but ignored.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The progress object will always be removed from the task list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True if powerOff and session close both succeed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False if on failure (logged), including when we successfully
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync kill the VM process.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('terminateVmBySession: oSession=%s (pid=%s) oProgress=%s' % (oSession.sName, oSession.getPid(), oProgress));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Call getPid first to make sure the PID is cached in the wrapper.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.getPid();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Take Screenshot and upload it (see below) to Test Manager if appropriate/requested.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLastScreenshotPath = None
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fTakeScreenshot is True or self.fAlwaysUploadScreenshots or reporter.testErrorCount() > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLastScreenshotPath = os.path.join(self.sScratchPath, "LastScreenshot-%s.png" % oSession.sName)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.takeScreenshot(sLastScreenshotPath)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLastScreenshotPath = None
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Terminate the VM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Cancel the progress object if specified.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oProgress is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not oProgress.isCompleted() and oProgress.isCancelable():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('terminateVmBySession: canceling "%s"...' % (oProgress.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress.o.cancel();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress.wait();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oProgress);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Check if the VM has terminated by it self before powering it off.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fClose = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.pollTask();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('terminateVmBySession: powering off "%s"...' % (oSession.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.powerOff(fFudgeOnFailure = False);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # power off failed, try terminate it in a nice manner.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync uPid = oSession.getPid();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if uPid is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('terminateVmBySession: Terminating PID %u (VM %s)' % (uPid, oSession.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fClose = base.processTerminate(uPid);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fClose is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.waitOnDirectSessionClose(oSession.oVM, 5000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fClose = oSession.waitForTask(1000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fClose is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Being nice failed...
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('terminateVmBySession: Termination failed, trying to kill PID %u (VM %s) instead' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (uPid, oSession.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fClose = base.processKill(uPid);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fClose is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.waitOnDirectSessionClose(oSession.oVM, 5000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fClose = oSession.waitForTask(1000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fClose is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('terminateVmBySession: Failed to kill PID %u (VM %s)' % (uPid, oSession.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The final steps.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fClose is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.close();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.waitOnDirectSessionClose(oSession.oVM, 10000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync eState = oSession.oVM.state;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if eState == vboxcon.MachineState_Aborted:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('terminateVmBySession: The VM "%s" aborted!' % (oSession.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Add the release log, debug log and a screenshot of the VM to the test report.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fAlwaysUploadLogs or reporter.testErrorCount() > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.addLogsToReport();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Add a screenshot if it has been requested and taken successfully.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sLastScreenshotPath is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if reporter.testErrorCount() > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sLastScreenshotPath, 'screenshot/failure', 'Last VM screenshot');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sLastScreenshotPath, 'screenshot/success', 'Last VM screenshot');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Some information query functions (mix).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Methods require the VBox API. If the information is provided by both
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # the testboxscript as well as VBox API, we'll check if it matches.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _hasHostCpuFeature(self, sEnvVar, sEnum, fpApiMinVer, fQuiet):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Common Worker for hasHostNestedPaging() and hasHostHwVirt().
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fEnv = os.environ.get(sEnvVar, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fEnv is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fEnv = fEnv.lower() not in [ 'false', 'f', 'not', 'no', 'n', '0', ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fVBox = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.importVBoxApi();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= fpApiMinVer and hasattr(vboxcon, sEnum):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fVBox = self.oVBox.host.getProcessorFeature(getattr(vboxcon, sEnum));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fQuiet:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fVBox is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fEnv is not None:
43edacd15c59bbe993c6dd44bcc20e5db501dc6fvboxsync if fEnv != fVBox and not fQuiet:
43edacd15c59bbe993c6dd44bcc20e5db501dc6fvboxsync reporter.log('TestBox configuration overwritten: fVBox=%s (%s) vs. fEnv=%s (%s)'
43edacd15c59bbe993c6dd44bcc20e5db501dc6fvboxsync % (fVBox, sEnum, fEnv, sEnvVar));
43edacd15c59bbe993c6dd44bcc20e5db501dc6fvboxsync return fEnv;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fVBox;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fEnv is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fEnv;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def hasHostHwVirt(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if hardware assisted virtualization is supported by the host.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self._hasHostCpuFeature('TESTBOX_HAS_HW_VIRT', 'ProcessorFeature_HWVirtEx', 3.1, fQuiet);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def hasHostNestedPaging(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if nested paging is supported by the host.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self._hasHostCpuFeature('TESTBOX_HAS_NESTED_PAGING', 'ProcessorFeature_NestedPaging', 4.2, fQuiet) \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and self.hasHostHwVirt(fQuiet);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def hasHostLongMode(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the host supports 64-bit guests.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Note that the testboxscript doesn't export this variable atm.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self._hasHostCpuFeature('TESTBOX_HAS_LONG_MODE', 'ProcessorFeature_LongMode', 3.1, fQuiet);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def getHostCpuCount(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns the number of CPUs on the host.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cEnv = os.environ.get('TESTBOX_CPU_COUNT', None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cEnv is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cEnv = int(cEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cVBox = self.oVBox.host.processorOnlineCount;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fQuiet:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cVBox = None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cVBox is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cEnv is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync assert cVBox == cEnv, 'Misconfigured TestBox: VBox: %u CPUs, testboxscript: %u CPUs' % (cVBox, cEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return cVBox;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cEnv is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return cEnv;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _getHostCpuDesc(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Internal method used for getting the host CPU description from VBoxSVC.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns description string, on failure an empty string is returned.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.oVBox.host.getProcessorDescription(0);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not fQuiet:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return '';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def isHostCpuAmd(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the host CPU vendor is AMD.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCpuDesc = self._getHostCpuDesc(fQuiet);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sCpuDesc.startswith("AMD") or sCpuDesc == 'AuthenticAMD';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def isHostCpuIntel(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the host CPU vendor is Intel.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCpuDesc = self._getHostCpuDesc(fQuiet);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sCpuDesc.startswith("Intel") or sCpuDesc == 'GenuineIntel';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def isHostCpuVia(self, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the host CPU vendor is VIA (or Centaur).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCpuDesc = self._getHostCpuDesc(fQuiet);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sCpuDesc.startswith("VIA") or sCpuDesc == 'CentaurHauls';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Testdriver execution methods.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def handleTask(self, oTask, sMethod):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Callback method for handling unknown tasks in the various run loops.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The testdriver should override this if it already tasks running when
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync calling startVmAndConnectToTxsViaTcp, txsRunTest or similar methods.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Call super to handle unknown tasks.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True if handled, False if not.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('%s: unknown task %s' % (sMethod, oTask));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsDoTask(self, oSession, oTxsSession, fnAsync, aArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Generic TXS task wrapper which waits both on the TXS and the session tasks.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False on error, logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns task result on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # All async methods ends with the following to args.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout = aArgs[-2];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fIgnoreErrors = aArgs[-1];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRemoveVm = self.addTask(oSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRemoveTxs = self.addTask(oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync rc = fnAsync(*aArgs); # pylint: disable=W0142
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if rc is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync rc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTask = self.waitForTasks(cMsTimeout + 1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is oTxsSession:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession.isSuccess():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync rc = oTxsSession.getResult();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif fIgnoreErrors is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log( 'txsDoTask: task failed (%s)' % (oTxsSession.getLastReply()[1],));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoTask: task failed (%s)' % (oTxsSession.getLastReply()[1],));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsSession.cancelTask();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fIgnoreErrors is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log( 'txsDoTask: The task timed out.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorTimeout('txsDoTask: The task timed out.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oTask is oSession:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoTask: The VM terminated unexpectedly');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fIgnoreErrors is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log( 'txsDoTask: An unknown task %s was returned' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoTask: An unknown task %s was returned' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoTask: fnAsync returned %s' % (rc,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRemoveTxs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRemoveVm:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return rc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: disable=C0111
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsDisconnect(self, oSession, oTxsSession, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncDisconnect,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsUuid(self, oSession, oTxsSession, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncUuid,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsMkDir(self, oSession, oTxsSession, sRemoteDir, fMode = 0700, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncMkDir,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteDir, fMode, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsMkDirPath(self, oSession, oTxsSession, sRemoteDir, fMode = 0700, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncMkDirPath,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteDir, fMode, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsMkSymlink(self, oSession, oTxsSession, sLinkTarget, sLink, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncMkSymlink,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sLinkTarget, sLink, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRmDir(self, oSession, oTxsSession, sRemoteDir, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncRmDir,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteDir, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRmFile(self, oSession, oTxsSession, sRemoteFile, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncRmFile,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteFile, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRmSymlink(self, oSession, oTxsSession, sRemoteSymlink, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncRmSymlink,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteSymlink, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRmTree(self, oSession, oTxsSession, sRemoteTree, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncRmTree,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteTree, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsIsDir(self, oSession, oTxsSession, sRemoteDir, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncIsDir,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteDir, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsIsFile(self, oSession, oTxsSession, sRemoteFile, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncIsFile,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteFile, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsIsSymlink(self, oSession, oTxsSession, sRemoteSymlink, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncIsSymlink,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteSymlink, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsUploadFile(self, oSession, oTxsSession, sLocalFile, sRemoteFile, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncUploadFile, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sLocalFile, sRemoteFile, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsUploadString(self, oSession, oTxsSession, sContent, sRemoteFile, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncUploadString, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sContent, sRemoteFile, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsDownloadFile(self, oSession, oTxsSession, sRemoteFile, sLocalFile, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncDownloadFile, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteFile, sLocalFile, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsDownloadFiles(self, oSession, oTxsSession, asFiles, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Convenience function to get files from the guest and stores it
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync into the scratch directory for later (manual) review.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False on failure, logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync for sGstFile in asFiles:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo Check for already existing files on the host and create a new
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # name for the current file to download.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sTmpFile = os.path.join(self.sScratchPath, 'tmp-' + os.path.basename(sGstFile));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('Downloading file "%s" to "%s" ...' % (sGstFile, sTmpFile));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.txsDownloadFile(oSession, oTxsSession, sGstFile, sTmpFile, 30 * 1000, fIgnoreErrors);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: os.unlink(sTmpFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sTmpFile, 'misc/other', 'guest - ' + sGstFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fIgnoreErrors is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('error downloading file "%s" to "%s"' % (sGstFile, sTmpFile));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('warning: file "%s" was not downloaded, ignoring.' % (sGstFile,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsDownloadString(self, oSession, oTxsSession, sRemoteFile, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncDownloadString,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteFile, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsUnpackFile(self, oSession, oTxsSession, sRemoteFile, sRemoteDir, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncUnpackFile, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (sRemoteFile, sRemoteDir, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=C0111
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsCdWait(self, oSession, oTxsSession, cMsTimeout = 30000, sFileCdWait = 'vboxtxs-readme.txt'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Mostly an internal helper for txsRebootAndReconnectViaTcp and
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync startVmAndConnectToTxsViaTcp that waits for the CDROM drive to become
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ready. It does this by polling for a file it knows to exist on the CD.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False on failure, logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRemoveVm = self.addTask(oSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRemoveTxs = self.addTask(oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout = self.adjustTimeoutMs(cMsTimeout);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync msStart = base.timestampMilli();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout2 = cMsTimeout;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oTxsSession.asyncIsFile('${CDROM}/%s' % (sFileCdWait), cMsTimeout2);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # wait for it to complete.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTask = self.waitForTasks(cMsTimeout2 + 1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is not oTxsSession:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsSession.cancelTask();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorTimeout('txsToCdWait: The task timed out (after %s ms).'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (base.timestampMilli() - msStart,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oTask is oSession:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsToCdWait: The VM terminated unexpectedly');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsToCdWait: An unknown task %s was returned' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession.isSuccess():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Check for timeout.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsElapsed = base.timestampMilli() - msStart;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cMsElapsed >= cMsTimeout:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsToCdWait: timed out');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # delay.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sleep(1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # resubmitt the task.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout2 = msStart + cMsTimeout - base.timestampMilli();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cMsTimeout2 < 500:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout2 = 500;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oTxsSession.asyncIsFile('${CDROM}/%s' % (sFileCdWait), cMsTimeout2);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsToCdWait: asyncIsFile failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsToCdWait: asyncIsFile failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRemoveTxs:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRemoveVm:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsDoConnectViaTcp(self, oSession, cMsTimeout, fNatForwardingForTxs = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Mostly an internal worker for connecting to TXS via TCP used by the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *ViaTcp methods.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns a tuplet with True/False and TxsSession/None depending on the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync result. Errors are logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsDoConnectViaTcp: oSession=%s, cMsTimeout=%s, fNatForwardingForTxs=%s'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (oSession, cMsTimeout, fNatForwardingForTxs));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout = self.adjustTimeoutMs(cMsTimeout);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsConnect = oSession.txsConnectViaTcp(cMsTimeout, fNatForwardingForTxs = fNatForwardingForTxs);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsConnect is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.addTask(oTxsConnect);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRemoveVm = self.addTask(oSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTask = self.waitForTasks(cMsTimeout + 1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsDoConnectViaTcp: waitForTasks returned %s' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oTxsConnect);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is oTxsConnect:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsSession = oTxsConnect.getResult();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsDoConnectViaTcp: Connected to TXS on %s.' % (oTxsSession.oTransport.sHostname,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (True, oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoConnectViaTcp: failed to connect to TXS.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsConnect.cancelTask();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorTimeout('txsDoConnectViaTcp: connect stage 1 timed out');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oTask is oSession:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.reportPrematureTermination('txsDoConnectViaTcp: ');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoConnectViaTcp: unknown/wrong task %s' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRemoveVm:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoConnectViaTcp: txsConnectViaTcp failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (False, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def startVmAndConnectToTxsViaTcp(self, sVmName, fCdWait = False, cMsTimeout = 15*60000, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsCdWait = 30000, sFileCdWait = 'vboxtxs-readme.txt', \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fNatForwardingForTxs = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Starts the specified VM and tries to connect to its TXS via TCP.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The VM will be powered off if TXS doesn't respond before the specified
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync time has elapsed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns a the VM and TXS sessions (a two tuple) on success. The VM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync session is in the task list, the TXS session is not.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns (None, None) on failure, fully logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Zap the guest IP to make sure we're not getting a stale entry
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # (unless we're restoring the VM of course).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTestVM = self.oTestVmSet.findTestVmByName(sVmName) if self.oTestVmSet is not None else None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTestVM is None \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or oTestVM.fSnapshotRestoreCurrent is False:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession1 = self.openSession(self.getVmByName(sVmName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession1.delGuestPropertyValue('/VirtualBox/GuestInfo/Net/0/V4/IP');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession1.saveSettings(True);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync del oSession1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Start the VM.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('startVmAndConnectToTxsViaTcp: Starting(/preparing) "%s" (timeout %s s)...' % (sVmName, cMsTimeout / 1000));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = self.startVmByName(sVmName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Connect to TXS.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('startVmAndConnectToTxsViaTcp: Started(/prepared) "%s", connecting to TXS ...' % (sVmName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (fRc, oTxsSession) = self.txsDoConnectViaTcp(oSession, cMsTimeout, fNatForwardingForTxs);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fCdWait:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wait for CD?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.txsCdWait(oSession, oTxsSession, cMsCdWait, sFileCdWait);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('startVmAndConnectToTxsViaTcp: txsCdWait failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Success!
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (oSession, oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('startVmAndConnectToTxsViaTcp: txsDoConnectViaTcp failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # If something went wrong while waiting for TXS to be started - take VM screenshot before terminate it
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.terminateVmBySession(oSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRebootAndReconnectViaTcp(self, oSession, oTxsSession, fCdWait = False, cMsTimeout = 15*60000, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsCdWait = 30000, sFileCdWait = 'vboxtxs-readme.txt', fNatForwardingForTxs = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Executes the TXS reboot command
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns A tuple of True and the new TXS session on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns A tuple of False and either the old TXS session or None on failure.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsRebootAndReconnect: cMsTimeout=%u' % (cMsTimeout,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # This stuff is a bit complicated because of rebooting being kind of
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # disruptive to the TXS and such... The protocol is that TXS will:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # - ACK the reboot command.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # - Shutdown the transport layer, implicitly disconnecting us.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # - Execute the reboot operation.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # - On failure, it will be re-init the transport layer and be
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # available pretty much immediately. UUID unchanged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # - On success, it will be respawed after the reboot (hopefully),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # with a different UUID.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iStart = base.timestampMilli();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Get UUID.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout2 = min(60000, cMsTimeout);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sUuidBefore = self.txsUuid(oSession, oTxsSession, self.adjustTimeoutMs(cMsTimeout2, 60000));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sUuidBefore is not False:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Reboot.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsElapsed = base.timestampMilli() - iStart;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout2 = cMsTimeout - cMsElapsed;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncReboot,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (self.adjustTimeoutMs(cMsTimeout2, 60000), False));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Reconnect.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fNatForwardingForTxs is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sleep(22); # NAT fudge - Two fixes are wanted: 1. TXS connect retries. 2. Main API reboot/reset hint.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsElapsed = base.timestampMilli() - iStart;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (fRc, oTxsSession) = self.txsDoConnectViaTcp(oSession, cMsTimeout - cMsElapsed, fNatForwardingForTxs);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Check the UUID.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsElapsed = base.timestampMilli() - iStart;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout2 = min(60000, cMsTimeout - cMsElapsed);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sUuidAfter = self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncUuid,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (self.adjustTimeoutMs(cMsTimeout2, 60000), False));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sUuidBefore is not False:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sUuidAfter != sUuidBefore:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('The guest rebooted (UUID %s -> %s)' % (sUuidBefore, sUuidAfter))
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Do CD wait if specified.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fCdWait:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.txsCdWait(oSession, oTxsSession, cMsCdWait, sFileCdWait);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc is not True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: txsCdWait failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: failed to get UUID (after)');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: did not reboot (UUID %s)' % (sUuidBefore,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: txsDoConnectViaTcp failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: reboot failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: failed to get UUID (before)');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (fRc, oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: disable=R0914,R0913
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRunTest(self, oTxsSession, sTestName, cMsTimeout, sExecName, asArgs = (), asAddEnv = (), sAsUser = ""):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Executes the specified test task, waiting till it completes or times out.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The VM session (if any) must be in the task list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True if we executed the task and nothing abnormal happend.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Query the process status from the TXS session.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False if some unexpected task was signalled or we failed to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart(sTestName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsRunTest: cMsTimeout=%u sExecName=%s asArgs=%s' % (cMsTimeout, sExecName, asArgs));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession.asyncExec(sExecName, asArgs, asAddEnv, sAsUser, cMsTimeout = self.adjustTimeoutMs(cMsTimeout)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.addTask(oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wait for the job to complete.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTask = self.waitForTasks(cMsTimeout + 1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTest: waitForTasks timed out');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is oTxsSession:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTest: isSuccess=%s getResult=%s' % (oTxsSession.isSuccess(), oTxsSession.getResult()));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.handleTask(oTask, 'txsRunTest'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not oTxsSession.pollTask():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsSession.cancelTask();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRunTest: asyncExec failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRunTestRedirectStd(self, oTxsSession, sTestName, cMsTimeout, sExecName, asArgs = (), asAddEnv = (), sAsUser = "",
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oStdIn = '/dev/null', oStdOut = '/dev/null', oStdErr = '/dev/null', oTestPipe = '/dev/null'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Executes the specified test task, waiting till it completes or times out,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync redirecting stdin, stdout and stderr to the given objects.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The VM session (if any) must be in the task list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True if we executed the task and nothing abnormal happend.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Query the process status from the TXS session.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False if some unexpected task was signalled or we failed to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart(sTestName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsRunTestRedirectStd: cMsTimeout=%u sExecName=%s asArgs=%s' % (cMsTimeout, sExecName, asArgs));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession.asyncExecEx(sExecName, asArgs, asAddEnv, oStdIn, oStdOut, oStdErr,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTestPipe, sAsUser, cMsTimeout = self.adjustTimeoutMs(cMsTimeout)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.addTask(oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wait for the job to complete.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTask = self.waitForTasks(cMsTimeout + 1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTestRedirectStd: waitForTasks timed out');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is oTxsSession:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTestRedirectStd: isSuccess=%s getResult=%s'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (oTxsSession.isSuccess(), oTxsSession.getResult()));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.handleTask(oTask, 'txsRunTestRedirectStd'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oTxsSession);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not oTxsSession.pollTask():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsSession.cancelTask();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRunTestRedirectStd: asyncExec failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRunTest2(self, oTxsSession1, oTxsSession2, sTestName, cMsTimeout,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sExecName1, asArgs1,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sExecName2, asArgs2,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asAddEnv1 = (), sAsUser1 = '', fWithTestPipe1 = True,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asAddEnv2 = (), sAsUser2 = '', fWithTestPipe2 = True):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Executes the specified test tasks, waiting till they complete or
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync times out. The 1st task is started after the 2nd one.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The VM session (if any) must be in the task list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True if we executed the task and nothing abnormal happend.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Query the process status from the TXS sessions.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False if some unexpected task was signalled or we failed to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testStart(sTestName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Submit the jobs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = False;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession1.asyncExec(sExecName1, asArgs1, asAddEnv1, sAsUser1, fWithTestPipe1, '1-',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.adjustTimeoutMs(cMsTimeout)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.addTask(oTxsSession1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sleep(2); # fudge! grr
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession2.asyncExec(sExecName2, asArgs2, asAddEnv2, sAsUser2, fWithTestPipe2, '2-',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.adjustTimeoutMs(cMsTimeout)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.addTask(oTxsSession2);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wait for the jobs to complete.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cPendingJobs = 2;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync while True:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTask = self.waitForTasks(cMsTimeout + 1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTest2: waitForTasks timed out');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is oTxsSession1 or oTask is oTxsSession2:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTask is oTxsSession1: iTask = 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else: iTask = 2;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTest2: #%u - isSuccess=%s getResult=%s' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (iTask, oTask.isSuccess(), oTask.getResult()));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oTask);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cPendingJobs -= 1;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cPendingJobs <= 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = True;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif not self.handleTask(oTask, 'txsRunTest'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oTxsSession2);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not oTxsSession2.pollTask():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsSession2.cancelTask();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRunTest2: asyncExec #2 failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.removeTask(oTxsSession1);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not oTxsSession1.pollTask():
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsSession1.cancelTask();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRunTest2: asyncExec #1 failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.testDone();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return fRc;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=R0914,R0913
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync