cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# -*- coding: utf-8 -*-
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# pylint: disable=C0302
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncVirtualBox Specific base testdriver.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncCopyright (C) 2010-2014 Oracle Corporation
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.
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.
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# Standard Python imports.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Figure out where the validation kit lives and make sure it's in the path.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncg_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Validation Kit imports.
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__fnComExceptionGetAttr__ = None; # pylint: disable=C0103
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ __getattribute__/__getattr__ default fake."""
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ ComException.__getattr__ wrapper - both XPCOM and COM. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = __fnComExceptionGetAttr__(oSelf, 'hresult');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oAttr = __fnComExceptionGetAttr__(oSelf, 'strerror');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #print '__MyComExceptionGetAttr(,%s) -> "%s"' % (sName, oAttr);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncdef __deployExceptionHacks__(oNativeComExceptionClass):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Deploys the exception and error hacks that helps unifying COM and XPCOM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync exceptions and errors.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync global __fnComExceptionGetAttr__ # pylint: disable=C0103
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Hook up our attribute getter for the exception class (ASSUMES new-style).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync __fnComExceptionGetAttr__ = getattr(oNativeComExceptionClass, '__getattr__');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync __fnComExceptionGetAttr__ = getattr(oNativeComExceptionClass, '__getattribute__');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync setattr(oNativeComExceptionClass, '__getattr__', __MyComExceptionGetAttr)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Make the modified classes accessible (are there better ways to do this?)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync# Utility functions.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if a IPv4 address looks valid. This will return false for
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync localhost and similar.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Stringifies the error information in a IVirtualBoxErrorInfo object.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns string with error info.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sRet = 'rc=%s text="%s" IID=%s component=%s' % (ComError.toString(rc), sText, sIid, sComponent);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Report a VirtualBox error on oErr. oErr can be IVirtualBoxErrorInfo
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or IProgress. Anything else is ignored.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns the same a reporter.error().
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return reporter.error(stringifyErrorInfo(oErrObj));
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 # The VBOX_E_XXX bits:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Reverse lookup table.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Copy all error codes from oNativeComErrorClass to this class and
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync install compatability mappings.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # First, add the VBOX_E_XXX constants to dDecimalToConst.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Copy all error codes from oNativeComErrorClass to this class.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Install mappings to the other platform.
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 ComError.E_ACCESSDENIED = -2147024891; # see VBox/com/defs.h
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 Checks if the ComException e is not equal to the COM status code hr.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This takes DISP_E_EXCEPTION & excepinfo into account.
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 # The DISP_E_EXCEPTION + excptinfo fun needs checking up, only
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # empirical info on it so far.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if hrXcpt == ComError.DISP_E_EXCEPTION and oXcpt.excepinfo is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the ComException e is not equal to the COM status code hr.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync See equal() for more details.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Converts the specified COM status code to a string.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync A VirtualBox build.
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 Construct a build object from a build file name and/or install path.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Initialize all members first.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Figure out the values as best we can.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Both parameters are None, which means we're falling back on a
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # build in the development tree.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sType = os.environ.get("KBUILD_TYPE", os.environ.get("BUILD_TYPE", "release"));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sOs = os.environ.get("KBUILD_TARGET", os.environ.get("BUILD_TARGET", oDriver.sHost));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sArch = os.environ.get("KBUILD_TARGET_ARCH", os.environ.get("BUILD_TARGET_ARCH", oDriver.sHostArch));
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 = os.path.join(sBldDir, 'bin', 'VBoxSVC' + base.exeSuff());
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidat = os.path.join(sBldDir, 'dist/VirtualBox.app/Contents/MacOS/VBoxSVC');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sSearch = os.path.abspath(os.path.join(sSearch, '..'));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sCandidat is None or not os.path.isfile(sCandidat):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sInstallPath = os.path.abspath(os.path.dirname(sCandidat));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sDesignation = os.environ.get('TEST_BUILD_DESIGNATION', None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oFile = utils.openNoInherit(os.path.join(self.sSrcRoot, sOut, 'revision.kmk'), 'r');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oMatch is not None:
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 self.sInstallPath = os.path.abspath(strInstallPath);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSdkPath = os.path.join(self.sInstallPath, 'sdk');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sDesignation = os.environ.get('TEST_BUILD_DESIGNATION', 'XXXXX');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo Much more work is required here.
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 # 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 self.sGuestAdditionsIso = '%s/VBoxGuestAdditions.iso' % (self.sInstallPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sGuestAdditionsIso = '%s/additions/VBoxGuestAdditions.iso' % (self.sInstallPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # __init__ end;
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 """ Returns True if it's development build (kind), otherwise False. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Base class for both Console and VirtualBox event handlers.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oEventSrc = dArgs['oEventSrc']; # Console/VirtualBox for < 3.3
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The thread procedure for the event processing thread.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvt = self.oEventSrc.getEvent(self.oListener, 500);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.oVBoxMgr.xcptIsDeadInterface(): reporter.logXcpt();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync else: reporter.log('threadForPassiveMode/%s: interface croaked (ignored)' % (self.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oEventSrc.eventProcessed(self.oListener, oEvt);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Called when working in passive mode.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oThread = threading.Thread(target = self.threadForPassiveMode, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Unregister the event handler.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('unregisterCallback failed on %s' % (self.oListener,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('unregisterListener failed on %s because of dead interface (%s)'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (self.oListener, self.oVBoxMgr.xcptToString(),));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('unregisterListener failed on %s' % (self.oListener,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Compatibility wrapper that child classes implement.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def registerDerivedEventHandler(oVBoxMgr, fpApiVer, oSubClass, dArgsCopy,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Registers the callback / event listener.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oRet = oVBoxMgr.createCallback(sICallbackNm, oSubClass, dArgsCopy);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('%s::registerCallback(%s) failed%s' % (sSrcParentNm, oRet, sLogSuffix));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fMustSucceed or ComError.notEqual(oXcpt, ComError.E_UNEXPECTED):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('%s::registerCallback(%s)%s' % (sSrcParentNm, oRet, sLogSuffix));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fPassive = sys.platform == 'win32'; # or webservices.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oListener = oRet = oVBoxMgr.createListener(oSubClass, dArgsCopy);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('%s::eventSource.createListener(%s) failed%s' % (sSrcParentNm, oListener, sLogSuffix));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEventSrc.registerListener(oListener, [vboxcon.VBoxEventType_Any], not fPassive);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fMustSucceed or ComError.notEqual(oXcpt, ComError.E_UNEXPECTED):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('%s::eventSource.registerListener(%s) failed%s' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from win32com.server.util import unwrap # pylint: disable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Base class for handling IConsole events.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The class has IConsoleCallback (<=3.2) compatible callback methods which
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync the user can override as needed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Note! This class must not inherit from object or we'll get type errors in VBoxPython.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync EventHandlerBase.__init__(self, dArgs, self.oSession.fpApiVer, sName);
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 reporter.log2('onAdditionsStateChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onNetworkAdapterChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onSerialPortChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onParallelPortChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onStorageControllerChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onVRDPServerChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onRemoteDisplayInfoChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onUSBControllerChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onUSBDeviceStateChange(self, oDevice, fAttached, oError):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onUSBDeviceStateChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onSharedFolderChange/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onRuntimeError(self, fFatal, sErrId, sMessage):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('onCanShowWindow/%s' % (self.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=C0111,R0913,W0613
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Compatibility wrapper.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtBase = self.oVBoxMgr.queryInterface(oEvt, 'IEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtIt = self.oVBoxMgr.queryInterface(oEvtBase, 'IRuntimeErrorEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.onRuntimeError(oEvtIt.fatal, oEvtIt.id, oEvtIt.message)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo implement the other events.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if eType != vboxcon.VBoxEventType_OnMousePointerShapeChanged:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Base class for handling IVirtualBox events.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The class has IConsoleCallback (<=3.2) compatible callback methods which
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync the user can override as needed.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Note! This class must not inherit from object or we'll get type errors in VBoxPython.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync EventHandlerBase.__init__(self, dArgs, self.oVBox.fpApiVer, sName);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: disable=C0111,W0613
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMachineStateChange(self, sMachineId, eState):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onExtraDataCanChange(self, sMachineId, sKey, sValue):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The COM bridge does tuples differently. Not very funny if you ask me... ;-)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onExtraDataChange(self, sMachineId, sKey, sValue):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMediumRegistered(self, sMediumId, eMediumType, fRegistered):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMachineRegistered(self, sMachineId, fRegistered):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSessionStateChange(self, sMachineId, eState):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSnapshotTaken(self, sMachineId, sSnapshotId):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSnapshotDiscarded(self, sMachineId, sSnapshotId):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onSnapshotChange(self, sMachineId, sSnapshotId):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onGuestPropertyChange(self, sMachineId, sName, sValue, sFlags):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=C0111,W0613
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Compatibility wrapper.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtBase = self.oVBoxMgr.queryInterface(oEvt, 'IEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if eType == vboxcon.VBoxEventType_OnMachineStateChanged:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtIt = self.oVBoxMgr.queryInterface(oEvtBase, 'IMachineStateChangedEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.onMachineStateChange(oEvtIt.machineId, oEvtIt.state)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif eType == vboxcon.VBoxEventType_OnGuestPropertyChanged:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oEvtIt = self.oVBoxMgr.queryInterface(oEvtBase, 'IGuestPropertyChangedEvent');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.onGuestPropertyChange(oEvtIt.machineId, oEvtIt.name, oEvtIt.value, oEvtIt.flags);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo implement the other events.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass SessionConsoleEventHandler(ConsoleEventHandlerBase):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync For catching machine state changes and waking up the task machinery at that point.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def onMachineStateChange(self, sMachineId, eState): # pylint: disable=W0613
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Just interrupt the wait loop here so it can check again. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsyncclass TestDriver(base.TestDriver): # pylint: disable=R0902
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This is the VirtualBox test driver.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoVMs = []; ## @todo not sure if this list will be of any use.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oTestVmManager = vboxtestvms.TestVmManager(self.sResourcePath);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Quietly detect build and validation kit.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Make sure all debug logs goes to the scratch area unless
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # specified otherwise (more of this later on).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_DEST'] = 'dir=%s' % (self.sScratchPath);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Dump object state, for debugging.
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 This is used internally to try figure a locally installed build when
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync running tests manually.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Try dev build first since that's where I'll be using it first..
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Try default installation locations.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sProgFiles = os.environ.get('ProgramFiles', 'C:\\Program Files');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.path.join(sProgFiles, 'OracleVM', 'VirtualBox'),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asLocs = [ '/opt/VirtualBox-3.2', '/opt/VirtualBox-3.1', '/opt/VirtualBox-3.0', '/opt/VirtualBox' ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asLocs = [ '/Applications/VirtualBox.app/Contents/MacOS' ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asLocs = [ '/opt/VirtualBox-3.2', '/opt/VirtualBox-3.1', '/opt/VirtualBox-3.0', '/opt/VirtualBox' ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('failed to find VirtualBox installation');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This is used internally by the constructor to try locate an unzipped
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync VBox Validation Kit somewhere in the immediate proximity.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Normally it's found where we're running from, which is the same as
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # the script directly on the testboxes.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oBuild is not None and self.oBuild.sInstallPath not in asCandidates:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # When working out of the tree, we'll search the current directory
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # as well as parent dirs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Do the searching.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isfile(os.path.join(sCandidate, 'VBoxValidationKit.iso')):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCandidate = os.path.join(sCandidate, 'validationkit');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if os.path.isfile(os.path.join(sCandidate, 'VBoxValidationKit.iso')):
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 # Set the member values.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxValidationKitIso = os.path.join(sCandidate, 'VBoxValidationKit.iso');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxBootSectors = os.path.join(sCandidate, 'bootsectors');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Import the 'vboxapi' module from the VirtualBox build we're using and
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync instantiate the two basic objects.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This will try detect an development or installed build if no build has
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync been associated with the driver yet.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo split up this messy function.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Make sure we've got our own VirtualBox config and VBoxSVC (on XPCOM at least).
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 # Do the detecting.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Avoid crashing when loading the 32-bit module (or whatever it is that goes bang).
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 # Start VBoxSVC and load the vboxapi bits.
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 self.oVBox.systemProperties.defaultMachineFolder = sNewFolder;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt("defaultMachineFolder exception (sNewFolder=%s)" % (sNewFolder,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Kill VBoxSVC on failure.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Starts VBoxSVC. """
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 except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_FLAGS'] = '%s append' % (self.sLogSvcFlags,); # Append becuse of VBoxXPCOMIPCD.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_DEST'] = 'file=%s' % (self.sVBoxSvcLogFile,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOXSVC_RELEASE_LOG_FLAGS'] = 'time append';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Always leave a pid file behind so we can kill it during cleanup-before.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sVBoxSvcPidFile = '%s/VBoxSVC.pid' % (self.sScratchPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sVBoxSVC = '%s/VBoxSVC' % (self.oBuild.sInstallPath,); ## @todo .exe and stuff.
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 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(sGdb): sGdb = '/usr/local/bin/gdb';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not os.path.isfile(sGdb): sGdb = '/usr/sfw/bin/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 reporter.log('Press enter or return after starting VBoxSVC in the debugger...');
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 self.oVBoxSvcProcess = base.Process.spawn(sWinDbg, sWinDbg, sVBoxSVC + base.exeSuff());
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Press enter or return after starting VBoxSVC in the debugger...');
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 else: # Run without a debugger attached.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.sHost in ('darwin', 'freebsd', 'linux', 'solaris', ):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # XPCOM - We can use a pipe to let VBoxSVC notify us when it's ready.
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 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 if sResponse is None or sResponse.strip() != 'READY':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('VBoxSVC failed starting up... (sResponse=%s)' % (sResponse,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Windows - Just fudge it for now.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess = base.Process.spawn(sVBoxSVC, sVBoxSVC);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Enable automatic crash reporting if we succeeded.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess.enableCrashReporting('crash/report/svc', 'crash/dump/svc');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Fudge and pid file.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.oVBoxSvcProcess != None and not self.oVBoxSvcProcess.wait(cMsFudge):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oFile = utils.openNoInherit(self.sVBoxSvcPidFile, "w+");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('sPidFile=%s' % (self.sVBoxSvcPidFile,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Finally add the task so we'll notice when it dies in a relatively timely manner.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ Kill a VBoxSVC given the pid from it's pid file. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Read the pid file.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Convert the pid to an integer and validate the range a little bit.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('sPidfile=%s sPid="%s"' % (sPidFile, sPid));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('negative pid - sPidfile=%s sPid="%s" iPid=%d' % (sPidFile, sPid, iPid));
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 # 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('Successfully killed VBoxSVC (pid=%s)' % (iPid,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Failed to kill VBoxSVC (pid=%s)' % (iPid,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Stops VBoxSVC. Try the polite way first.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBoxSvcProcess.enableCrashReporting(None, None); # Disables it.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # by process object.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Dropping VBoxSVC a SIGUSR1 hint...');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('VBoxSVC is still around, killing it...');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # by pid file.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._killVBoxSVCByPidFile('%s/VBoxSVC.pid' % (self.sScratchPath,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Import and set up the vboxapi.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The caller saves and restores sys.path.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Setup vbox logging for self (the test driver).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sSelfLogFile = '%s/VBoxTestDriver.log' % (self.sScratchPath,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_FLAGS'] = '%s append' % (self.sLogSelfFlags, );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_LOG_DEST'] = 'file=%s' % (self.sSelfLogFile,);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync os.environ['VBOX_RELEASE_LOG_FLAGS'] = 'time append';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Hack the sys.path + environment so the vboxapi can be found.
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 # pylint: disable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from pythoncom import com_error as NativeComExceptionClass # pylint: disable=E0611
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from xpcom import Exception as NativeComExceptionClass
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Create the manager.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Figure the API version.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('Failed to get VirtualBox version, assuming 4.0.0');
dd1ed7dae880ecef88e32d742f9192c519c18f44vboxsync if sVer.startswith("5.0") or (sVer.startswith("4.3.5") and len(sVer) == 6):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif sVer.startswith("4.3") or (sVer.startswith("4.2.5") and len(sVer) == 6):
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 raise base.GenError('Unknown version "%s"' % (sVer,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testdriver.vboxwrappers import VirtualBoxWrapper;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox = VirtualBoxWrapper(oVBox, self.oVBoxMgr, self.fpApiVer, self);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync vboxcon.goHackModuleClass.oVBoxMgr = self.oVBoxMgr; # VBoxConstantWrappingHack.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Found version %s (%s)' % (self.fpApiVer, sVer));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Glosses over missing self.oVBoxMgr methods on older VBox versions.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 0x800706be, -2147023170, # NS_ERROR_CALL_FAILED (RPC_S_CALL_FAILED)
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync 0x800706ba, -2147023174, # RPC_S_SERVER_UNAVAILABLE.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from pythoncom import com_error as NativeComExceptionClass # pylint: disable=F0401,E0611
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from xpcom import Exception as NativeComExceptionClass # pylint: disable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return hrXcpt == hrStatus or hrXcpt == hrStatus - 0x100000000;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ See vboxapi. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Add utilities found in newer vboxapi revision.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not hasattr(self.oVBoxMgr, 'xcptIsDeadInterface'):
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 Drop all VBox object references and shutdown com/xpcom.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync pass; ## TODO shutdown COM if possible/necessary?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from xpcom import _xpcom as _xpcom; # pylint: disable=F0401
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cIfs = _xpcom._GetInterfaceCount(); # pylint: disable=W0212
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cObjs = _xpcom._GetGatewayCount(); # pylint: disable=W0212
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('actionCleanupAfter: NS_ShutdownXPCOM -> %s, nothing left behind.' % (hrc, ));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('actionCleanupAfter: NS_ShutdownXPCOM -> %s, leaving %s objects and %s interfaces behind...' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.logXcpt('actionCleanupAfter: _DumpInterfaces failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Tries to power off all running VMs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if uPid is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('_powerOffAllVms: PID is %s for %s, trying to kill it.' % (uPid, oSession.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('_powerOffAllVms: No PID for %s' % (oSession.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Build type, OS and arch getters.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get the build type.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return 'release';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get the build OS.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get the build arch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get the path to the guest addition iso.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
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 reporter.log(' Sets the session type. Typical values are: gui, headless, sdl');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Default: %s' % (self.sSessionTypeDef));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Enables VRDP, ports starting at 6000');
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(' Use default locations and files for VBoxSVC. This is useful');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' for automatically configuring the test VMs for debugging.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger group settings for the testdriver.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger flags settings for the testdriver.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger destination settings for the testdriver.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VM session logger group settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VM session logger destination settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBoxSVC logger group settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBoxSVC logger flag settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBoxSVC logger destination settings.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger group settings for everyone.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger flags settings for everyone.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' The VBox logger destination settings for everyone.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Whether to always upload log files, or only do so on failure.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(' Whether to always upload final screen shots, or only do so on failure.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def parseOption(self, asArgs, iArg): # pylint: disable=R0915
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-session-type" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vrdp-base-port" takes an argument');
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 raise base.InvalidOption('The "--vbox-default-bridged-nic" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-self-log" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-self-log-flags" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-self-log-dest" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-session-log" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-session-log-flags" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-session-log-dest" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-svc-log" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-svc-log-flags" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-svc-log-dest" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-log" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-svc-flags" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync raise base.InvalidOption('The "--vbox-log-dest" takes an argument');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif asArgs[iArg] == '--vbox-always-upload-screenshots':
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Relevant for selecting VMs to test?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Hand it to the base class.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.parseOption(self, asArgs, iArg);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Kill any VBoxSVC left behind by a previous test run.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._killVBoxSVCByPidFile('%s/VBoxSVC.pid' % (self.sScratchPath,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Clean up the VBox bits and then call the base driver.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync If your test driver overrides this, it should normally call us at the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync end of the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Kill any left over VM processes.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Drop all VBox object references and shutdown xpcom then
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # terminating VBoxSVC, with extreme prejudice if need be.
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 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 sVBoxSvcRelLog = os.path.join(self.sScratchPath, 'VBoxUserHome', 'VBoxSVC.log');
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 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 print '> ls -la %s' % (os.path.join(self.sScratchPath, 'VBoxUserHome'),);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync utils.processCall(['ls', '-la', os.path.join(self.sScratchPath, 'VBoxUserHome')]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync utils.processCall(['ls', '-la', self.sScratchPath]);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Testbox debugging - END - TEMPORARY, REMOVE ASAP.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Finally, call the base driver to wipe the scratch space.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Terminate VBoxSVC if we've got a pid file.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self._killVBoxSVCByPidFile('%s/VBoxSVC.pid' % (self.sScratchPath,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Stop VBoxSVC if we've started it.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('*** Shutting down the VBox API... (iRc=%s)' % (iRc,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Task wait method override.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Overriding base.TestDriver.notifyAboutReadyTask.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('vbox.notifyAboutReadyTask: called interruptWaitEvents');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return base.TestDriver.notifyAboutReadyTask(self, oTask);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Overriding base.TestDriver.waitForTasksSleepWorker.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync _ = rc; #reporter.log2('vbox.waitForTasksSleepWorker(%u): true (waitForEvents -> %s)' % (cMsTimeout, rc));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Utility methods.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Processes events, returning after the first batch has been processed
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync or the time limit has been reached.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Only Ctrl-C exception, no return.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync """ processEvents(0) - no waiting. """
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Sleep for a specified amount of time, processing XPCOM events all the while.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #reporter.log2('cMsTimeout=%s - cMsElapsed=%d => %s' % (cMsTimeout, cMsElapsed, cMsTimeout - cMsElapsed));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def _logVmInfoUnsafe(self, oVM): # pylint: disable=R0915,R0912
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Internal worker for logVmInfo that is wrapped in try/except.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This is copy, paste, search, replace and edit of infoCmd from vboxshell.py.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" OS Type: %s - %s" % (oVM.OSTypeId, oOsType.description));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Session state: %s" % (oVM.sessionState));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Session PID: %u (%#x)" % (oVM.sessionPID, oVM.sessionPID));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Session PID: %u (%#x)" % (oVM.sessionPid, oVM.sessionPid));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Session Type: %s" % (oVM.sessionType));
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 reporter.log(" PAE: %s" % (oVM.getCPUProperty(vboxcon.CPUPropertyType_PAE)));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Synthetic CPU: %s" % (oVM.getCPUProperty(vboxcon.CPUPropertyType_Synthetic)));
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 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 reporter.log(" VRDP server: %s" % (oVM.VRDEServer.enabled));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync try: sPorts = oVM.VRDEServer.getVRDEProperty("TCP/Ports");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" VRDP auth: %s (%s)" % (oVM.VRDEServer.authType, oVM.VRDEServer.authLibrary));
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 aoControllers = self.oVBoxMgr.getArray(oVM, 'storageControllers')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" %s %s bus: %s type: %s" % (oCtrl.name, oCtrl.controllerType, oCtrl.bus, oCtrl.controllerType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoAttachments = self.oVBoxMgr.getArray(oVM, 'mediumAttachments')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sCtrl = "Controller: %s port: %s device: %s type: %s" % (oAtt.controller, oAtt.port, oAtt.device, oAtt.type);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Location: %s" % (oMedium.location));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Virtual image: %s" % (oMedium.location));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Host floppy: %s" % (oMedium.location));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" Virtual image: %s" % (oMedium.location));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: break;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2(" slot #%d found but not enabled, skipping" % (iSlot,));
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 reporter.log(" slot #%d: type: %s (%s) MAC Address: %s lineSpeed: %s" % \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (iSlot, sType, oNic.adapterType, oNic.MACAddress, oNic.lineSpeed) );
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oNic.attachmentType == vboxcon.NetworkAttachmentType_NAT:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: NAT (%s)" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" nat-network: %s" % (oNic.NATNetwork,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync elif oNic.attachmentType == vboxcon.NetworkAttachmentType_Bridged:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: Bridged (%s)" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" hostInterface: %s" % (oNic.bridgedInterface));
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 reporter.log(" hostInterface: %s" % (oNic.hostOnlyInterface));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" hostInterface: %s" % (oNic.hostInterface));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oNic.attachmentType == vboxcon.NetworkAttachmentType_Generic:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: Generic (%s)" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" generic-driver: %s" % (oNic.GenericDriver));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: unknown-%s" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log(" attachmentType: unknown-%s" % (oNic.attachmentType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def logVmInfo(self, oVM): # pylint: disable=R0915,R0912
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Logs VM configuration details.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This is copy, past, search, replace and edit of infoCmd from vboxshell.py.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync logVmInfo + getVmByName.
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 sIdOrDesc = 'Oracle Solaris 10 5/09 and earlier (64 bit)';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync aoGuestTypes = self.oVBoxMgr.getArray(self.oVBox, 'GuestOSTypes');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Search the test resources for the most recent VM HD.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns path relative to the test resource root.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo implement a proper search algo here.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return '4.2/' + sFlavor + '/' + sVmName + '/t-' + sVmName + '.vdi';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # VM Api wrappers that logs errors, hides exceptions and other details.
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 Creates a test VM with a immutable HD from the test resources.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # create + register the VM
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= 4.2: # Introduces grouping (third parameter, empty for now).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.oVBox.createMachine("", sName, [], self.tryFindGuestOsId(sKind), "");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.oVBox.createMachine("", sName, self.tryFindGuestOsId(sKind), "", False);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.oVBox.createMachine(sName, self.tryFindGuestOsId(sKind), "", "", False);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oVM = self.oVBox.createMachine(sName, self.tryFindGuestOsId(sKind), "", "");
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to create vm "%s"' % (sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Configure the VM.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fRc and (eNic0AttachType is not None or (sNic0NetName is not None and sNic0NetName != 'default')):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setNicAttachment(eNic0AttachType, sNic0NetName, 0);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.setupVrdp(True, self.uVrdpBasePort + iGroup);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oSession.enableVmmDevTestingPart(fVmmDevTestingPart, fVmmDevTestingMmio);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('created "%s" with name "%s"' % (oVM.id, sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=R0913,R0914
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def addTestMachine(self, sNameOrId, fQuiet = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Adds an already existing (that is, configured) test VM to the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync test VM list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # find + add the VM to the list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('Port me!'); ## @todo Add support for older version < 4.0.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('could not find vm "%s"' % (sNameOrId,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('Added "%s" with name "%s"' % (oVM.id, sNameOrId));
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 On failure None is returned and an error is logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to get the UUID for VM "%s"' % (oVM,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
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 oSession = self.oVBoxMgr.openMachineSession(sUuid);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to open session for "%s" ("%s")' % (sUuid, oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
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 Get a test VM by name. Returns None if not found, logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Look it up in our 'cache'.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync #reporter.log2('cur: %s / %s (oVM=%s)' % (oVM.name, oVM.id, oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to get the name from the VM "%s"' % (oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Look it up the standard way.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Get a test VM by uuid. Returns None if not found, logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Look it up in our 'cache'.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to get the UUID from the VM "%s"' % (oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Look it up the standard way.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def waitOnProgress(self, oProgress, cMsTimeout = 1000000, fErrorOnTimeout = True, cMsInterval = 1000):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Waits for a progress object to complete. Returns the status code.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wait for progress no longer than cMsTimeout time period.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if ((tsDelta.microseconds + tsDelta.seconds * 1000000) / 1000) > cMsTimeout:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorTimeout('Timeout while waiting for progress.')
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: return -2;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def waitOnDirectSessionClose(self, oVM, cMsTimeout):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Waits for the VM process to close it's current direct session.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns None.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Get the original values so we're not subject to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if ComError.notEqual(oXcpt, ComError.E_ACCESSDENIED):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync and ( eCurState == vboxcon.SessionState_Unlocking \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync iCurPid = oVM.sessionPID if self.fpApiVer >= 4.2 else oVM.sessionPid;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if ComError.notEqual(oXcpt, ComError.E_ACCESSDENIED):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Uploads the VBoxStartup.log when present.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLogFile = os.path.join(oVM.logFolder, 'VBoxStartup.log');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sLogFile, 'log/release/vm', '%s startup log' % (sVmName, ),
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sAltName = '%s-%s' % (sVmName, os.path.basename(sLogFile),));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def startVmEx(self, oVM, fWait = True, sType = None, sName = None, asEnv = None): # pylint: disable=R0914,R0915
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 asEnv is a list of string on the putenv() form.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync On failure (None, None) is returned and an error is logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Massage and check the input.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('startVmEx: sName=%s fWait=%s sType=%s' % (sName, fWait, sType));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync ## @todo Do this elsewhere.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Hack alert. Disables all annoying GUI popups.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sType == 'gui' and len(self.aoRemoteSessions) == 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.oVBox.setExtraData('GUI/Input/AutoCapture', 'false');
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 # The UUID for the name.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to get the UUID for VM "%s"' % (oVM));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Construct the environment.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sLogFile = '%s/VM-%s.log' % (self.sScratchPath, sUuid);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
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 # Shortcuts for local testing.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTestVM = self.oTestVmSet.findTestVmByName(sName) if self.oTestVmSet is not None else None;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTestVM is not None \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('Machine "%s" already running.' % (sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('Checking if snapshot for machine "%s" exists.' % (sName,));
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 reporter.log('warning: no current snapshot for machine "%s" found.' % (sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
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 or (self.fpApiVer == 4.3 and not hasattr(self.oVBoxMgr, 'getSessionObject')):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = self.oVBoxMgr.mgr.getSessionObject(self.oVBox); # pylint: disable=E1101
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession = self.oVBoxMgr.getSessionObject(self.oVBox); # pylint: disable=E1101
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = self.oVBox.openRemoteSession(oSession, sUuid, sType, sEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oProgress = oVM.launchVMProcess(oSession, sType, sEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorXcpt('failed to start VM "%s" ("%s"), aborting.' % (sUuid, sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
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 oSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reportError(oProgress, 'failed to open session for "%s"' % (sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wrap up the session object and push on to the list before returning it.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testdriver.vboxwrappers import SessionWrapper;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oWrapped = SessionWrapper(oSession, oVM, self.oVBox, self.oVBoxMgr, self, True, sName, sLogFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oWrapped is not self.aoRemoteSessions[len(self.aoRemoteSessions) - 1]:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('not by reference: oWrapped=%s aoRemoteSessions[%s]=%s'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.aoRemoteSessions[len(self.aoRemoteSessions) - 1]));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('startVmEx: oSession=%s, oSessionWrapper=%s, oProgress=%s' % (oSession, oWrapped, oProgress));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync from testdriver.vboxwrappers import ProgressWrapper;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (oWrapped, ProgressWrapper(oProgress, self.oVBoxMgr, self,
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 def startVmByNameEx(self, sName, fWait=True, sType=None, asEnv = None):
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 On failure (None, None) is returned and an error is logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oVM is None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.startVmEx(oVM, fWait, sType, sName, asEnv = asEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def startVmByName(self, sName, sType=None, asEnv = None):
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 On failure None is returned and an error is logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession, _ = self.startVmByNameEx(sName, True, sType, asEnv = asEnv);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def terminateVmBySession(self, oSession, oProgress = None, fTakeScreenshot = None):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Terminates the VM specified by oSession and adds the release logs to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync the test report.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync This will try archive this by using powerOff, but will resort to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync tougher methods if that fails.
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 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 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 reporter.log2('terminateVmBySession: oSession=%s (pid=%s) oProgress=%s' % (oSession.sName, oSession.getPid(), oProgress));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Call getPid first to make sure the PID is cached in the wrapper.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Take Screenshot and upload it (see below) to Test Manager if appropriate/requested.
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 # Terminate the VM
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 # Check if the VM has terminated by it self before powering it off.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('terminateVmBySession: powering off "%s"...' % (oSession.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # power off failed, try terminate it in a nice manner.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if uPid is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('terminateVmBySession: Terminating PID %u (VM %s)' % (uPid, oSession.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Being nice failed...
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('terminateVmBySession: Termination failed, trying to kill PID %u (VM %s) instead' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('terminateVmBySession: Failed to kill PID %u (VM %s)' % (uPid, oSession.sName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # The final steps.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.waitOnDirectSessionClose(oSession.oVM, 10000);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('terminateVmBySession: The VM "%s" aborted!' % (oSession.sName,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Add the release log, debug log and a screenshot of the VM to the test report.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fAlwaysUploadLogs or reporter.testErrorCount() > 0:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Add a screenshot if it has been requested and taken successfully.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if sLastScreenshotPath is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sLastScreenshotPath, 'screenshot/failure', 'Last VM screenshot');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sLastScreenshotPath, 'screenshot/success', 'Last VM screenshot');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Some information query functions (mix).
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 def _hasHostCpuFeature(self, sEnvVar, sEnum, fpApiMinVer, fQuiet):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Common Worker for hasHostNestedPaging() and hasHostHwVirt().
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fEnv is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fEnv = fEnv.lower() not in [ 'false', 'f', 'not', 'no', 'n', '0', ];
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if self.fpApiVer >= fpApiMinVer and hasattr(vboxcon, sEnum):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fVBox = self.oVBox.host.getProcessorFeature(getattr(vboxcon, sEnum));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fVBox is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fEnv is not None:
43edacd15c59bbe993c6dd44bcc20e5db501dc6fvboxsync reporter.log('TestBox configuration overwritten: fVBox=%s (%s) vs. fEnv=%s (%s)'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if fEnv is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if hardware assisted virtualization is supported by the host.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self._hasHostCpuFeature('TESTBOX_HAS_HW_VIRT', 'ProcessorFeature_HWVirtEx', 3.1, fQuiet);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if nested paging is supported by the host.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self._hasHostCpuFeature('TESTBOX_HAS_NESTED_PAGING', 'ProcessorFeature_NestedPaging', 4.2, fQuiet) \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the host supports 64-bit guests.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
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 Returns the number of CPUs on the host.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Raises exception on environment / host mismatch.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if cEnv is not None:
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 if cEnv is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Internal method used for getting the host CPU description from VBoxSVC.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns description string, on failure an empty string is returned.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the host CPU vendor is AMD.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sCpuDesc.startswith("AMD") or sCpuDesc == 'AuthenticAMD';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the host CPU vendor is Intel.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sCpuDesc.startswith("Intel") or sCpuDesc == 'GenuineIntel';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Checks if the host CPU vendor is VIA (or Centaur).
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True / False.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return sCpuDesc.startswith("VIA") or sCpuDesc == 'CentaurHauls';
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Testdriver execution methods.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Callback method for handling unknown tasks in the various run loops.
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 Returns True if handled, False if not.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('%s: unknown task %s' % (sMethod, oTask));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsDoTask(self, oSession, oTxsSession, fnAsync, aArgs):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Generic TXS task wrapper which waits both on the TXS and the session tasks.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False on error, logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns task result on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # All async methods ends with the following to args.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log( 'txsDoTask: task failed (%s)' % (oTxsSession.getLastReply()[1],));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoTask: task failed (%s)' % (oTxsSession.getLastReply()[1],));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorTimeout('txsDoTask: The task timed out.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoTask: The VM terminated unexpectedly');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log( 'txsDoTask: An unknown task %s was returned' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoTask: An unknown task %s was returned' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoTask: fnAsync returned %s' % (rc,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: disable=C0111
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsDisconnect(self, oSession, oTxsSession, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncDisconnect,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsUuid(self, oSession, oTxsSession, cMsTimeout = 30000, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncUuid,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
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 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 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 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 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 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 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 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 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 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 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 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 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 def txsDownloadFiles(self, oSession, oTxsSession, asFiles, fIgnoreErrors = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Convenience function to get files from the guest and stores it
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync into the scratch directory for later (manual) review.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False on failure, logged.
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 except: pass;
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.addLogFile(sTmpFile, 'misc/other', 'guest - ' + sGstFile);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('error downloading file "%s" to "%s"' % (sGstFile, sTmpFile));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('warning: file "%s" was not downloaded, ignoring.' % (sGstFile,));
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 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 # pylint: enable=C0111
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsCdWait(self, oSession, oTxsSession, cMsTimeout = 30000, sFileCdWait = 'vboxtxs-readme.txt'):
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 Returns True on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False on failure, logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oTxsSession.asyncIsFile('${CDROM}/%s' % (sFileCdWait), cMsTimeout2);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # wait for it to complete.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorTimeout('txsToCdWait: The task timed out (after %s ms).'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsToCdWait: The VM terminated unexpectedly');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsToCdWait: An unknown task %s was returned' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Check for timeout.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # resubmitt the task.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsTimeout2 = msStart + cMsTimeout - base.timestampMilli();
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = oTxsSession.asyncIsFile('${CDROM}/%s' % (sFileCdWait), cMsTimeout2);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsDoConnectViaTcp(self, oSession, cMsTimeout, fNatForwardingForTxs = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Mostly an internal worker for connecting to TXS via TCP used by the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync *ViaTcp methods.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns a tuplet with True/False and TxsSession/None depending on the
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync result. Errors are logged.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsDoConnectViaTcp: oSession=%s, cMsTimeout=%s, fNatForwardingForTxs=%s'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTxsConnect = oSession.txsConnectViaTcp(cMsTimeout, fNatForwardingForTxs = fNatForwardingForTxs);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsConnect is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsDoConnectViaTcp: waitForTasks returned %s' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession is not None:
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsDoConnectViaTcp: Connected to TXS on %s.' % (oTxsSession.oTransport.sHostname,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoConnectViaTcp: failed to connect to TXS.');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.errorTimeout('txsDoConnectViaTcp: connect stage 1 timed out');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession.reportPrematureTermination('txsDoConnectViaTcp: ');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoConnectViaTcp: unknown/wrong task %s' % (oTask,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsDoConnectViaTcp: txsConnectViaTcp failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync return (False, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def startVmAndConnectToTxsViaTcp(self, sVmName, fCdWait = False, cMsTimeout = 15*60000, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsCdWait = 30000, sFileCdWait = 'vboxtxs-readme.txt', \
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 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 # 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 oSession1 = self.openSession(self.getVmByName(sVmName));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oSession1.delGuestPropertyValue('/VirtualBox/GuestInfo/Net/0/V4/IP');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Start the VM.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('startVmAndConnectToTxsViaTcp: Starting(/preparing) "%s" (timeout %s s)...' % (sVmName, cMsTimeout / 1000));
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 # Wait for CD?
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.txsCdWait(oSession, oTxsSession, cMsCdWait, sFileCdWait);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('startVmAndConnectToTxsViaTcp: txsCdWait failed');
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 return (None, None);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRebootAndReconnectViaTcp(self, oSession, oTxsSession, fCdWait = False, cMsTimeout = 15*60000, \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync cMsCdWait = 30000, sFileCdWait = 'vboxtxs-readme.txt', fNatForwardingForTxs = False):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Executes the TXS reboot command
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns A tuple of True and the new TXS session on success.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns A tuple of False and either the old TXS session or None on failure.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsRebootAndReconnect: cMsTimeout=%u' % (cMsTimeout,));
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 # Get UUID.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sUuidBefore = self.txsUuid(oSession, oTxsSession, self.adjustTimeoutMs(cMsTimeout2, 60000));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncReboot,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (self.adjustTimeoutMs(cMsTimeout2, 60000), False));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Reconnect.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync self.sleep(22); # NAT fudge - Two fixes are wanted: 1. TXS connect retries. 2. Main API reboot/reset hint.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (fRc, oTxsSession) = self.txsDoConnectViaTcp(oSession, cMsTimeout - cMsElapsed, fNatForwardingForTxs);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Check the UUID.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync sUuidAfter = self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncUuid,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync (self.adjustTimeoutMs(cMsTimeout2, 60000), False));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('The guest rebooted (UUID %s -> %s)' % (sUuidBefore, sUuidAfter))
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Do CD wait if specified.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync fRc = self.txsCdWait(oSession, oTxsSession, cMsCdWait, sFileCdWait);
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: txsCdWait failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: failed to get UUID (after)');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: did not reboot (UUID %s)' % (sUuidBefore,));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: txsDoConnectViaTcp failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: reboot failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRebootAndReconnectViaTcp: failed to get UUID (before)');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: disable=R0914,R0913
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRunTest(self, oTxsSession, sTestName, cMsTimeout, sExecName, asArgs = (), asAddEnv = (), sAsUser = ""):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Executes the specified test task, waiting till it completes or times out.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The VM session (if any) must be in the task list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True if we executed the task and nothing abnormal happend.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Query the process status from the TXS session.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False if some unexpected task was signalled or we failed to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsRunTest: cMsTimeout=%u sExecName=%s asArgs=%s' % (cMsTimeout, sExecName, asArgs));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession.asyncExec(sExecName, asArgs, asAddEnv, sAsUser, cMsTimeout = self.adjustTimeoutMs(cMsTimeout)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wait for the job to complete.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTest: waitForTasks timed out');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTest: isSuccess=%s getResult=%s' % (oTxsSession.isSuccess(), oTxsSession.getResult()));
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 Executes the specified test task, waiting till it completes or times out,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync redirecting stdin, stdout and stderr to the given objects.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The VM session (if any) must be in the task list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True if we executed the task and nothing abnormal happend.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Query the process status from the TXS session.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False if some unexpected task was signalled or we failed to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log2('txsRunTestRedirectStd: cMsTimeout=%u sExecName=%s asArgs=%s' % (cMsTimeout, sExecName, asArgs));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession.asyncExecEx(sExecName, asArgs, asAddEnv, oStdIn, oStdOut, oStdErr,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync oTestPipe, sAsUser, cMsTimeout = self.adjustTimeoutMs(cMsTimeout)):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wait for the job to complete.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTestRedirectStd: waitForTasks timed out');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTestRedirectStd: isSuccess=%s getResult=%s'
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync % (oTxsSession.isSuccess(), oTxsSession.getResult()));
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if not self.handleTask(oTask, 'txsRunTestRedirectStd'):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRunTestRedirectStd: asyncExec failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync def txsRunTest2(self, oTxsSession1, oTxsSession2, sTestName, cMsTimeout,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asAddEnv1 = (), sAsUser1 = '', fWithTestPipe1 = True,
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync asAddEnv2 = (), sAsUser2 = '', fWithTestPipe2 = True):
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Executes the specified test tasks, waiting till they complete or
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync times out. The 1st task is started after the 2nd one.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync The VM session (if any) must be in the task list.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns True if we executed the task and nothing abnormal happend.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Query the process status from the TXS sessions.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync Returns False if some unexpected task was signalled or we failed to
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync submit the job.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Submit the jobs.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession1.asyncExec(sExecName1, asArgs1, asAddEnv1, sAsUser1, fWithTestPipe1, '1-',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync if oTxsSession2.asyncExec(sExecName2, asArgs2, asAddEnv2, sAsUser2, fWithTestPipe2, '2-',
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # Wait for the jobs to complete.
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTest2: waitForTasks timed out');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.log('txsRunTest2: #%u - isSuccess=%s getResult=%s' \
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRunTest2: asyncExec #2 failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync reporter.error('txsRunTest2: asyncExec #1 failed');
cf22150eaeeb72431bf1cf65c309a431454fb22bvboxsync # pylint: enable=R0914,R0913