base.py revision cf22150eaeeb72431bf1cf65c309a431454fb22b
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync# -*- coding: utf-8 -*-
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync# pylint: disable=C0302
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncBase testdriver module.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncCopyright (C) 2010-2014 Oracle Corporation
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncThis file is part of VirtualBox Open Source Edition (OSE), as
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncavailable from http://www.virtualbox.org. This file is free software;
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncyou can redistribute it and/or modify it under the terms of the GNU
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncGeneral Public License (GPL) as published by the Free Software
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncFoundation, in version 2 as it comes in the "COPYING" file of the
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncVirtualBox OSE distribution. VirtualBox OSE is distributed in the
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsynchope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncThe contents of this file may alternatively be used under the terms
e6ad2e18e663b076aeabfec994947514566a7accvboxsyncof the Common Development and Distribution License Version 1.0
e6ad2e18e663b076aeabfec994947514566a7accvboxsync(CDDL) only, as it comes in the "COPYING.CDDL" file of the
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncVirtualBox OSE distribution, in which case the provisions of the
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncCDDL are applicable instead of those of the GPL.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncYou may elect to license modified versions of this file under the
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncterms and conditions of either the GPL or the CDDL or both.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync# Standard Python imports.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync# Validation Kit imports.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync# Figure where we are.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncg_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)));
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync# Some utility functions.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync Returns the executable suffix.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync return '.exe';
41fcf8465b641c7083d3b440451f17c1210fce33vboxsync Searches the PATH for the specified executable name, returning the first
3ea1dbf096240fc221aea99352a74c17a367a9b6vboxsync existing file/directory/whatever. The return is abspath'ed.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync sPath = os.getenv('PATH', os.getenv('Path', os.path.defpath));
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync Tries to get an environment variable, optionally with a local run alternative.
d9677fea1378fca6695c8f8fd3dbb21ac4607280vboxsync Will raise an exception if sLocalAlternative is None and the variable is
d9677fea1378fca6695c8f8fd3dbb21ac4607280vboxsync empty or missing.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync if sVal is None:
56a67728661fcf47fd03bafdc7b5b33050c4a551vboxsync raise GenError('environment variable "%s" is missing' % (sVar));
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync raise GenError('environment variable "%s" is empty' % (sVar));
3fa7a7e633f46a212052b510cdb8cee41f279a67vboxsync if sLocalAlternative is None or not reporter.isLocal():
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsyncdef getDirEnv(sVar, sAlternative = None, fLocalReq = False, fTryCreate = False):
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync Tries to get an environment variable specifying a directory path.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync Resolves it into an absolute path and verifies its existance before
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync returning it.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync If the environment variable is empty or isn't set, or if the directory
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync doesn't exist or isn't a directory, sAlternative is returned instead.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync If sAlternative is None, then we'll raise a GenError. For local runs we'll
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync only do this if fLocalReq is True.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync assert sAlternative is None or fTryCreate is False;
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync if sVal is None:
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync raise GenError('environment variable "%s" is missing' % (sVar));
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync raise GenError('environment variable "%s" is empty' % (sVar));
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync reporter.error('the value of env.var. "%s" is not a dir: "%s"' % (sVar, sVal));
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync raise GenError('the value of env.var. "%s" is not a dir: "%s"' % (sVar, sVal));
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync reporter.error('makedirs failed on the value of env.var. "%s": "%s"' % (sVar, sVal));
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync raise GenError('makedirs failed on the value of env.var. "%s": "%s"' % (sVar, sVal));
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync Gets a millisecond timestamp.
9055f61bb57d2a625c6434d55beac7565c3b3c0dvboxsync Gets a nanosecond timestamp.
3a343ca21a267ec3c54e2317e2ed18fe99b8ebbbvboxsync Wrapper around gethostbyname.
3a343ca21a267ec3c54e2317e2ed18fe99b8ebbbvboxsync if sName is not None:
e637cb22e348f5665d5473dae55ed785aa7b6e9avboxsync reporter.error('gethostbyname(%s) -> %s' % (sName, sIpAddr));
e637cb22e348f5665d5473dae55ed785aa7b6e9avboxsync Sends a SIGINT or equivalent to interrupt the specified process.
e637cb22e348f5665d5473dae55ed785aa7b6e9avboxsync Returns True on success, False on failure.
5159c4c6485473c77871b515c15b59c3caa60b46vboxsync On Windows hosts this may not work unless the process happens to be a
5159c4c6485473c77871b515c15b59c3caa60b46vboxsync process group leader.
return fRc;
return fRc;
return fRc;
return fRc;
return False;
return fRc;
asPsCmd = None;
if asPsCmd is not None:
return False;
return False;
if sCurName is None:
return False;
return False;
return False;
return fRc;
return '<%s: fSignalled=%s, __oRLock=%s, oCv=%s, oOwner=%s, oLocker=%s, msStart=%s, sDbgCreated=%s>' \
% (type(self).__name__, self.fSignalled, self.__oRLock, self.oCv, repr(self.oOwner), self.oLocker, self.msStart,
return oOldOwner;
if not fOld:
return fOld;
return fOld
return fOld;
return fOld
if not fLocked:
if not fLocked:
return fState
if not fState:
while not fState:
return fState;
% (TdTaskBase.toString(self), self.uExitCode, self.uPid, self.sName, self.asArgs, self.hWin, self.uTid);
asArgs = [];
if not fLocked:
if not fRc:
reporter.error('Process "%s" returned/crashed with a non-zero status code!! rc=%u sig=%u%s (raw=%#x)'
if not fLocked:
return fRc;
if sKind is not None:
return True;
return True;
_ = asArgs;
return iArg;
self.sBinPath = os.path.join(g_ksValidationKitDir, os.pardir, os.pardir, os.pardir, 'out', utils.getHostOsDotArch(),
return False;
if os.path.isabs(sName): ## @todo Hack. Need to deal properly with stuff in the validationkit.zip and similar.
return sName;
return False;
return cErrors;
return False;
return True;
return True;
return iNext;
return iArgs;
return False;
return True;
return oTask;
return oTask;
return True;
return False;
while fMore:
if oTask is not None:
return oTask;
while fMore:
if oTask is not None:
return oTask;
except KeyboardInterrupt:
aiPids = [];
return aiPids;
return aiPids;
return False;
return True;
if not fQuiet:
return False;
return False;
return True;
return False;
return True;
return cMsToDeadline;
return cMsTimeout;
return sXmlFile;
return True;
raise QuietInvalidOption();
if iArg >= len(asArgs): raise InvalidOption('The "extract" action requires a destination directory');
return iArg;
return True;
return False;
return False;
return False;
return False;
return False;
return False;
return False;
return False;
return True;
return True;
return True;
return True;
return True;
return True;
return False;
_ = iRc;
return iRc;
if asArgs is None:
if fRc is None: