VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testdriver/vboxtestvms.py@ 78674

Last change on this file since 78674 was 78674, checked in by vboxsync, 6 years ago

tdAddBasic1.py,tdAddSharedFolders1.py: Enabled shared folder testing after more adjustments. bugref:9172

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 56.9 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: vboxtestvms.py 78674 2019-05-23 00:09:07Z vboxsync $
3
4"""
5VirtualBox Test VMs
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2010-2019 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 78674 $"
30
31# Standard Python imports.
32import copy;
33import os;
34import re;
35import random;
36import socket;
37import string;
38
39# Validation Kit imports.
40from testdriver import base;
41from testdriver import reporter;
42from testdriver import vboxcon;
43from common import utils;
44
45
46# All virtualization modes.
47g_asVirtModes = ['hwvirt', 'hwvirt-np', 'raw',];
48# All virtualization modes except for raw-mode.
49g_asVirtModesNoRaw = ['hwvirt', 'hwvirt-np',];
50# Dictionary mapping the virtualization mode mnemonics to a little less cryptic
51# strings used in test descriptions.
52g_dsVirtModeDescs = {
53 'raw' : 'Raw-mode',
54 'hwvirt' : 'HwVirt',
55 'hwvirt-np' : 'NestedPaging'
56};
57
58## @name VM grouping flags
59## @{
60g_kfGrpSmoke = 0x0001; ##< Smoke test VM.
61g_kfGrpStandard = 0x0002; ##< Standard test VM.
62g_kfGrpStdSmoke = g_kfGrpSmoke | g_kfGrpStandard; ##< shorthand.
63g_kfGrpWithGAs = 0x0004; ##< The VM has guest additions installed.
64g_kfGrpNoTxs = 0x0008; ##< The VM lacks test execution service.
65g_kfGrpAncient = 0x1000; ##< Ancient OS.
66g_kfGrpExotic = 0x2000; ##< Exotic OS.
67## @}
68
69
70## @name Flags.
71## @{
72g_k32 = 32; # pylint: disable=C0103
73g_k64 = 64; # pylint: disable=C0103
74g_k32_64 = 96; # pylint: disable=C0103
75g_kiArchMask = 96;
76g_kiNoRaw = 128; ##< No raw mode.
77## @}
78
79# Array indexes.
80g_iGuestOsType = 0;
81g_iKind = 1;
82g_iFlags = 2;
83g_iMinCpu = 3;
84g_iMaxCpu = 4;
85g_iRegEx = 5;
86
87# Table translating from VM name core to a more detailed guest info.
88# pylint: disable=C0301
89g_aaNameToDetails = \
90[
91 [ 'WindowsNT3x', 'WindowsNT3x', g_k32, 1, 32, ['nt3', 'nt3[0-9]*']], # max cpus??
92 [ 'WindowsNT4', 'WindowsNT4', g_k32, 1, 32, ['nt4', 'nt4sp[0-9]']], # max cpus??
93 [ 'Windows2000', 'Windows2000', g_k32, 1, 32, ['w2k', 'w2ksp[0-9]', 'win2k', 'win2ksp[0-9]']], # max cpus??
94 [ 'WindowsXP', 'WindowsXP', g_k32, 1, 32, ['xp', 'xpsp[0-9]']],
95 [ 'WindowsXP_64', 'WindowsXP_64', g_k64, 1, 32, ['xp64', 'xp64sp[0-9]']],
96 [ 'Windows2003', 'Windows2003', g_k32, 1, 32, ['w2k3', 'w2k3sp[0-9]', 'win2k3', 'win2k3sp[0-9]']],
97 [ 'WindowsVista', 'WindowsVista', g_k32, 1, 32, ['vista', 'vistasp[0-9]']],
98 [ 'WindowsVista_64','WindowsVista_64', g_k64, 1, 64, ['vista-64', 'vistasp[0-9]-64',]], # max cpus/cores??
99 [ 'Windows2008', 'Windows2008', g_k32, 1, 64, ['w2k8', 'w2k8sp[0-9]', 'win2k8', 'win2k8sp[0-9]']], # max cpus/cores??
100 [ 'Windows2008_64', 'Windows2008_64', g_k64, 1, 64, ['w2k8r2', 'w2k8r2sp[0-9]', 'win2k8r2', 'win2k8r2sp[0-9]']], # max cpus/cores??
101 [ 'Windows7', 'Windows7', g_k32, 1, 32, ['w7', 'w7sp[0-9]', 'win7',]], # max cpus/cores??
102 [ 'Windows7_64', 'Windows7_64', g_k64, 1, 64, ['w7-64', 'w7sp[0-9]-64', 'win7-64',]], # max cpus/cores??
103 [ 'Windows8', 'Windows8', g_k32 | g_kiNoRaw, 1, 32, ['w8', 'w8sp[0-9]', 'win8',]], # max cpus/cores??
104 [ 'Windows8_64', 'Windows8_64', g_k64, 1, 64, ['w8-64', 'w8sp[0-9]-64', 'win8-64',]], # max cpus/cores??
105 [ 'Windows81', 'Windows81', g_k32 | g_kiNoRaw, 1, 32, ['w81', 'w81sp[0-9]', 'win81',]], # max cpus/cores??
106 [ 'Windows81_64', 'Windows81_64', g_k64, 1, 64, ['w81-64', 'w81sp[0-9]-64', 'win81-64',]], # max cpus/cores??
107 [ 'Windows10', 'Windows10', g_k32 | g_kiNoRaw, 1, 32, ['w10', 'w10sp[0-9]', 'win10',]], # max cpus/cores??
108 [ 'Windows10_64', 'Windows10_64', g_k64, 1, 64, ['w10-64', 'w10sp[0-9]-64', 'win10-64',]], # max cpus/cores??
109 [ 'Linux', 'Debian', g_k32, 1, 256, ['deb[0-9]*', 'debian[0-9]*', ]],
110 [ 'Linux_64', 'Debian_64', g_k64, 1, 256, ['deb[0-9]*-64', 'debian[0-9]*-64', ]],
111 [ 'Linux', 'RedHat', g_k32, 1, 256, ['rhel', 'rhel[0-9]', 'rhel[0-9]u[0-9]']],
112 [ 'Linux', 'Fedora', g_k32, 1, 256, ['fedora', 'fedora[0-9]*', ]],
113 [ 'Linux_64', 'Fedora_64', g_k64, 1, 256, ['fedora-64', 'fedora[0-9]*-64', ]],
114 [ 'Linux', 'Oracle', g_k32, 1, 256, ['ols[0-9]*', 'oel[0-9]*', ]],
115 [ 'Linux_64', 'Oracle_64', g_k64, 1, 256, ['ols[0-9]*-64', 'oel[0-9]*-64', ]],
116 [ 'Linux', 'OpenSUSE', g_k32, 1, 256, ['opensuse[0-9]*', 'suse[0-9]*', ]],
117 [ 'Linux_64', 'OpenSUSE_64', g_k64, 1, 256, ['opensuse[0-9]*-64', 'suse[0-9]*-64', ]],
118 [ 'Linux', 'Ubuntu', g_k32, 1, 256, ['ubuntu[0-9]*', ]],
119 [ 'Linux_64', 'Ubuntu_64', g_k64, 1, 256, ['ubuntu[0-9]*-64', ]],
120 [ 'Linux', 'ArchLinux', g_k32, 1, 256, ['arch[0-9]*', ]],
121 [ 'Linux_64', 'ArchLinux_64', g_k64, 1, 256, ['arch[0-9]*-64', ]],
122 [ 'Solaris', 'Solaris', g_k32, 1, 256, ['sol10', 'sol10u[0-9]']],
123 [ 'Solaris_64', 'Solaris_64', g_k64, 1, 256, ['sol10-64', 'sol10u-64[0-9]']],
124 [ 'Solaris_64', 'Solaris11_64', g_k64, 1, 256, ['sol11u1']],
125 [ 'BSD', 'FreeBSD_64', g_k32_64, 1, 1, ['bs-.*']], # boot sectors, wanted 64-bit type.
126 [ 'DOS', 'DOS', g_k32, 1, 1, ['bs-.*']],
127];
128
129
130## @name Guest OS type string constants.
131## @{
132g_ksGuestOsTypeDarwin = 'darwin';
133g_ksGuestOsTypeDOS = 'dos';
134g_ksGuestOsTypeFreeBSD = 'freebsd';
135g_ksGuestOsTypeLinux = 'linux';
136g_ksGuestOsTypeOS2 = 'os2';
137g_ksGuestOsTypeSolaris = 'solaris';
138g_ksGuestOsTypeWindows = 'windows';
139## @}
140
141## @name String constants for paravirtualization providers.
142## @{
143g_ksParavirtProviderNone = 'none';
144g_ksParavirtProviderDefault = 'default';
145g_ksParavirtProviderLegacy = 'legacy';
146g_ksParavirtProviderMinimal = 'minimal';
147g_ksParavirtProviderHyperV = 'hyperv';
148g_ksParavirtProviderKVM = 'kvm';
149## @}
150
151## Valid paravirtualization providers.
152g_kasParavirtProviders = ( g_ksParavirtProviderNone, g_ksParavirtProviderDefault, g_ksParavirtProviderLegacy,
153 g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM );
154
155# Mapping for support of paravirtualisation providers per guest OS.
156#g_kdaParavirtProvidersSupported = {
157# g_ksGuestOsTypeDarwin : ( g_ksParavirtProviderMinimal, ),
158# g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, ),
159# g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
160# g_ksGuestOsTypeOS2 : ( g_ksParavirtProviderNone, ),
161# g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
162# g_ksGuestOsTypeWindows : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, )
163#}
164# Temporary tweak:
165# since for the most guests g_ksParavirtProviderNone is almost the same as g_ksParavirtProviderMinimal,
166# g_ksParavirtProviderMinimal is removed from the list in order to get maximum number of unique choices
167# during independent test runs when paravirt provider is taken randomly.
168g_kdaParavirtProvidersSupported = {
169 g_ksGuestOsTypeDarwin : ( g_ksParavirtProviderMinimal, ),
170 g_ksGuestOsTypeDOS : ( g_ksParavirtProviderNone, ),
171 g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, ),
172 g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
173 g_ksGuestOsTypeOS2 : ( g_ksParavirtProviderNone, ),
174 g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
175 g_ksGuestOsTypeWindows : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, )
176}
177
178
179# pylint: enable=C0301
180
181def _intersects(asSet1, asSet2):
182 """
183 Checks if any of the strings in set 1 matches any of the regular
184 expressions in set 2.
185 """
186 for sStr1 in asSet1:
187 for sRx2 in asSet2:
188 if re.match(sStr1, sRx2 + '$'):
189 return True;
190 return False;
191
192
193class TestVm(object):
194 """
195 A Test VM - name + VDI/whatever.
196
197 This is just a data object.
198 """
199
200 def __init__(self, # pylint: disable=R0913
201 sVmName, # type: str
202 fGrouping = 0, # type: int
203 oSet = None, # type: TestVmSet
204 sHd = None, # type: str
205 sKind = None, # type: str
206 acCpusSup = None, # type: List[int]
207 asVirtModesSup = None, # type: List[str]
208 fIoApic = None, # type: bool
209 fNstHwVirt = False, # type: bool
210 fPae = None, # type: bool
211 sNic0AttachType = None, # type: str
212 sFloppy = None, # type: str
213 fVmmDevTestingPart = None, # type: bool
214 fVmmDevTestingMmio = False, # type: bool
215 asParavirtModesSup = None, # type: List[str]
216 fRandomPvPMode = False, # type: bool
217 sFirmwareType = 'bios', # type: str
218 sChipsetType = 'piix3', # type: str
219 sHddControllerType = 'IDE Controller', # type: str
220 sDvdControllerType = 'IDE Controller' # type: str
221 ):
222 self.oSet = oSet;
223 self.sVmName = sVmName;
224 self.fGrouping = fGrouping;
225 self.sHd = sHd; # Relative to the testrsrc root.
226 self.acCpusSup = acCpusSup;
227 self.asVirtModesSup = asVirtModesSup;
228 self.asParavirtModesSup = asParavirtModesSup;
229 self.asParavirtModesSupOrg = asParavirtModesSup; # HACK ALERT! Trick to make the 'effing random mess not get in the
230 # way of actively selecting virtualization modes.
231 self.sKind = sKind;
232 self.sGuestOsType = None;
233 self.sDvdImage = None; # Relative to the testrsrc root.
234 self.sDvdControllerType = sDvdControllerType;
235 self.fIoApic = fIoApic;
236 self.fNstHwVirt = fNstHwVirt;
237 self.fPae = fPae;
238 self.sNic0AttachType = sNic0AttachType;
239 self.sHddControllerType = sHddControllerType;
240 self.sFloppy = sFloppy; # Relative to the testrsrc root, except when it isn't...
241 self.fVmmDevTestingPart = fVmmDevTestingPart;
242 self.fVmmDevTestingMmio = fVmmDevTestingMmio;
243 self.sFirmwareType = sFirmwareType;
244 self.sChipsetType = sChipsetType;
245 self.fCom1RawFile = False;
246
247 self.fSnapshotRestoreCurrent = False; # Whether to restore execution on the current snapshot.
248 self.fSkip = False; # All VMs are included in the configured set by default.
249 self.aInfo = None;
250 self.sCom1RawFile = None; # Set by createVmInner and getReconfiguredVm if fCom1RawFile is set.
251 self._guessStuff(fRandomPvPMode);
252
253 def _mkCanonicalGuestOSType(self, sType):
254 """
255 Convert guest OS type into constant representation.
256 Raise exception if specified @param sType is unknown.
257 """
258 if sType.lower().startswith('darwin'):
259 return g_ksGuestOsTypeDarwin
260 if sType.lower().startswith('bsd'):
261 return g_ksGuestOsTypeFreeBSD
262 if sType.lower().startswith('dos'):
263 return g_ksGuestOsTypeDOS
264 if sType.lower().startswith('linux'):
265 return g_ksGuestOsTypeLinux
266 if sType.lower().startswith('os2'):
267 return g_ksGuestOsTypeOS2
268 if sType.lower().startswith('solaris'):
269 return g_ksGuestOsTypeSolaris
270 if sType.lower().startswith('windows'):
271 return g_ksGuestOsTypeWindows
272 raise base.GenError(sWhat="unknown guest OS kind: %s" % str(sType))
273
274 def _guessStuff(self, fRandomPvPMode):
275 """
276 Used by the constructor to guess stuff.
277 """
278
279 sNm = self.sVmName.lower().strip();
280 asSplit = sNm.replace('-', ' ').split(' ');
281
282 if self.sKind is None:
283 # From name.
284 for aInfo in g_aaNameToDetails:
285 if _intersects(asSplit, aInfo[g_iRegEx]):
286 self.aInfo = aInfo;
287 self.sGuestOsType = self._mkCanonicalGuestOSType(aInfo[g_iGuestOsType])
288 self.sKind = aInfo[g_iKind];
289 break;
290 if self.sKind is None:
291 reporter.fatal('The OS of test VM "%s" cannot be guessed' % (self.sVmName,));
292
293 # Check for 64-bit, if required and supported.
294 if (self.aInfo[g_iFlags] & g_kiArchMask) == g_k32_64 and _intersects(asSplit, ['64', 'amd64']):
295 self.sKind = self.sKind + '_64';
296 else:
297 # Lookup the kind.
298 for aInfo in g_aaNameToDetails:
299 if self.sKind == aInfo[g_iKind]:
300 self.aInfo = aInfo;
301 break;
302 if self.aInfo is None:
303 reporter.fatal('The OS of test VM "%s" with sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
304
305 # Translate sKind into sGuest OS Type.
306 if self.sGuestOsType is None:
307 if self.aInfo is not None:
308 self.sGuestOsType = self._mkCanonicalGuestOSType(self.aInfo[g_iGuestOsType])
309 elif self.sKind.find("Windows") >= 0:
310 self.sGuestOsType = g_ksGuestOsTypeWindows
311 elif self.sKind.find("Linux") >= 0:
312 self.sGuestOsType = g_ksGuestOsTypeLinux;
313 elif self.sKind.find("Solaris") >= 0:
314 self.sGuestOsType = g_ksGuestOsTypeSolaris;
315 elif self.sKind.find("DOS") >= 0:
316 self.sGuestOsType = g_ksGuestOsTypeDOS;
317 else:
318 reporter.fatal('The OS of test VM "%s", sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
319
320 # Restrict modes and such depending on the OS.
321 if self.asVirtModesSup is None:
322 self.asVirtModesSup = list(g_asVirtModes);
323 if self.sGuestOsType in (g_ksGuestOsTypeOS2, g_ksGuestOsTypeDarwin) \
324 or self.sKind.find('_64') > 0 \
325 or (self.aInfo is not None and (self.aInfo[g_iFlags] & g_kiNoRaw)):
326 self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
327 # TEMPORARY HACK - START
328 sHostName = os.environ.get("COMPUTERNAME", None);
329 if sHostName: sHostName = sHostName.lower();
330 else: sHostName = socket.getfqdn(); # Horribly slow on windows without IPv6 DNS/whatever.
331 if sHostName.startswith('testboxpile1'):
332 self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
333 # TEMPORARY HACK - END
334
335 # Restrict the CPU count depending on the OS and/or percieved SMP readiness.
336 if self.acCpusSup is None:
337 if _intersects(asSplit, ['uni']):
338 self.acCpusSup = [1];
339 elif self.aInfo is not None:
340 self.acCpusSup = [i for i in range(self.aInfo[g_iMinCpu], self.aInfo[g_iMaxCpu]) ];
341 else:
342 self.acCpusSup = [1];
343
344 # Figure relevant PV modes based on the OS.
345 if self.asParavirtModesSup is None:
346 self.asParavirtModesSup = g_kdaParavirtProvidersSupported[self.sGuestOsType];
347 ## @todo Remove this hack as soon as we've got around to explictly configure test variations
348 ## on the server side. Client side random is interesting but not the best option.
349 self.asParavirtModesSupOrg = self.asParavirtModesSup;
350 if fRandomPvPMode:
351 random.seed();
352 self.asParavirtModesSup = (random.choice(self.asParavirtModesSup),);
353
354 return True;
355
356 def getNonCanonicalGuestOsType(self):
357 """
358 Gets the non-canonical OS type (self.sGuestOsType is canonical).
359 """
360 return self.aInfo[g_iGuestOsType];
361
362 def getMissingResources(self, sTestRsrc):
363 """
364 Returns a list of missing resources (paths, stuff) that the VM needs.
365 """
366 asRet = [];
367 for sPath in [ self.sHd, self.sDvdImage, self.sFloppy]:
368 if sPath is not None:
369 if not os.path.isabs(sPath):
370 sPath = os.path.join(sTestRsrc, sPath);
371 if not os.path.exists(sPath):
372 asRet.append(sPath);
373 return asRet;
374
375 def createVm(self, oTestDrv, eNic0AttachType = None, sDvdImage = None):
376 """
377 Creates the VM with defaults and the few tweaks as per the arguments.
378
379 Returns same as vbox.TestDriver.createTestVM.
380 """
381 if sDvdImage is not None:
382 sMyDvdImage = sDvdImage;
383 else:
384 sMyDvdImage = self.sDvdImage;
385
386 if eNic0AttachType is not None:
387 eMyNic0AttachType = eNic0AttachType;
388 elif self.sNic0AttachType is None:
389 eMyNic0AttachType = None;
390 elif self.sNic0AttachType == 'nat':
391 eMyNic0AttachType = vboxcon.NetworkAttachmentType_NAT;
392 elif self.sNic0AttachType == 'bridged':
393 eMyNic0AttachType = vboxcon.NetworkAttachmentType_Bridged;
394 else:
395 assert False, self.sNic0AttachType;
396
397 return self.createVmInner(oTestDrv, eMyNic0AttachType, sMyDvdImage);
398
399 def _generateRawPortFilename(self, oTestDrv, sInfix, sSuffix):
400 """ Generates a raw port filename. """
401 random.seed();
402 sRandom = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(10));
403 return os.path.join(oTestDrv.sScratchPath, self.sVmName + sInfix + sRandom + sSuffix);
404
405 def createVmInner(self, oTestDrv, eNic0AttachType, sDvdImage):
406 """
407 Same as createVm but parameters resolved.
408
409 Returns same as vbox.TestDriver.createTestVM.
410 """
411 reporter.log2('');
412 reporter.log2('Calling createTestVM on %s...' % (self.sVmName,))
413 if self.fCom1RawFile:
414 self.sCom1RawFile = self._generateRawPortFilename(oTestDrv, '-com1-', '.out');
415 return oTestDrv.createTestVM(self.sVmName,
416 1, # iGroup
417 sHd = self.sHd,
418 sKind = self.sKind,
419 fIoApic = self.fIoApic,
420 fNstHwVirt = self.fNstHwVirt,
421 fPae = self.fPae,
422 eNic0AttachType = eNic0AttachType,
423 sDvdImage = sDvdImage,
424 sDvdControllerType = self.sDvdControllerType,
425 sHddControllerType = self.sHddControllerType,
426 sFloppy = self.sFloppy,
427 fVmmDevTestingPart = self.fVmmDevTestingPart,
428 fVmmDevTestingMmio = self.fVmmDevTestingPart,
429 sFirmwareType = self.sFirmwareType,
430 sChipsetType = self.sChipsetType,
431 sCom1RawFile = self.sCom1RawFile if self.fCom1RawFile else None
432 );
433
434 def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
435 """
436 actionExecute worker that finds and reconfigure a test VM.
437
438 Returns (fRc, oVM) where fRc is True, None or False and oVM is a
439 VBox VM object that is only present when rc is True.
440 """
441
442 fRc = False;
443 oVM = oTestDrv.getVmByName(self.sVmName);
444 if oVM is not None:
445 if self.fSnapshotRestoreCurrent is True:
446 fRc = True;
447 else:
448 fHostSupports64bit = oTestDrv.hasHostLongMode();
449 if self.is64bitRequired() and not fHostSupports64bit:
450 fRc = None; # Skip the test.
451 elif self.isViaIncompatible() and oTestDrv.isHostCpuVia():
452 fRc = None; # Skip the test.
453 elif self.isShanghaiIncompatible() and oTestDrv.isHostCpuShanghai():
454 fRc = None; # Skip the test.
455 elif self.isP4Incompatible() and oTestDrv.isHostCpuP4():
456 fRc = None; # Skip the test.
457 else:
458 oSession = oTestDrv.openSession(oVM);
459 if oSession is not None:
460 fRc = oSession.enableVirtEx(sVirtMode != 'raw');
461 fRc = fRc and oSession.enableNestedPaging(sVirtMode == 'hwvirt-np');
462 fRc = fRc and oSession.setCpuCount(cCpus);
463 if cCpus > 1:
464 fRc = fRc and oSession.enableIoApic(True);
465
466 if sParavirtMode is not None and oSession.fpApiVer >= 5.0:
467 adParavirtProviders = {
468 g_ksParavirtProviderNone : vboxcon.ParavirtProvider_None,
469 g_ksParavirtProviderDefault: vboxcon.ParavirtProvider_Default,
470 g_ksParavirtProviderLegacy : vboxcon.ParavirtProvider_Legacy,
471 g_ksParavirtProviderMinimal: vboxcon.ParavirtProvider_Minimal,
472 g_ksParavirtProviderHyperV : vboxcon.ParavirtProvider_HyperV,
473 g_ksParavirtProviderKVM : vboxcon.ParavirtProvider_KVM,
474 };
475 fRc = fRc and oSession.setParavirtProvider(adParavirtProviders[sParavirtMode]);
476
477 fCfg64Bit = self.is64bitRequired() or (self.is64bit() and fHostSupports64bit and sVirtMode != 'raw');
478 fRc = fRc and oSession.enableLongMode(fCfg64Bit);
479 if fCfg64Bit: # This is to avoid GUI pedantic warnings in the GUI. Sigh.
480 oOsType = oSession.getOsType();
481 if oOsType is not None:
482 if oOsType.is64Bit and sVirtMode == 'raw':
483 assert(oOsType.id[-3:] == '_64');
484 fRc = fRc and oSession.setOsType(oOsType.id[:-3]);
485 elif not oOsType.is64Bit and sVirtMode != 'raw':
486 fRc = fRc and oSession.setOsType(oOsType.id + '_64');
487
488 # New serial raw file.
489 if fRc and self.fCom1RawFile:
490 self.sCom1RawFile = self._generateRawPortFilename(oTestDrv, '-com1-', '.out');
491 utils.noxcptDeleteFile(self.sCom1RawFile);
492 fRc = oSession.setupSerialToRawFile(0, self.sCom1RawFile);
493
494 # Make life simpler for child classes.
495 if fRc:
496 fRc = self._childVmReconfig(oTestDrv, oVM, oSession);
497
498 fRc = fRc and oSession.saveSettings();
499 if not oSession.close():
500 fRc = False;
501 if fRc is True:
502 return (True, oVM);
503 return (fRc, None);
504
505 def _childVmReconfig(self, oTestDrv, oVM, oSession):
506 """ Hook into getReconfiguredVm() for children. """
507 _ = oTestDrv; _ = oVM; _ = oSession;
508 return True;
509
510 def isWindows(self):
511 """ Checks if it's a Windows VM. """
512 return self.sGuestOsType == g_ksGuestOsTypeWindows;
513
514 def isOS2(self):
515 """ Checks if it's an OS/2 VM. """
516 return self.sGuestOsType == g_ksGuestOsTypeOS2;
517
518 def isLinux(self):
519 """ Checks if it's an Linux VM. """
520 return self.sGuestOsType == g_ksGuestOsTypeLinux;
521
522 def is64bit(self):
523 """ Checks if it's a 64-bit VM. """
524 return self.sKind.find('_64') >= 0;
525
526 def is64bitRequired(self):
527 """ Check if 64-bit is required or not. """
528 return (self.aInfo[g_iFlags] & g_k64) != 0;
529
530 def isLoggedOntoDesktop(self):
531 """ Checks if the test VM is logging onto a graphical desktop by default. """
532 if self.isWindows():
533 return True;
534 if self.isOS2():
535 return True;
536 if self.sVmName.find('-desktop'):
537 return True;
538 return False;
539
540 def isViaIncompatible(self):
541 """
542 Identifies VMs that doesn't work on VIA.
543
544 Returns True if NOT supported on VIA, False if it IS supported.
545 """
546 # Oracle linux doesn't like VIA in our experience
547 if self.aInfo[g_iKind] in ['Oracle', 'Oracle_64']:
548 return True;
549 # OS/2: "The system detected an internal processing error at location
550 # 0168:fff1da1f - 000e:ca1f. 0a8606fd
551 if self.isOS2():
552 return True;
553 # Windows NT4 before SP4 won't work because of cmpxchg8b not being
554 # detected, leading to a STOP 3e(80,0,0,0).
555 if self.aInfo[g_iKind] == 'WindowsNT4':
556 if self.sVmName.find('sp') < 0:
557 return True; # no service pack.
558 if self.sVmName.find('sp0') >= 0 \
559 or self.sVmName.find('sp1') >= 0 \
560 or self.sVmName.find('sp2') >= 0 \
561 or self.sVmName.find('sp3') >= 0:
562 return True;
563 # XP x64 on a physical VIA box hangs exactly like a VM.
564 if self.aInfo[g_iKind] in ['WindowsXP_64', 'Windows2003_64']:
565 return True;
566 # Vista 64 throws BSOD 0x5D (UNSUPPORTED_PROCESSOR)
567 if self.aInfo[g_iKind] in ['WindowsVista_64']:
568 return True;
569 # Solaris 11 hangs on VIA, tested on a physical box (testboxvqc)
570 if self.aInfo[g_iKind] in ['Solaris11_64']:
571 return True;
572 return False;
573
574 def isShanghaiIncompatible(self):
575 """
576 Identifies VMs that doesn't work on Shanghai.
577
578 Returns True if NOT supported on Shanghai, False if it IS supported.
579 """
580 # For now treat it just like VIA, to be adjusted later
581 return self.isViaIncompatible()
582
583 def isP4Incompatible(self):
584 """
585 Identifies VMs that doesn't work on Pentium 4 / Pentium D.
586
587 Returns True if NOT supported on P4, False if it IS supported.
588 """
589 # Stupid 1 kHz timer. Too much for antique CPUs.
590 if self.sVmName.find('rhel5') >= 0:
591 return True;
592 # Due to the boot animation the VM takes forever to boot.
593 if self.aInfo[g_iKind] == 'Windows2000':
594 return True;
595 return False;
596
597
598class BootSectorTestVm(TestVm):
599 """
600 A Boot Sector Test VM.
601 """
602
603 def __init__(self, oSet, sVmName, sFloppy = None, asVirtModesSup = None, f64BitRequired = False):
604 self.f64BitRequired = f64BitRequired;
605 if asVirtModesSup is None:
606 asVirtModesSup = list(g_asVirtModes);
607 TestVm.__init__(self, sVmName,
608 oSet = oSet,
609 acCpusSup = [1,],
610 sFloppy = sFloppy,
611 asVirtModesSup = asVirtModesSup,
612 fPae = True,
613 fIoApic = True,
614 fVmmDevTestingPart = True,
615 fVmmDevTestingMmio = True,
616 );
617
618 def is64bitRequired(self):
619 return self.f64BitRequired;
620
621
622class AncientTestVm(TestVm):
623 """
624 A ancient Test VM, using the serial port for communicating results.
625
626 We're looking for 'PASSED' and 'FAILED' lines in the COM1 output.
627 """
628
629
630 def __init__(self, # pylint: disable=R0913
631 sVmName, # type: str
632 fGrouping = g_kfGrpAncient | g_kfGrpNoTxs, # type: int
633 sHd = None, # type: str
634 sKind = None, # type: str
635 acCpusSup = None, # type: List[int]
636 asVirtModesSup = None, # type: List[str]
637 sNic0AttachType = None, # type: str
638 sFloppy = None, # type: str
639 sFirmwareType = 'bios', # type: str
640 sChipsetType = 'piix3', # type: str
641 sHddControllerName = 'IDE Controller', # type: str
642 sDvdControllerName = 'IDE Controller', # type: str
643 cMBRamMax = None, # type: int
644 ):
645 TestVm.__init__(self,
646 sVmName,
647 fGrouping = fGrouping,
648 sHd = sHd,
649 sKind = sKind,
650 acCpusSup = [1] if acCpusSup is None else acCpusSup,
651 asVirtModesSup = asVirtModesSup,
652 sNic0AttachType = sNic0AttachType,
653 sFloppy = sFloppy,
654 sFirmwareType = sFirmwareType,
655 sChipsetType = sChipsetType,
656 sHddControllerType = sHddControllerName,
657 sDvdControllerType = sDvdControllerName,
658 asParavirtModesSup = (g_ksParavirtProviderNone,)
659 );
660 self.fCom1RawFile = True;
661 self.cMBRamMax= cMBRamMax;
662
663
664 def _childVmReconfig(self, oTestDrv, oVM, oSession):
665 _ = oVM; _ = oTestDrv;
666 fRc = True;
667
668 # DOS 4.01 doesn't like the default 32MB of memory.
669 if fRc and self.cMBRamMax is not None:
670 try:
671 cMBRam = oSession.o.machine.memorySize;
672 except:
673 cMBRam = self.cMBRamMax + 4;
674 if self.cMBRamMax < cMBRam:
675 fRc = oSession.setRamSize(self.cMBRamMax);
676
677 return fRc;
678
679
680class TestVmSet(object):
681 """
682 A set of Test VMs.
683 """
684
685 def __init__(self, oTestVmManager = None, acCpus = None, asVirtModes = None, fIgnoreSkippedVm = False):
686 self.oTestVmManager = oTestVmManager;
687 if acCpus is None:
688 acCpus = [1, 2];
689 self.acCpusDef = acCpus;
690 self.acCpus = acCpus;
691 if asVirtModes is None:
692 asVirtModes = list(g_asVirtModes);
693 self.asVirtModesDef = asVirtModes;
694 self.asVirtModes = asVirtModes;
695 self.aoTestVms = [];
696 self.fIgnoreSkippedVm = fIgnoreSkippedVm;
697 self.asParavirtModes = None; ##< If None, use the first PV mode of the test VM, otherwise all modes in this list.
698
699 def findTestVmByName(self, sVmName):
700 """
701 Returns the TestVm object with the given name.
702 Returns None if not found.
703 """
704
705 # The 'tst-' prefix is optional.
706 sAltName = sVmName if sVmName.startswith('tst-') else 'tst-' + sVmName;
707
708 for oTestVm in self.aoTestVms:
709 if oTestVm.sVmName == sVmName or oTestVm.sVmName == sAltName:
710 return oTestVm;
711 return None;
712
713 def getAllVmNames(self, sSep = ':'):
714 """
715 Returns names of all the test VMs in the set separated by
716 sSep (defaults to ':').
717 """
718 sVmNames = '';
719 for oTestVm in self.aoTestVms:
720 sName = oTestVm.sVmName;
721 if sName.startswith('tst-'):
722 sName = sName[4:];
723 if sVmNames == '':
724 sVmNames = sName;
725 else:
726 sVmNames = sVmNames + sSep + sName;
727 return sVmNames;
728
729 def showUsage(self):
730 """
731 Invoked by vbox.TestDriver.
732 """
733 reporter.log('');
734 reporter.log('Test VM selection and general config options:');
735 reporter.log(' --virt-modes <m1[:m2[:...]]>');
736 reporter.log(' Default: %s' % (':'.join(self.asVirtModesDef)));
737 reporter.log(' --skip-virt-modes <m1[:m2[:...]]>');
738 reporter.log(' Use this to avoid hwvirt or hwvirt-np when not supported by the host');
739 reporter.log(' since we cannot detect it using the main API. Use after --virt-modes.');
740 reporter.log(' --cpu-counts <c1[:c2[:...]]>');
741 reporter.log(' Default: %s' % (':'.join(str(c) for c in self.acCpusDef)));
742 reporter.log(' --test-vms <vm1[:vm2[:...]]>');
743 reporter.log(' Test the specified VMs in the given order. Use this to change');
744 reporter.log(' the execution order or limit the choice of VMs');
745 reporter.log(' Default: %s (all)' % (self.getAllVmNames(),));
746 reporter.log(' --skip-vms <vm1[:vm2[:...]]>');
747 reporter.log(' Skip the specified VMs when testing.');
748 reporter.log(' --snapshot-restore-current');
749 reporter.log(' Restores the current snapshot and resumes execution.');
750 reporter.log(' --paravirt-modes <pv1[:pv2[:...]]>');
751 reporter.log(' Set of paravirtualized providers (modes) to tests. Intersected with what the test VM supports.');
752 reporter.log(' Default is the first PV mode the test VMs support, generally same as "legacy".');
753 reporter.log(' --with-nested-hwvirt-only');
754 reporter.log(' Test VMs using nested hardware-virtualization only.');
755 reporter.log(' --without-nested-hwvirt-only');
756 reporter.log(' Test VMs not using nested hardware-virtualization only.');
757 ## @todo Add more options for controlling individual VMs.
758 return True;
759
760 def parseOption(self, asArgs, iArg):
761 """
762 Parses the set test vm set options (--test-vms and --skip-vms), modifying the set
763 Invoked by the testdriver method with the same name.
764
765 Keyword arguments:
766 asArgs -- The argument vector.
767 iArg -- The index of the current argument.
768
769 Returns iArg if the option was not recognized and the caller should handle it.
770 Returns the index of the next argument when something is consumed.
771
772 In the event of a syntax error, a InvalidOption or QuietInvalidOption
773 is thrown.
774 """
775
776 if asArgs[iArg] == '--virt-modes':
777 iArg += 1;
778 if iArg >= len(asArgs):
779 raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
780
781 self.asVirtModes = asArgs[iArg].split(':');
782 for s in self.asVirtModes:
783 if s not in self.asVirtModesDef:
784 raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
785 % (s, ' '.join(self.asVirtModesDef)));
786
787 elif asArgs[iArg] == '--skip-virt-modes':
788 iArg += 1;
789 if iArg >= len(asArgs):
790 raise base.InvalidOption('The "--skip-virt-modes" takes a colon separated list of modes');
791
792 for s in asArgs[iArg].split(':'):
793 if s not in self.asVirtModesDef:
794 raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
795 % (s, ' '.join(self.asVirtModesDef)));
796 if s in self.asVirtModes:
797 self.asVirtModes.remove(s);
798
799 elif asArgs[iArg] == '--cpu-counts':
800 iArg += 1;
801 if iArg >= len(asArgs):
802 raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
803
804 self.acCpus = [];
805 for s in asArgs[iArg].split(':'):
806 try: c = int(s);
807 except: raise base.InvalidOption('The "--cpu-counts" value "%s" is not an integer' % (s,));
808 if c <= 0: raise base.InvalidOption('The "--cpu-counts" value "%s" is zero or negative' % (s,));
809 self.acCpus.append(c);
810
811 elif asArgs[iArg] == '--test-vms':
812 iArg += 1;
813 if iArg >= len(asArgs):
814 raise base.InvalidOption('The "--test-vms" takes colon separated list');
815
816 for oTestVm in self.aoTestVms:
817 oTestVm.fSkip = True;
818
819 asTestVMs = asArgs[iArg].split(':');
820 for s in asTestVMs:
821 oTestVm = self.findTestVmByName(s);
822 if oTestVm is None:
823 raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
824 % (s, self.getAllVmNames(' ')));
825 oTestVm.fSkip = False;
826
827 elif asArgs[iArg] == '--skip-vms':
828 iArg += 1;
829 if iArg >= len(asArgs):
830 raise base.InvalidOption('The "--skip-vms" takes colon separated list');
831
832 asTestVMs = asArgs[iArg].split(':');
833 for s in asTestVMs:
834 oTestVm = self.findTestVmByName(s);
835 if oTestVm is None:
836 reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s,));
837 else:
838 oTestVm.fSkip = True;
839
840 elif asArgs[iArg] == '--snapshot-restore-current':
841 for oTestVm in self.aoTestVms:
842 if oTestVm.fSkip is False:
843 oTestVm.fSnapshotRestoreCurrent = True;
844 reporter.log('VM "%s" will be restored.' % (oTestVm.sVmName));
845
846 elif asArgs[iArg] == '--paravirt-modes':
847 iArg += 1
848 if iArg >= len(asArgs):
849 raise base.InvalidOption('The "--paravirt-modes" takes a colon separated list of modes');
850
851 self.asParavirtModes = asArgs[iArg].split(':')
852 for sPvMode in self.asParavirtModes:
853 if sPvMode not in g_kasParavirtProviders:
854 raise base.InvalidOption('The "--paravirt-modes" value "%s" is not valid; valid values are: %s'
855 % (sPvMode, ', '.join(g_kasParavirtProviders),));
856 if not self.asParavirtModes:
857 self.asParavirtModes = None;
858
859 # HACK ALERT! Reset the random paravirt selection for members.
860 for oTestVm in self.aoTestVms:
861 oTestVm.asParavirtModesSup = oTestVm.asParavirtModesSupOrg;
862
863 elif asArgs[iArg] == '--with-nested-hwvirt-only':
864 for oTestVm in self.aoTestVms:
865 if oTestVm.fNstHwVirt is False:
866 oTestVm.fSkip = True;
867
868 elif asArgs[iArg] == '--without-nested-hwvirt-only':
869 for oTestVm in self.aoTestVms:
870 if oTestVm.fNstHwVirt is True:
871 oTestVm.fSkip = True;
872
873 else:
874 return iArg;
875 return iArg + 1;
876
877 def getResourceSet(self):
878 """
879 Implements base.TestDriver.getResourceSet
880 """
881 asResources = [];
882 for oTestVm in self.aoTestVms:
883 if not oTestVm.fSkip:
884 if oTestVm.sHd is not None:
885 asResources.append(oTestVm.sHd);
886 if oTestVm.sDvdImage is not None:
887 asResources.append(oTestVm.sDvdImage);
888 return asResources;
889
890 def actionConfig(self, oTestDrv, eNic0AttachType = None, sDvdImage = None):
891 """
892 For base.TestDriver.actionConfig. Configure the VMs with defaults and
893 a few tweaks as per arguments.
894
895 Returns True if successful.
896 Returns False if not.
897 """
898
899 for oTestVm in self.aoTestVms:
900 if oTestVm.fSkip:
901 continue;
902
903 if oTestVm.fSnapshotRestoreCurrent:
904 # If we want to restore a VM we don't need to create
905 # the machine anymore -- so just add it to the test VM list.
906 oVM = oTestDrv.addTestMachine(oTestVm.sVmName);
907 else:
908 oVM = oTestVm.createVm(oTestDrv, eNic0AttachType, sDvdImage);
909 if oVM is None:
910 return False;
911
912 return True;
913
914 def _removeUnsupportedVirtModes(self, oTestDrv):
915 """
916 Removes unsupported virtualization modes.
917 """
918 if 'hwvirt' in self.asVirtModes and not oTestDrv.hasHostHwVirt():
919 reporter.log('Hardware assisted virtualization is not available on the host, skipping it.');
920 self.asVirtModes.remove('hwvirt');
921
922 if 'hwvirt-np' in self.asVirtModes and not oTestDrv.hasHostNestedPaging():
923 reporter.log('Nested paging not supported by the host, skipping it.');
924 self.asVirtModes.remove('hwvirt-np');
925
926 if 'raw' in self.asVirtModes and not oTestDrv.hasRawModeSupport():
927 reporter.log('Raw-mode virtualization is not available in this build (or perhaps for this host), skipping it.');
928 self.asVirtModes.remove('raw');
929
930 return True;
931
932 def actionExecute(self, oTestDrv, fnCallback): # pylint: disable=R0914
933 """
934 For base.TestDriver.actionExecute. Calls the callback function for
935 each of the VMs and basic configuration variations (virt-mode and cpu
936 count).
937
938 Returns True if all fnCallback calls returned True, otherwise False.
939
940 The callback can return True, False or None. The latter is for when the
941 test is skipped. (True is for success, False is for failure.)
942 """
943
944 self._removeUnsupportedVirtModes(oTestDrv);
945 cMaxCpus = oTestDrv.getHostCpuCount();
946
947 #
948 # The test loop.
949 #
950 fRc = True;
951 for oTestVm in self.aoTestVms:
952 if oTestVm.fNstHwVirt and not oTestDrv.isHostCpuAmd():
953 reporter.log('Ignoring VM %s (Nested hardware-virtualization only supported on AMD CPUs).' % (oTestVm.sVmName,));
954 continue;
955 if oTestVm.fSkip and self.fIgnoreSkippedVm:
956 reporter.log2('Ignoring VM %s (fSkip = True).' % (oTestVm.sVmName,));
957 continue;
958 reporter.testStart(oTestVm.sVmName);
959 if oTestVm.fSkip:
960 reporter.testDone(fSkipped = True);
961 continue;
962
963 # Intersect the supported modes and the ones being testing.
964 asVirtModesSup = [sMode for sMode in oTestVm.asVirtModesSup if sMode in self.asVirtModes];
965
966 # Ditto for CPUs.
967 acCpusSup = [cCpus for cCpus in oTestVm.acCpusSup if cCpus in self.acCpus];
968
969 # Ditto for paravirtualization modes, except if not specified we got a less obvious default.
970 if self.asParavirtModes is not None and oTestDrv.fpApiVer >= 5.0:
971 asParavirtModes = [sPvMode for sPvMode in oTestVm.asParavirtModesSup if sPvMode in self.asParavirtModes];
972 assert None not in asParavirtModes;
973 elif oTestDrv.fpApiVer >= 5.0:
974 asParavirtModes = (oTestVm.asParavirtModesSup[0],);
975 assert asParavirtModes[0] is not None;
976 else:
977 asParavirtModes = (None,);
978
979 for cCpus in acCpusSup:
980 if cCpus == 1:
981 reporter.testStart('1 cpu');
982 else:
983 reporter.testStart('%u cpus' % (cCpus));
984 if cCpus > cMaxCpus:
985 reporter.testDone(fSkipped = True);
986 continue;
987
988 cTests = 0;
989 for sVirtMode in asVirtModesSup:
990 if sVirtMode == 'raw' and cCpus > 1:
991 continue;
992 reporter.testStart('%s' % ( g_dsVirtModeDescs[sVirtMode], ) );
993 cStartTests = cTests;
994
995 for sParavirtMode in asParavirtModes:
996 if sParavirtMode is not None:
997 assert oTestDrv.fpApiVer >= 5.0;
998 reporter.testStart('%s' % ( sParavirtMode, ) );
999
1000 # Reconfigure the VM.
1001 try:
1002 (rc2, oVM) = oTestVm.getReconfiguredVm(oTestDrv, cCpus, sVirtMode, sParavirtMode = sParavirtMode);
1003 except KeyboardInterrupt:
1004 raise;
1005 except:
1006 reporter.errorXcpt(cFrames = 9);
1007 rc2 = False;
1008 if rc2 is True:
1009 # Do the testing.
1010 try:
1011 rc2 = fnCallback(oVM, oTestVm);
1012 except KeyboardInterrupt:
1013 raise;
1014 except:
1015 reporter.errorXcpt(cFrames = 9);
1016 rc2 = False;
1017 if rc2 is False:
1018 reporter.maybeErr(reporter.testErrorCount() == 0, 'fnCallback failed');
1019 elif rc2 is False:
1020 reporter.log('getReconfiguredVm failed');
1021 if rc2 is False:
1022 fRc = False;
1023
1024 cTests = cTests + (rc2 is not None);
1025 if sParavirtMode is not None:
1026 reporter.testDone(fSkipped = (rc2 is None));
1027
1028 reporter.testDone(fSkipped = cTests == cStartTests);
1029
1030 reporter.testDone(fSkipped = cTests == 0);
1031
1032 _, cErrors = reporter.testDone();
1033 if cErrors > 0:
1034 fRc = False;
1035 return fRc;
1036
1037 def enumerateTestVms(self, fnCallback):
1038 """
1039 Enumerates all the 'active' VMs.
1040
1041 Returns True if all fnCallback calls returned True.
1042 Returns False if any returned False.
1043 Returns None immediately if fnCallback returned None.
1044 """
1045 fRc = True;
1046 for oTestVm in self.aoTestVms:
1047 if not oTestVm.fSkip:
1048 fRc2 = fnCallback(oTestVm);
1049 if fRc2 is None:
1050 return fRc2;
1051 fRc = fRc and fRc2;
1052 return fRc;
1053
1054
1055
1056class TestVmManager(object):
1057 """
1058 Test VM manager.
1059 """
1060
1061 ## @name VM grouping flags
1062 ## @{
1063 kfGrpSmoke = g_kfGrpSmoke;
1064 kfGrpStandard = g_kfGrpStandard;
1065 kfGrpStdSmoke = g_kfGrpStdSmoke;
1066 kfGrpWithGAs = g_kfGrpWithGAs;
1067 kfGrpNoTxs = g_kfGrpNoTxs;
1068 kfGrpAncient = g_kfGrpAncient;
1069 kfGrpExotic = g_kfGrpExotic;
1070 ## @}
1071
1072 kaTestVMs = (
1073 # Linux
1074 TestVm('tst-ubuntu-15_10-64-efi', kfGrpStdSmoke, sHd = '4.2/efi/ubuntu-15_10-efi-amd64.vdi',
1075 sKind = 'Ubuntu_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi',
1076 asParavirtModesSup = [g_ksParavirtProviderKVM,]),
1077 TestVm('tst-rhel5', kfGrpSmoke, sHd = '3.0/tcp/rhel5.vdi',
1078 sKind = 'RedHat', acCpusSup = range(1, 33), fIoApic = True, sNic0AttachType = 'nat'),
1079 TestVm('tst-arch', kfGrpStandard, sHd = '4.2/usb/tst-arch.vdi',
1080 sKind = 'ArchLinux_64', acCpusSup = range(1, 33), fIoApic = True, sNic0AttachType = 'nat'),
1081 # disabled 2019-03-08 klaus - fails all over the place and pollutes the test results
1082 #TestVm('tst-ubuntu-1804-64', kfGrpStdSmoke, sHd = '4.2/ubuntu-1804/t-ubuntu-1804-64.vdi',
1083 # sKind = 'Ubuntu_64', acCpusSup = range(1, 33), fIoApic = True),
1084 TestVm('tst-ol76-64', kfGrpStdSmoke, sHd = '4.2/ol76/t-ol76-64.vdi',
1085 sKind = 'Oracle_64', acCpusSup = range(1, 33), fIoApic = True),
1086
1087 # Solaris
1088 TestVm('tst-sol10', kfGrpSmoke, sHd = '3.0/tcp/solaris10.vdi',
1089 sKind = 'Solaris', acCpusSup = range(1, 33), fPae = True, sNic0AttachType = 'bridged'),
1090 TestVm('tst-sol10-64', kfGrpSmoke, sHd = '3.0/tcp/solaris10.vdi',
1091 sKind = 'Solaris_64', acCpusSup = range(1, 33), sNic0AttachType = 'bridged'),
1092 TestVm('tst-sol11u1', kfGrpSmoke, sHd = '4.2/nat/sol11u1/t-sol11u1.vdi',
1093 sKind = 'Solaris11_64', acCpusSup = range(1, 33), sNic0AttachType = 'nat', fIoApic = True,
1094 sHddControllerType = 'SATA Controller'),
1095 #TestVm('tst-sol11u1-ich9', kfGrpSmoke, sHd = '4.2/nat/sol11u1/t-sol11u1.vdi',
1096 # sKind = 'Solaris11_64', acCpusSup = range(1, 33), sNic0AttachType = 'nat', fIoApic = True,
1097 # sHddControllerType = 'SATA Controller', sChipsetType = 'ich9'),
1098
1099 # NT 3.x
1100 TestVm('tst-nt310', kfGrpAncient, sHd = '5.2/great-old-ones/t-nt310/t-nt310.vdi',
1101 sKind = 'WindowsNT3x', acCpusSup = [1], sHddControllerType = 'BusLogic SCSI Controller',
1102 sDvdControllerType = 'BusLogic SCSI Controller'),
1103 TestVm('tst-nt350', kfGrpAncient, sHd = '5.2/great-old-ones/t-nt350/t-nt350.vdi',
1104 sKind = 'WindowsNT3x', acCpusSup = [1], sHddControllerType = 'BusLogic SCSI Controller',
1105 sDvdControllerType = 'BusLogic SCSI Controller'),
1106 TestVm('tst-nt351', kfGrpAncient, sHd = '5.2/great-old-ones/t-nt350/t-nt351.vdi',
1107 sKind = 'WindowsNT3x', acCpusSup = [1], sHddControllerType = 'BusLogic SCSI Controller',
1108 sDvdControllerType = 'BusLogic SCSI Controller'),
1109
1110 # NT 4
1111 TestVm('tst-nt4sp1', kfGrpStdSmoke, sHd = '4.2/nat/nt4sp1/t-nt4sp1.vdi',
1112 sKind = 'WindowsNT4', acCpusSup = [1], sNic0AttachType = 'nat'),
1113
1114 TestVm('tst-nt4sp6', kfGrpStdSmoke, sHd = '4.2/nt4sp6/t-nt4sp6.vdi',
1115 sKind = 'WindowsNT4', acCpusSup = range(1, 33)),
1116
1117 # W2K
1118 TestVm('tst-2ksp4', kfGrpStdSmoke, sHd = '4.2/win2ksp4/t-win2ksp4.vdi',
1119 sKind = 'Windows2000', acCpusSup = range(1, 33)),
1120
1121 # XP
1122 TestVm('tst-xppro', kfGrpStdSmoke, sHd = '4.2/nat/xppro/t-xppro.vdi',
1123 sKind = 'WindowsXP', acCpusSup = range(1, 33), sNic0AttachType = 'nat'),
1124 TestVm('tst-xpsp2', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxpsp2.vdi',
1125 sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
1126 TestVm('tst-xpsp2-halaacpi', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halaacpi.vdi',
1127 sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
1128 TestVm('tst-xpsp2-halacpi', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halacpi.vdi',
1129 sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
1130 TestVm('tst-xpsp2-halapic', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halapic.vdi',
1131 sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True),
1132 TestVm('tst-xpsp2-halmacpi', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halmacpi.vdi',
1133 sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True),
1134 TestVm('tst-xpsp2-halmps', kfGrpStdSmoke, sHd = '4.2/xpsp2/t-winxp-halmps.vdi',
1135 sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True),
1136
1137 # W2K3
1138 TestVm('tst-win2k3ent', kfGrpSmoke, sHd = '3.0/tcp/win2k3ent-acpi.vdi',
1139 sKind = 'Windows2003', acCpusSup = range(1, 33), fPae = True, sNic0AttachType = 'bridged'),
1140
1141 # W7
1142 TestVm('tst-win7', kfGrpStdSmoke, sHd = '4.2/win7-32/t-win7.vdi',
1143 sKind = 'Windows7', acCpusSup = range(1, 33), fIoApic = True),
1144
1145 # W8
1146 TestVm('tst-win8-64', kfGrpStdSmoke, sHd = '4.2/win8-64/t-win8-64.vdi',
1147 sKind = 'Windows8_64', acCpusSup = range(1, 33), fIoApic = True),
1148 #TestVm('tst-win8-64-ich9', kfGrpStdSmoke, sHd = '4.2/win8-64/t-win8-64.vdi',
1149 # sKind = 'Windows8_64', acCpusSup = range(1, 33), fIoApic = True, sChipsetType = 'ich9'),
1150
1151 # W10
1152 TestVm('tst-win10-efi', kfGrpStdSmoke, sHd = '4.2/efi/win10-efi-x86.vdi',
1153 sKind = 'Windows10', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi'),
1154 TestVm('tst-win10-64-efi', kfGrpStdSmoke, sHd = '4.2/efi/win10-efi-amd64.vdi',
1155 sKind = 'Windows10_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi'),
1156 #TestVm('tst-win10-64-efi-ich9', kfGrpStdSmoke, sHd = '4.2/efi/win10-efi-amd64.vdi',
1157 # sKind = 'Windows10_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi', sChipsetType = 'ich9'),
1158
1159 # Nested hardware-virtualization
1160 TestVm('tst-nsthwvirt-ubuntu-64', kfGrpStdSmoke, sHd = '5.3/nat/nsthwvirt-ubuntu64/t-nsthwvirt-ubuntu64.vdi',
1161 sKind = 'Ubuntu_64', acCpusSup = range(1, 2), asVirtModesSup = ['hwvirt-np',], fIoApic = True, fNstHwVirt = True,
1162 sNic0AttachType = 'nat'),
1163
1164 # DOS and Old Windows.
1165 AncientTestVm('tst-dos20', sKind = 'DOS',
1166 sHd = '5.2/great-old-ones/t-dos20/t-dos20.vdi'),
1167 AncientTestVm('tst-dos401-win30me', sKind = 'DOS',
1168 sHd = '5.2/great-old-ones/t-dos401-win30me/t-dos401-win30me.vdi', cMBRamMax = 4),
1169 AncientTestVm('tst-dos401-emm386-win30me', sKind = 'DOS',
1170 sHd = '5.2/great-old-ones/t-dos401-emm386-win30me/t-dos401-emm386-win30me.vdi', cMBRamMax = 4),
1171 AncientTestVm('tst-dos50-win31', sKind = 'DOS',
1172 sHd = '5.2/great-old-ones/t-dos50-win31/t-dos50-win31.vdi'),
1173 AncientTestVm('tst-dos50-emm386-win31', sKind = 'DOS',
1174 sHd = '5.2/great-old-ones/t-dos50-emm386-win31/t-dos50-emm386-win31.vdi'),
1175 AncientTestVm('tst-dos622', sKind = 'DOS',
1176 sHd = '5.2/great-old-ones/t-dos622/t-dos622.vdi'),
1177 AncientTestVm('tst-dos622-emm386', sKind = 'DOS',
1178 sHd = '5.2/great-old-ones/t-dos622-emm386/t-dos622-emm386.vdi'),
1179 AncientTestVm('tst-dos71', sKind = 'DOS',
1180 sHd = '5.2/great-old-ones/t-dos71/t-dos71.vdi'),
1181
1182 #AncientTestVm('tst-dos5-win311a', sKind = 'DOS', sHd = '5.2/great-old-ones/t-dos5-win311a/t-dos5-win311a.vdi'),
1183 );
1184
1185
1186 def __init__(self, sResourcePath):
1187 self.sResourcePath = sResourcePath;
1188
1189 def selectSet(self, fGrouping, sTxsTransport = None, fCheckResources = True):
1190 """
1191 Returns a VM set with the selected VMs.
1192 """
1193 oSet = TestVmSet(oTestVmManager = self);
1194 for oVm in self.kaTestVMs:
1195 if oVm.fGrouping & fGrouping:
1196 if sTxsTransport is None or oVm.sNic0AttachType is None or sTxsTransport == oVm.sNic0AttachType:
1197 if not fCheckResources or not oVm.getMissingResources(self.sResourcePath):
1198 oCopyVm = copy.deepcopy(oVm);
1199 oCopyVm.oSet = oSet;
1200 oSet.aoTestVms.append(oCopyVm);
1201 return oSet;
1202
1203 def getStandardVmSet(self, sTxsTransport):
1204 """
1205 Gets the set of standard test VMs.
1206
1207 This is supposed to do something seriously clever, like searching the
1208 testrsrc tree for usable VMs, but for the moment it's all hard coded. :-)
1209 """
1210 return self.selectSet(self.kfGrpStandard, sTxsTransport)
1211
1212 def getSmokeVmSet(self, sTxsTransport = None):
1213 """Gets a representative set of VMs for smoke testing. """
1214 return self.selectSet(self.kfGrpSmoke, sTxsTransport);
1215
1216 def shutUpPyLint(self):
1217 """ Shut up already! """
1218 return self.sResourcePath;
1219
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette