# -*- coding: utf-8 -*-
# $Id$
"""
VirtualBox Test VMs
"""
__copyright__ = \
"""
Copyright (C) 2010-2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
# Standard Python imports.
import re;
import random;
import socket;
# Validation Kit imports.
# All virtualization modes.
# All virtualization modes except for raw-mode.
# Dictionary mapping the virtualization mode mnemonics to a little less cryptic
# strings used in test descriptions.
'raw' : 'Raw-mode',
'hwvirt' : 'HwVirt',
'hwvirt-np' : 'NestedPaging'
};
# Arch constants.
# Array indexes.
# Table translating from VM name core to a more detailed guest info.
# pylint: disable=C0301
[
[ 'Windows2000', 'Windows2000', g_k32, 1, 32, ['w2k', 'w2ksp[0-9]', 'win2k', 'win2ksp[0-9]']], # max cpus??
[ 'Windows2008', 'Windows2008', g_k32, 1, 64, ['w2k8', 'w2k8sp[0-9]', 'win2k8', 'win2k8sp[0-9]']], # max cpus/cores??
[ 'Windows2008_64', 'Windows2008_64', g_k64, 1, 64, ['w2k8r2', 'w2k8r2sp[0-9]', 'win2k8r2', 'win2k8r2sp[0-9]']], # max cpus/cores??
[ 'Windows7_64', 'Windows7_64', g_k64, 1, 64, ['w7-64', 'w7sp[0-9]-64', 'win7-64',]], # max cpus/cores??
[ 'Windows8_64', 'Windows8_64', g_k64, 1, 64, ['w8-64', 'w8sp[0-9]-64', 'win8-64',]], # max cpus/cores??
[ 'Windows81_64', 'Windows81_64', g_k64, 1, 64, ['w81-64', 'w81sp[0-9]-64', 'win81-64',]], # max cpus/cores??
];
## @name Guest OS type string constants.
## @{
## @}
## @name String constants for paravirtualization providers.
## @{
## @}
## Valid paravirtualization providers.
g_kasParavirtProviders = ( g_ksParavirtProviderNone, g_ksParavirtProviderDefault, g_ksParavirtProviderLegacy,
# Mapping for support of paravirtualisation providers per guest OS.
#g_kdaParavirtProvidersSupported = {
# g_ksGuestOsTypeDarwin : ( g_ksParavirtProviderMinimal, ),
# g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, ),
# g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
# g_ksGuestOsTypeOS2 : ( g_ksParavirtProviderNone, ),
# g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
# g_ksGuestOsTypeWindows : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, )
#}
# Temporary tweak:
# since for the most guests g_ksParavirtProviderNone is almost the same as g_ksParavirtProviderMinimal,
# g_ksParavirtProviderMinimal is removed from the list in order to get maximum number of unique choices
# during independent test runs when paravirt provider is taken randomly.
g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
}
# pylint: enable=C0301
"""
Checks if any of the strings in set 1 matches any of the regular
expressions in set 2.
"""
return True;
return False;
"""
This is just a data object.
"""
def __init__(self, oSet, sVmName, sHd = None, sKind = None, acCpusSup = None, asVirtModesSup = None, # pylint: disable=R0913
fRandomPvPMode = False):
self.sGuestOsType = None;
"""
Convert guest OS type into constant representation.
Raise exception if specified @param sType is unknown.
"""
return g_ksGuestOsTypeDarwin
return g_ksGuestOsTypeFreeBSD
return g_ksGuestOsTypeLinux
return g_ksGuestOsTypeOS2
return g_ksGuestOsTypeSolaris
return g_ksGuestOsTypeWindows
"""
Used by the constructor to guess stuff.
"""
# From name.
for aInfo in g_aaNameToDetails:
break;
# Check for 64-bit, if required and supported.
else:
# Lookup the kind.
for aInfo in g_aaNameToDetails:
break;
reporter.fatal('The OS of test VM "%s" with sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
# Translate sKind into sGuest OS Type.
if self.sGuestOsType is None:
else:
reporter.fatal('The OS of test VM "%s", sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
# Restrict modes and such depending on the OS.
if self.asVirtModesSup is None:
# TEMPORARY HACK - START
# TEMPORARY HACK - END
else:
# Figure relevant PV modes based on the OS.
if self.asParavirtModesSup is None:
## @todo Remove this hack as soon as we've got around to explictly configure test variations
## on the server side. Client side random is interesting but not the best option.
if fRandomPvPMode:
return True;
"""
actionExecute worker that finds and reconfigure a test VM.
Returns (fRc, oVM) where fRc is True, None or False and oVM is a
VBox VM object that is only present when rc is True.
"""
if oVM is not None:
else:
fRc = None; # Skip the test.
fRc = None; # Skip the test.
else:
if oSession is not None:
};
fCfg64Bit = self.is64bitRequired() or (self.is64bit() and fHostSupports64bit and sVirtMode != 'raw');
if fCfg64Bit: # This is to avoid GUI pedantic warnings in the GUI. Sigh.
if oOsType is not None:
return (fRc, None);
""" Checks if it's a Windows VM. """
""" Checks if it's an OS/2 VM. """
""" Checks if it's a 64-bit VM. """
""" Check if 64-bit is required or not. """
""" Checks if the test VM is logging onto a graphical desktop by default. """
return True;
return True;
return True;
return False;
"""
Identifies VMs that doesn't work on VIA.
Returns True if NOT supported on VIA, False if it IS supported.
"""
# Oracle linux doesn't like VIA in our experience
return True;
# OS/2: "The system detected an internal processing error at location
# 0168:fff1da1f - 000e:ca1f. 0a8606fd
return True;
# Windows NT4 before SP4 won't work because of cmpxchg8b not being
# detected, leading to a STOP 3e(80,0,0,0).
return True; # no service pack.
return True;
return False;
"""
A Boot Sector Test VM.
"""
if asVirtModesSup is None:
acCpusSup = [1,],
);
return self.f64BitRequired;
"""
A set of Test VMs.
"""
def __init__(self, oTestVmManager = None, acCpus = None, asVirtModes = None, fIgnoreSkippedVm = False):
if acCpus is None:
if asVirtModes is None:
self.asParavirtModes = None; ##< If None, use the first PV mode of the test VM, otherwise all modes in this list.
"""
Returns the TestVm object with the given name.
Returns None if not found.
"""
return oTestVm;
return None;
"""
Returns names of all the test VMs in the set separated by
sSep (defaults to ':').
"""
sVmNames = '';
if sVmNames == '':
else:
return sVmNames;
"""
Invoked by vbox.TestDriver.
"""
reporter.log(' Set of paravirtualized providers (modes) to tests. Intersected with what the test VM supports.');
## @todo Add more options for controlling individual VMs.
return True;
"""
Parses the set test vm set options (--test-vms and --skip-vms), modifying the set
Invoked by the testdriver method with the same name.
Keyword arguments:
asArgs -- The argument vector.
iArg -- The index of the current argument.
Returns iArg if the option was not recognized and the caller should handle it.
Returns the index of the next argument when something is consumed.
In the event of a syntax error, a InvalidOption or QuietInvalidOption
is thrown.
"""
iArg += 1;
for s in self.asVirtModes:
if s not in self.asVirtModesDef:
iArg += 1;
if s not in self.asVirtModesDef:
if s in self.asVirtModes:
iArg += 1;
try: c = int(s);
iArg += 1;
for s in asTestVMs:
if oTestVm is None:
iArg += 1;
for s in asTestVMs:
if oTestVm is None:
else:
iArg += 1
if sPvMode not in g_kasParavirtProviders:
self.asParavirtModes = None;
else:
return iArg;
return iArg + 1;
"""
Implements base.TestDriver.getResourceSet
"""
asResources = [];
return asResources;
"""
For base.TestDriver.actionConfig. Configure the VMs with defaults and
a few tweaks as per arguments.
Returns True if successful.
Returns False if not.
"""
continue;
# If we want to restore a VM we don't need to create
# the machine anymore -- so just add it to the test VM list.
else:
## @todo This could possibly be moved to the TestVM object.
if sDvdImage is not None:
else:
if eNic0AttachType is not None:
elif oTestVm.sNic0AttachType is None:
eMyNic0AttachType = None;
else:
sDvdImage = sMyDvdImage, \
if oVM is None:
return False;
return True;
"""
Removes unsupported virtualization modes.
"""
return True;
"""
For base.TestDriver.actionExecute. Calls the callback function for
each of the VMs and basic configuration variations (virt-mode and cpu
count).
Returns True if all fnCallback calls returned True, otherwise False.
The callback can return True, False or None. The latter is for when the
test is skipped. (True is for success, False is for failure.)
"""
#
# The test loop.
#
continue;
continue;
# Intersect the supported modes and the ones being testing.
# Ditto for CPUs.
# Ditto for paravirtualization modes, except if not specified we got a less obvious default.
asParavirtModes = [sPvMode for sPvMode in oTestVm.asParavirtModesSup if sPvMode in self.asParavirtModes];
assert None not in asParavirtModes;
assert asParavirtModes[0] is not None;
else:
asParavirtModes = (None,);
if cCpus == 1:
else:
continue;
cTests = 0;
for sVirtMode in asVirtModesSup:
continue;
for sParavirtMode in asParavirtModes:
if sParavirtMode is not None:
# Reconfigure the VM.
try:
except KeyboardInterrupt:
raise;
except:
# Do the testing.
try:
except KeyboardInterrupt:
raise;
except:
if sParavirtMode is not None:
if cErrors > 0:
return fRc;
"""
Enumerates all the 'active' VMs.
Returns True if all fnCallback calls returned True.
Returns False if any returned False.
Returns None immediately if fnCallback returned None.
"""
if fRc2 is None:
return fRc2;
return fRc;
"""
Test VM manager.
"""
"""
Gets the set of standard test VMs.
This is supposed to do something seriously clever, like searching the
testrsrc tree for usable VMs, but for the moment it's all hard coded. :-)
"""
return oSet;
"""
Gets a representative set of VMs for smoke testing.
"""
return oSet;
""" Shut up already! """
return self.sResourcePath;