1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: vboxtestvms.py 58992 2015-12-04 15:23:23Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | VirtualBox Test VMs
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2010-2015 Oracle Corporation
|
---|
11 |
|
---|
12 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | available from http://www.virtualbox.org. This file is free software;
|
---|
14 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | General Public License (GPL) as published by the Free Software
|
---|
16 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 |
|
---|
20 | The contents of this file may alternatively be used under the terms
|
---|
21 | of the Common Development and Distribution License Version 1.0
|
---|
22 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
23 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
24 | CDDL are applicable instead of those of the GPL.
|
---|
25 |
|
---|
26 | You may elect to license modified versions of this file under the
|
---|
27 | terms and conditions of either the GPL or the CDDL or both.
|
---|
28 | """
|
---|
29 | __version__ = "$Revision: 58992 $"
|
---|
30 |
|
---|
31 | # Standard Python imports.
|
---|
32 | import re;
|
---|
33 | import random;
|
---|
34 | import socket;
|
---|
35 |
|
---|
36 | # Validation Kit imports.
|
---|
37 | from testdriver import base;
|
---|
38 | from testdriver import reporter;
|
---|
39 | from testdriver import vboxcon;
|
---|
40 |
|
---|
41 |
|
---|
42 | # All virtualization modes.
|
---|
43 | g_asVirtModes = ['hwvirt', 'hwvirt-np', 'raw',];
|
---|
44 | # All virtualization modes except for raw-mode.
|
---|
45 | g_asVirtModesNoRaw = ['hwvirt', 'hwvirt-np',];
|
---|
46 | # Dictionary mapping the virtualization mode mnemonics to a little less cryptic
|
---|
47 | # strings used in test descriptions.
|
---|
48 | g_dsVirtModeDescs = {
|
---|
49 | 'raw' : 'Raw-mode',
|
---|
50 | 'hwvirt' : 'HwVirt',
|
---|
51 | 'hwvirt-np' : 'NestedPaging'
|
---|
52 | };
|
---|
53 |
|
---|
54 | ## @name Flags.
|
---|
55 | ## @{
|
---|
56 | g_k32 = 32; # pylint: disable=C0103
|
---|
57 | g_k64 = 64; # pylint: disable=C0103
|
---|
58 | g_k32_64 = 96; # pylint: disable=C0103
|
---|
59 | g_kiArchMask = 96;
|
---|
60 | g_kiNoRaw = 128; ##< No raw mode.
|
---|
61 | ## @}
|
---|
62 |
|
---|
63 | # Array indexes.
|
---|
64 | g_iGuestOsType = 0;
|
---|
65 | g_iKind = 1;
|
---|
66 | g_iFlags = 2;
|
---|
67 | g_iMinCpu = 3;
|
---|
68 | g_iMaxCpu = 4;
|
---|
69 | g_iRegEx = 5;
|
---|
70 |
|
---|
71 | # Table translating from VM name core to a more detailed guest info.
|
---|
72 | # pylint: disable=C0301
|
---|
73 | g_aaNameToDetails = \
|
---|
74 | [
|
---|
75 | [ 'WindowsNT4', 'WindowsNT4', g_k32, 1, 32, ['nt4', 'nt4sp[0-9]']], # max cpus??
|
---|
76 | [ 'Windows2000', 'Windows2000', g_k32, 1, 32, ['w2k', 'w2ksp[0-9]', 'win2k', 'win2ksp[0-9]']], # max cpus??
|
---|
77 | [ 'WindowsXP', 'WindowsXP', g_k32, 1, 32, ['xp', 'xpsp[0-9]']],
|
---|
78 | [ 'WindowsXP_64', 'WindowsXP_64', g_k64, 1, 32, ['xp64', 'xp64sp[0-9]']],
|
---|
79 | [ 'Windows2003', 'Windows2003', g_k32, 1, 32, ['w2k3', 'w2k3sp[0-9]', 'win2k3', 'win2k3sp[0-9]']],
|
---|
80 | [ 'WindowsVista', 'WindowsVista', g_k32, 1, 32, ['vista', 'vistasp[0-9]']],
|
---|
81 | [ 'Windows2008', 'Windows2008', g_k32, 1, 64, ['w2k8', 'w2k8sp[0-9]', 'win2k8', 'win2k8sp[0-9]']], # max cpus/cores??
|
---|
82 | [ 'Windows2008_64', 'Windows2008_64', g_k64, 1, 64, ['w2k8r2', 'w2k8r2sp[0-9]', 'win2k8r2', 'win2k8r2sp[0-9]']], # max cpus/cores??
|
---|
83 | [ 'Windows7', 'Windows7', g_k32, 1, 32, ['w7', 'w7sp[0-9]', 'win7',]], # max cpus/cores??
|
---|
84 | [ 'Windows7_64', 'Windows7_64', g_k64, 1, 64, ['w7-64', 'w7sp[0-9]-64', 'win7-64',]], # max cpus/cores??
|
---|
85 | [ 'Windows8', 'Windows8', g_k32 | g_kiNoRaw, 1, 32, ['w8', 'w8sp[0-9]', 'win8',]], # max cpus/cores??
|
---|
86 | [ 'Windows8_64', 'Windows8_64', g_k64, 1, 64, ['w8-64', 'w8sp[0-9]-64', 'win8-64',]], # max cpus/cores??
|
---|
87 | [ 'Windows81', 'Windows81', g_k32 | g_kiNoRaw, 1, 32, ['w81', 'w81sp[0-9]', 'win81',]], # max cpus/cores??
|
---|
88 | [ 'Windows81_64', 'Windows81_64', g_k64, 1, 64, ['w81-64', 'w81sp[0-9]-64', 'win81-64',]], # max cpus/cores??
|
---|
89 | [ 'Windows10', 'Windows10', g_k32 | g_kiNoRaw, 1, 32, ['w10', 'w10sp[0-9]', 'win10',]], # max cpus/cores??
|
---|
90 | [ 'Windows10_64', 'Windows10_64', g_k64, 1, 64, ['w10-64', 'w10sp[0-9]-64', 'win10-64',]], # max cpus/cores??
|
---|
91 | [ 'Linux', 'Debian', g_k32, 1, 256, ['deb[0-9]*', 'debian[0-9]*', ]],
|
---|
92 | [ 'Linux_64', 'Debian_64', g_k64, 1, 256, ['deb[0-9]*-64', 'debian[0-9]*-64', ]],
|
---|
93 | [ 'Linux', 'RedHat', g_k32, 1, 256, ['rhel', 'rhel[0-9]', 'rhel[0-9]u[0-9]']],
|
---|
94 | [ 'Linux', 'Fedora', g_k32, 1, 256, ['fedora', 'fedora[0-9]*', ]],
|
---|
95 | [ 'Linux_64', 'Fedora_64', g_k64, 1, 256, ['fedora-64', 'fedora[0-9]*-64', ]],
|
---|
96 | [ 'Linux', 'Oracle', g_k32, 1, 256, ['ols[0-9]*', 'oel[0-9]*', ]],
|
---|
97 | [ 'Linux_64', 'Oracle_64', g_k64, 1, 256, ['ols[0-9]*-64', 'oel[0-9]*-64', ]],
|
---|
98 | [ 'Linux', 'OpenSUSE', g_k32, 1, 256, ['opensuse[0-9]*', 'suse[0-9]*', ]],
|
---|
99 | [ 'Linux_64', 'OpenSUSE_64', g_k64, 1, 256, ['opensuse[0-9]*-64', 'suse[0-9]*-64', ]],
|
---|
100 | [ 'Linux', 'Ubuntu', g_k32, 1, 256, ['ubuntu[0-9]*', ]],
|
---|
101 | [ 'Linux_64', 'Ubuntu_64', g_k64, 1, 256, ['ubuntu[0-9]*-64', ]],
|
---|
102 | [ 'Solaris', 'Solaris', g_k32, 1, 256, ['sol10', 'sol10u[0-9]']],
|
---|
103 | [ 'Solaris_64', 'Solaris_64', g_k64, 1, 256, ['sol10-64', 'sol10u-64[0-9]']],
|
---|
104 | [ 'Solaris_64', 'Solaris11_64', g_k64, 1, 256, ['sol11u1']],
|
---|
105 | [ 'BSD', 'FreeBSD_64', g_k32_64, 1, 1, ['bs-.*']], # boot sectors, wanted 64-bit type.
|
---|
106 | ];
|
---|
107 |
|
---|
108 |
|
---|
109 | ## @name Guest OS type string constants.
|
---|
110 | ## @{
|
---|
111 | g_ksGuestOsTypeDarwin = 'darwin';
|
---|
112 | g_ksGuestOsTypeFreeBSD = 'freebsd';
|
---|
113 | g_ksGuestOsTypeLinux = 'linux';
|
---|
114 | g_ksGuestOsTypeOS2 = 'os2';
|
---|
115 | g_ksGuestOsTypeSolaris = 'solaris';
|
---|
116 | g_ksGuestOsTypeWindows = 'windows';
|
---|
117 | ## @}
|
---|
118 |
|
---|
119 | ## @name String constants for paravirtualization providers.
|
---|
120 | ## @{
|
---|
121 | g_ksParavirtProviderNone = 'none';
|
---|
122 | g_ksParavirtProviderDefault = 'default';
|
---|
123 | g_ksParavirtProviderLegacy = 'legacy';
|
---|
124 | g_ksParavirtProviderMinimal = 'minimal';
|
---|
125 | g_ksParavirtProviderHyperV = 'hyperv';
|
---|
126 | g_ksParavirtProviderKVM = 'kvm';
|
---|
127 | ## @}
|
---|
128 |
|
---|
129 | ## Valid paravirtualization providers.
|
---|
130 | g_kasParavirtProviders = ( g_ksParavirtProviderNone, g_ksParavirtProviderDefault, g_ksParavirtProviderLegacy,
|
---|
131 | g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM );
|
---|
132 |
|
---|
133 | # Mapping for support of paravirtualisation providers per guest OS.
|
---|
134 | #g_kdaParavirtProvidersSupported = {
|
---|
135 | # g_ksGuestOsTypeDarwin : ( g_ksParavirtProviderMinimal, ),
|
---|
136 | # g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, ),
|
---|
137 | # g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
|
---|
138 | # g_ksGuestOsTypeOS2 : ( g_ksParavirtProviderNone, ),
|
---|
139 | # g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
|
---|
140 | # g_ksGuestOsTypeWindows : ( g_ksParavirtProviderNone, g_ksParavirtProviderMinimal, g_ksParavirtProviderHyperV, )
|
---|
141 | #}
|
---|
142 | # Temporary tweak:
|
---|
143 | # since for the most guests g_ksParavirtProviderNone is almost the same as g_ksParavirtProviderMinimal,
|
---|
144 | # g_ksParavirtProviderMinimal is removed from the list in order to get maximum number of unique choices
|
---|
145 | # during independent test runs when paravirt provider is taken randomly.
|
---|
146 | g_kdaParavirtProvidersSupported = {
|
---|
147 | g_ksGuestOsTypeDarwin : ( g_ksParavirtProviderMinimal, ),
|
---|
148 | g_ksGuestOsTypeFreeBSD : ( g_ksParavirtProviderNone, ),
|
---|
149 | g_ksGuestOsTypeLinux : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, g_ksParavirtProviderKVM),
|
---|
150 | g_ksGuestOsTypeOS2 : ( g_ksParavirtProviderNone, ),
|
---|
151 | g_ksGuestOsTypeSolaris : ( g_ksParavirtProviderNone, ),
|
---|
152 | g_ksGuestOsTypeWindows : ( g_ksParavirtProviderNone, g_ksParavirtProviderHyperV, )
|
---|
153 | }
|
---|
154 |
|
---|
155 |
|
---|
156 | # pylint: enable=C0301
|
---|
157 |
|
---|
158 | def _intersects(asSet1, asSet2):
|
---|
159 | """
|
---|
160 | Checks if any of the strings in set 1 matches any of the regular
|
---|
161 | expressions in set 2.
|
---|
162 | """
|
---|
163 | for sStr1 in asSet1:
|
---|
164 | for sRx2 in asSet2:
|
---|
165 | if re.match(sStr1, sRx2 + '$'):
|
---|
166 | return True;
|
---|
167 | return False;
|
---|
168 |
|
---|
169 |
|
---|
170 | class TestVm(object):
|
---|
171 | """
|
---|
172 | A Test VM - name + VDI/whatever.
|
---|
173 |
|
---|
174 | This is just a data object.
|
---|
175 | """
|
---|
176 |
|
---|
177 | def __init__(self, oSet, sVmName, sHd = None, sKind = None, acCpusSup = None, asVirtModesSup = None, # pylint: disable=R0913
|
---|
178 | fIoApic = None, fPae = None, sNic0AttachType = None, sHddControllerType = 'IDE Controller',
|
---|
179 | sFloppy = None, fVmmDevTestingPart = None, fVmmDevTestingMmio = False, asParavirtModesSup = None,
|
---|
180 | fRandomPvPMode = False, sFirmwareType = 'bios'):
|
---|
181 | self.oSet = oSet;
|
---|
182 | self.sVmName = sVmName;
|
---|
183 | self.sHd = sHd; # Relative to the testrsrc root.
|
---|
184 | self.acCpusSup = acCpusSup;
|
---|
185 | self.asVirtModesSup = asVirtModesSup;
|
---|
186 | self.asParavirtModesSup = asParavirtModesSup;
|
---|
187 | self.sKind = sKind;
|
---|
188 | self.sGuestOsType = None;
|
---|
189 | self.sDvdImage = None; # Relative to the testrsrc root.
|
---|
190 | self.fIoApic = fIoApic;
|
---|
191 | self.fPae = fPae;
|
---|
192 | self.sNic0AttachType = sNic0AttachType;
|
---|
193 | self.sHddControllerType = sHddControllerType;
|
---|
194 | self.sFloppy = sFloppy; # Relative to the testrsrc root, except when it isn't...
|
---|
195 | self.fVmmDevTestingPart = fVmmDevTestingPart;
|
---|
196 | self.fVmmDevTestingMmio = fVmmDevTestingMmio;
|
---|
197 | self.sFirmwareType = sFirmwareType;
|
---|
198 |
|
---|
199 | self.fSnapshotRestoreCurrent = False; # Whether to restore execution on the current snapshot.
|
---|
200 | self.fSkip = False; # All VMs are included in the configured set by default.
|
---|
201 | self.aInfo = None;
|
---|
202 | self._guessStuff(fRandomPvPMode);
|
---|
203 |
|
---|
204 | def _mkCanonicalGuestOSType(self, sType):
|
---|
205 | """
|
---|
206 | Convert guest OS type into constant representation.
|
---|
207 | Raise exception if specified @param sType is unknown.
|
---|
208 | """
|
---|
209 | if sType.lower().startswith('darwin'):
|
---|
210 | return g_ksGuestOsTypeDarwin
|
---|
211 | if sType.lower().startswith('bsd'):
|
---|
212 | return g_ksGuestOsTypeFreeBSD
|
---|
213 | if sType.lower().startswith('linux'):
|
---|
214 | return g_ksGuestOsTypeLinux
|
---|
215 | if sType.lower().startswith('os2'):
|
---|
216 | return g_ksGuestOsTypeOS2
|
---|
217 | if sType.lower().startswith('solaris'):
|
---|
218 | return g_ksGuestOsTypeSolaris
|
---|
219 | if sType.lower().startswith('windows'):
|
---|
220 | return g_ksGuestOsTypeWindows
|
---|
221 | raise base.GenError(sWhat="unknown guest OS kind: %s" % str(sType))
|
---|
222 |
|
---|
223 | def _guessStuff(self, fRandomPvPMode):
|
---|
224 | """
|
---|
225 | Used by the constructor to guess stuff.
|
---|
226 | """
|
---|
227 |
|
---|
228 | sNm = self.sVmName.lower().strip();
|
---|
229 | asSplit = sNm.replace('-', ' ').split(' ');
|
---|
230 |
|
---|
231 | if self.sKind is None:
|
---|
232 | # From name.
|
---|
233 | for aInfo in g_aaNameToDetails:
|
---|
234 | if _intersects(asSplit, aInfo[g_iRegEx]):
|
---|
235 | self.aInfo = aInfo;
|
---|
236 | self.sGuestOsType = self._mkCanonicalGuestOSType(aInfo[g_iGuestOsType])
|
---|
237 | self.sKind = aInfo[g_iKind];
|
---|
238 | break;
|
---|
239 | if self.sKind is None:
|
---|
240 | reporter.fatal('The OS of test VM "%s" cannot be guessed' % (self.sVmName,));
|
---|
241 |
|
---|
242 | # Check for 64-bit, if required and supported.
|
---|
243 | if (self.aInfo[g_iFlags] & g_kiArchMask) == g_k32_64 and _intersects(asSplit, ['64', 'amd64']):
|
---|
244 | self.sKind = self.sKind + '_64';
|
---|
245 | else:
|
---|
246 | # Lookup the kind.
|
---|
247 | for aInfo in g_aaNameToDetails:
|
---|
248 | if self.sKind == aInfo[g_iKind]:
|
---|
249 | self.aInfo = aInfo;
|
---|
250 | break;
|
---|
251 | if self.aInfo is None:
|
---|
252 | reporter.fatal('The OS of test VM "%s" with sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
|
---|
253 |
|
---|
254 | # Translate sKind into sGuest OS Type.
|
---|
255 | if self.sGuestOsType is None:
|
---|
256 | if self.aInfo is not None:
|
---|
257 | self.sGuestOsType = self._mkCanonicalGuestOSType(self.aInfo[g_iGuestOsType])
|
---|
258 | elif self.sKind.find("Windows") >= 0:
|
---|
259 | self.sGuestOsType = g_ksGuestOsTypeWindows
|
---|
260 | elif self.sKind.find("Linux") >= 0:
|
---|
261 | self.sGuestOsType = g_ksGuestOsTypeLinux;
|
---|
262 | elif self.sKind.find("Solaris") >= 0:
|
---|
263 | self.sGuestOsType = g_ksGuestOsTypeSolaris;
|
---|
264 | else:
|
---|
265 | reporter.fatal('The OS of test VM "%s", sKind="%s" cannot be guessed' % (self.sVmName, self.sKind));
|
---|
266 |
|
---|
267 | # Restrict modes and such depending on the OS.
|
---|
268 | if self.asVirtModesSup is None:
|
---|
269 | self.asVirtModesSup = list(g_asVirtModes);
|
---|
270 | if self.sGuestOsType in (g_ksGuestOsTypeOS2, g_ksGuestOsTypeDarwin) \
|
---|
271 | or self.sKind.find('_64') > 0 \
|
---|
272 | or (self.aInfo is not None and (self.aInfo[g_iFlags] & g_kiNoRaw)):
|
---|
273 | self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
|
---|
274 | # TEMPORARY HACK - START
|
---|
275 | sHostName = socket.getfqdn();
|
---|
276 | if sHostName.startswith('testboxpile1'):
|
---|
277 | self.asVirtModesSup = [sVirtMode for sVirtMode in self.asVirtModesSup if sVirtMode != 'raw'];
|
---|
278 | # TEMPORARY HACK - END
|
---|
279 |
|
---|
280 | # Restrict the CPU count depending on the OS and/or percieved SMP readiness.
|
---|
281 | if self.acCpusSup is None:
|
---|
282 | if _intersects(asSplit, ['uni']):
|
---|
283 | self.acCpusSup = [1];
|
---|
284 | elif self.aInfo is not None:
|
---|
285 | self.acCpusSup = [i for i in range(self.aInfo[g_iMinCpu], self.aInfo[g_iMaxCpu]) ];
|
---|
286 | else:
|
---|
287 | self.acCpusSup = [1];
|
---|
288 |
|
---|
289 | # Figure relevant PV modes based on the OS.
|
---|
290 | if self.asParavirtModesSup is None:
|
---|
291 | self.asParavirtModesSup = g_kdaParavirtProvidersSupported[self.sGuestOsType];
|
---|
292 | ## @todo Remove this hack as soon as we've got around to explictly configure test variations
|
---|
293 | ## on the server side. Client side random is interesting but not the best option.
|
---|
294 | if fRandomPvPMode:
|
---|
295 | random.seed();
|
---|
296 | self.asParavirtModesSup = (random.choice(self.asParavirtModesSup),);
|
---|
297 |
|
---|
298 | return True;
|
---|
299 |
|
---|
300 | def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
|
---|
301 | """
|
---|
302 | actionExecute worker that finds and reconfigure a test VM.
|
---|
303 |
|
---|
304 | Returns (fRc, oVM) where fRc is True, None or False and oVM is a
|
---|
305 | VBox VM object that is only present when rc is True.
|
---|
306 | """
|
---|
307 |
|
---|
308 | fRc = False;
|
---|
309 | oVM = oTestDrv.getVmByName(self.sVmName);
|
---|
310 | if oVM is not None:
|
---|
311 | if self.fSnapshotRestoreCurrent is True:
|
---|
312 | fRc = True;
|
---|
313 | else:
|
---|
314 | fHostSupports64bit = oTestDrv.hasHostLongMode();
|
---|
315 | if self.is64bitRequired() and not fHostSupports64bit:
|
---|
316 | fRc = None; # Skip the test.
|
---|
317 | elif self.isViaIncompatible() and oTestDrv.isHostCpuVia():
|
---|
318 | fRc = None; # Skip the test.
|
---|
319 | else:
|
---|
320 | oSession = oTestDrv.openSession(oVM);
|
---|
321 | if oSession is not None:
|
---|
322 | fRc = oSession.enableVirtEx(sVirtMode != 'raw');
|
---|
323 | fRc = fRc and oSession.enableNestedPaging(sVirtMode == 'hwvirt-np');
|
---|
324 | fRc = fRc and oSession.setCpuCount(cCpus);
|
---|
325 |
|
---|
326 | if sParavirtMode is not None and oSession.fpApiVer >= 5.0:
|
---|
327 | adParavirtProviders = {
|
---|
328 | g_ksParavirtProviderNone : vboxcon.ParavirtProvider_None,
|
---|
329 | g_ksParavirtProviderDefault: vboxcon.ParavirtProvider_Default,
|
---|
330 | g_ksParavirtProviderLegacy : vboxcon.ParavirtProvider_Legacy,
|
---|
331 | g_ksParavirtProviderMinimal: vboxcon.ParavirtProvider_Minimal,
|
---|
332 | g_ksParavirtProviderHyperV : vboxcon.ParavirtProvider_HyperV,
|
---|
333 | g_ksParavirtProviderKVM : vboxcon.ParavirtProvider_KVM,
|
---|
334 | };
|
---|
335 | fRc = fRc and oSession.setParavirtProvider(adParavirtProviders[sParavirtMode]);
|
---|
336 |
|
---|
337 | fCfg64Bit = self.is64bitRequired() or (self.is64bit() and fHostSupports64bit and sVirtMode != 'raw');
|
---|
338 | fRc = fRc and oSession.enableLongMode(fCfg64Bit);
|
---|
339 | if fCfg64Bit: # This is to avoid GUI pedantic warnings in the GUI. Sigh.
|
---|
340 | oOsType = oSession.getOsType();
|
---|
341 | if oOsType is not None:
|
---|
342 | if oOsType.is64Bit and sVirtMode == 'raw':
|
---|
343 | assert(oOsType.id[-3:] == '_64');
|
---|
344 | fRc = fRc and oSession.setOsType(oOsType.id[:-3]);
|
---|
345 | elif not oOsType.is64Bit and sVirtMode != 'raw':
|
---|
346 | fRc = fRc and oSession.setOsType(oOsType.id + '_64');
|
---|
347 |
|
---|
348 | fRc = fRc and oSession.saveSettings();
|
---|
349 | if not oSession.close():
|
---|
350 | fRc = False;
|
---|
351 | if fRc is True:
|
---|
352 | return (True, oVM);
|
---|
353 | return (fRc, None);
|
---|
354 |
|
---|
355 |
|
---|
356 | def isWindows(self):
|
---|
357 | """ Checks if it's a Windows VM. """
|
---|
358 | return self.sGuestOsType == g_ksGuestOsTypeWindows;
|
---|
359 |
|
---|
360 | def isOS2(self):
|
---|
361 | """ Checks if it's an OS/2 VM. """
|
---|
362 | return self.sGuestOsType == g_ksGuestOsTypeOS2;
|
---|
363 |
|
---|
364 | def is64bit(self):
|
---|
365 | """ Checks if it's a 64-bit VM. """
|
---|
366 | return self.sKind.find('_64') >= 0;
|
---|
367 |
|
---|
368 | def is64bitRequired(self):
|
---|
369 | """ Check if 64-bit is required or not. """
|
---|
370 | return (self.aInfo[g_iFlags] & g_k64) != 0;
|
---|
371 |
|
---|
372 | def isLoggedOntoDesktop(self):
|
---|
373 | """ Checks if the test VM is logging onto a graphical desktop by default. """
|
---|
374 | if self.isWindows():
|
---|
375 | return True;
|
---|
376 | if self.isOS2():
|
---|
377 | return True;
|
---|
378 | if self.sVmName.find('-desktop'):
|
---|
379 | return True;
|
---|
380 | return False;
|
---|
381 |
|
---|
382 | def isViaIncompatible(self):
|
---|
383 | """
|
---|
384 | Identifies VMs that doesn't work on VIA.
|
---|
385 |
|
---|
386 | Returns True if NOT supported on VIA, False if it IS supported.
|
---|
387 | """
|
---|
388 | # Oracle linux doesn't like VIA in our experience
|
---|
389 | if self.aInfo[g_iKind] in ['Oracle', 'Oracle_64']:
|
---|
390 | return True;
|
---|
391 | # OS/2: "The system detected an internal processing error at location
|
---|
392 | # 0168:fff1da1f - 000e:ca1f. 0a8606fd
|
---|
393 | if self.isOS2():
|
---|
394 | return True;
|
---|
395 | # Windows NT4 before SP4 won't work because of cmpxchg8b not being
|
---|
396 | # detected, leading to a STOP 3e(80,0,0,0).
|
---|
397 | if self.aInfo[g_iKind] == 'WindowsNT4':
|
---|
398 | if self.sVmName.find('sp') < 0:
|
---|
399 | return True; # no service pack.
|
---|
400 | if self.sVmName.find('sp0') >= 0 \
|
---|
401 | or self.sVmName.find('sp1') >= 0 \
|
---|
402 | or self.sVmName.find('sp2') >= 0 \
|
---|
403 | or self.sVmName.find('sp3') >= 0:
|
---|
404 | return True;
|
---|
405 | return False;
|
---|
406 |
|
---|
407 |
|
---|
408 |
|
---|
409 | class BootSectorTestVm(TestVm):
|
---|
410 | """
|
---|
411 | A Boot Sector Test VM.
|
---|
412 | """
|
---|
413 |
|
---|
414 | def __init__(self, oSet, sVmName, sFloppy = None, asVirtModesSup = None, f64BitRequired = False):
|
---|
415 | self.f64BitRequired = f64BitRequired;
|
---|
416 | if asVirtModesSup is None:
|
---|
417 | asVirtModesSup = list(g_asVirtModes);
|
---|
418 | TestVm.__init__(self, oSet, sVmName,
|
---|
419 | acCpusSup = [1,],
|
---|
420 | sFloppy = sFloppy,
|
---|
421 | asVirtModesSup = asVirtModesSup,
|
---|
422 | fPae = True,
|
---|
423 | fIoApic = True,
|
---|
424 | fVmmDevTestingPart = True,
|
---|
425 | fVmmDevTestingMmio = True,
|
---|
426 | );
|
---|
427 |
|
---|
428 | def is64bitRequired(self):
|
---|
429 | return self.f64BitRequired;
|
---|
430 |
|
---|
431 |
|
---|
432 |
|
---|
433 | class TestVmSet(object):
|
---|
434 | """
|
---|
435 | A set of Test VMs.
|
---|
436 | """
|
---|
437 |
|
---|
438 | def __init__(self, oTestVmManager = None, acCpus = None, asVirtModes = None, fIgnoreSkippedVm = False):
|
---|
439 | self.oTestVmManager = oTestVmManager;
|
---|
440 | if acCpus is None:
|
---|
441 | acCpus = [1, 2];
|
---|
442 | self.acCpusDef = acCpus;
|
---|
443 | self.acCpus = acCpus;
|
---|
444 | if asVirtModes is None:
|
---|
445 | asVirtModes = list(g_asVirtModes);
|
---|
446 | self.asVirtModesDef = asVirtModes;
|
---|
447 | self.asVirtModes = asVirtModes;
|
---|
448 | self.aoTestVms = [];
|
---|
449 | self.fIgnoreSkippedVm = fIgnoreSkippedVm;
|
---|
450 | self.asParavirtModes = None; ##< If None, use the first PV mode of the test VM, otherwise all modes in this list.
|
---|
451 |
|
---|
452 | def findTestVmByName(self, sVmName):
|
---|
453 | """
|
---|
454 | Returns the TestVm object with the given name.
|
---|
455 | Returns None if not found.
|
---|
456 | """
|
---|
457 | for oTestVm in self.aoTestVms:
|
---|
458 | if oTestVm.sVmName == sVmName:
|
---|
459 | return oTestVm;
|
---|
460 | return None;
|
---|
461 |
|
---|
462 | def getAllVmNames(self, sSep = ':'):
|
---|
463 | """
|
---|
464 | Returns names of all the test VMs in the set separated by
|
---|
465 | sSep (defaults to ':').
|
---|
466 | """
|
---|
467 | sVmNames = '';
|
---|
468 | for oTestVm in self.aoTestVms:
|
---|
469 | if sVmNames == '':
|
---|
470 | sVmNames = oTestVm.sVmName;
|
---|
471 | else:
|
---|
472 | sVmNames = sVmNames + sSep + oTestVm.sVmName;
|
---|
473 | return sVmNames;
|
---|
474 |
|
---|
475 | def showUsage(self):
|
---|
476 | """
|
---|
477 | Invoked by vbox.TestDriver.
|
---|
478 | """
|
---|
479 | reporter.log('');
|
---|
480 | reporter.log('Test VM selection and general config options:');
|
---|
481 | reporter.log(' --virt-modes <m1[:m2[:]]');
|
---|
482 | reporter.log(' Default: %s' % (':'.join(self.asVirtModesDef)));
|
---|
483 | reporter.log(' --skip-virt-modes <m1[:m2[:]]');
|
---|
484 | reporter.log(' Use this to avoid hwvirt or hwvirt-np when not supported by the host');
|
---|
485 | reporter.log(' since we cannot detect it using the main API. Use after --virt-modes.');
|
---|
486 | reporter.log(' --cpu-counts <c1[:c2[:]]');
|
---|
487 | reporter.log(' Default: %s' % (':'.join(str(c) for c in self.acCpusDef)));
|
---|
488 | reporter.log(' --test-vms <vm1[:vm2[:...]]>');
|
---|
489 | reporter.log(' Test the specified VMs in the given order. Use this to change');
|
---|
490 | reporter.log(' the execution order or limit the choice of VMs');
|
---|
491 | reporter.log(' Default: %s (all)' % (self.getAllVmNames(),));
|
---|
492 | reporter.log(' --skip-vms <vm1[:vm2[:...]]>');
|
---|
493 | reporter.log(' Skip the specified VMs when testing.');
|
---|
494 | reporter.log(' --snapshot-restore-current');
|
---|
495 | reporter.log(' Restores the current snapshot and resumes execution.');
|
---|
496 | reporter.log(' --paravirt-modes <pv1[:pv2[:]]>');
|
---|
497 | reporter.log(' Set of paravirtualized providers (modes) to tests. Intersected with what the test VM supports.');
|
---|
498 | reporter.log(' Default is the first PV mode the test VMs support, generally same as "legacy".');
|
---|
499 | ## @todo Add more options for controlling individual VMs.
|
---|
500 | return True;
|
---|
501 |
|
---|
502 | def parseOption(self, asArgs, iArg):
|
---|
503 | """
|
---|
504 | Parses the set test vm set options (--test-vms and --skip-vms), modifying the set
|
---|
505 | Invoked by the testdriver method with the same name.
|
---|
506 |
|
---|
507 | Keyword arguments:
|
---|
508 | asArgs -- The argument vector.
|
---|
509 | iArg -- The index of the current argument.
|
---|
510 |
|
---|
511 | Returns iArg if the option was not recognized and the caller should handle it.
|
---|
512 | Returns the index of the next argument when something is consumed.
|
---|
513 |
|
---|
514 | In the event of a syntax error, a InvalidOption or QuietInvalidOption
|
---|
515 | is thrown.
|
---|
516 | """
|
---|
517 |
|
---|
518 | if asArgs[iArg] == '--virt-modes':
|
---|
519 | iArg += 1;
|
---|
520 | if iArg >= len(asArgs):
|
---|
521 | raise base.InvalidOption('The "--virt-modes" takes a colon separated list of modes');
|
---|
522 |
|
---|
523 | self.asVirtModes = asArgs[iArg].split(':');
|
---|
524 | for s in self.asVirtModes:
|
---|
525 | if s not in self.asVirtModesDef:
|
---|
526 | raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
|
---|
527 | % (s, ' '.join(self.asVirtModesDef)));
|
---|
528 |
|
---|
529 | elif asArgs[iArg] == '--skip-virt-modes':
|
---|
530 | iArg += 1;
|
---|
531 | if iArg >= len(asArgs):
|
---|
532 | raise base.InvalidOption('The "--skip-virt-modes" takes a colon separated list of modes');
|
---|
533 |
|
---|
534 | for s in asArgs[iArg].split(':'):
|
---|
535 | if s not in self.asVirtModesDef:
|
---|
536 | raise base.InvalidOption('The "--virt-modes" value "%s" is not valid; valid values are: %s' \
|
---|
537 | % (s, ' '.join(self.asVirtModesDef)));
|
---|
538 | if s in self.asVirtModes:
|
---|
539 | self.asVirtModes.remove(s);
|
---|
540 |
|
---|
541 | elif asArgs[iArg] == '--cpu-counts':
|
---|
542 | iArg += 1;
|
---|
543 | if iArg >= len(asArgs):
|
---|
544 | raise base.InvalidOption('The "--cpu-counts" takes a colon separated list of cpu counts');
|
---|
545 |
|
---|
546 | self.acCpus = [];
|
---|
547 | for s in asArgs[iArg].split(':'):
|
---|
548 | try: c = int(s);
|
---|
549 | except: raise base.InvalidOption('The "--cpu-counts" value "%s" is not an integer' % (s,));
|
---|
550 | if c <= 0: raise base.InvalidOption('The "--cpu-counts" value "%s" is zero or negative' % (s,));
|
---|
551 | self.acCpus.append(c);
|
---|
552 |
|
---|
553 | elif asArgs[iArg] == '--test-vms':
|
---|
554 | iArg += 1;
|
---|
555 | if iArg >= len(asArgs):
|
---|
556 | raise base.InvalidOption('The "--test-vms" takes colon separated list');
|
---|
557 |
|
---|
558 | for oTestVm in self.aoTestVms:
|
---|
559 | oTestVm.fSkip = True;
|
---|
560 |
|
---|
561 | asTestVMs = asArgs[iArg].split(':');
|
---|
562 | for s in asTestVMs:
|
---|
563 | oTestVm = self.findTestVmByName(s);
|
---|
564 | if oTestVm is None:
|
---|
565 | raise base.InvalidOption('The "--test-vms" value "%s" is not valid; valid values are: %s' \
|
---|
566 | % (s, self.getAllVmNames(' ')));
|
---|
567 | oTestVm.fSkip = False;
|
---|
568 |
|
---|
569 | elif asArgs[iArg] == '--skip-vms':
|
---|
570 | iArg += 1;
|
---|
571 | if iArg >= len(asArgs):
|
---|
572 | raise base.InvalidOption('The "--skip-vms" takes colon separated list');
|
---|
573 |
|
---|
574 | asTestVMs = asArgs[iArg].split(':');
|
---|
575 | for s in asTestVMs:
|
---|
576 | oTestVm = self.findTestVmByName(s);
|
---|
577 | if oTestVm is None:
|
---|
578 | reporter.log('warning: The "--test-vms" value "%s" does not specify any of our test VMs.' % (s,));
|
---|
579 | else:
|
---|
580 | oTestVm.fSkip = True;
|
---|
581 |
|
---|
582 | elif asArgs[iArg] == '--snapshot-restore-current':
|
---|
583 | for oTestVm in self.aoTestVms:
|
---|
584 | if oTestVm.fSkip is False:
|
---|
585 | oTestVm.fSnapshotRestoreCurrent = True;
|
---|
586 | reporter.log('VM "%s" will be restored.' % (oTestVm.sVmName));
|
---|
587 |
|
---|
588 | elif asArgs[iArg] == '--paravirt-modes':
|
---|
589 | iArg += 1
|
---|
590 | if iArg >= len(asArgs):
|
---|
591 | raise base.InvalidOption('The "--paravirt-modes" takes a colon separated list of modes');
|
---|
592 |
|
---|
593 | self.asParavirtModes = asArgs[iArg].split(':')
|
---|
594 | for sPvMode in self.asParavirtModes:
|
---|
595 | if sPvMode not in g_kasParavirtProviders:
|
---|
596 | raise base.InvalidOption('The "--paravirt-modes" value "%s" is not valid; valid values are: %s'
|
---|
597 | % (sPvMode, ', '.join(g_kasParavirtProviders),));
|
---|
598 | if len(self.asParavirtModes) == 0:
|
---|
599 | self.asParavirtModes = None;
|
---|
600 |
|
---|
601 | else:
|
---|
602 | return iArg;
|
---|
603 | return iArg + 1;
|
---|
604 |
|
---|
605 | def getResourceSet(self):
|
---|
606 | """
|
---|
607 | Implements base.TestDriver.getResourceSet
|
---|
608 | """
|
---|
609 | asResources = [];
|
---|
610 | for oTestVm in self.aoTestVms:
|
---|
611 | if not oTestVm.fSkip:
|
---|
612 | if oTestVm.sHd is not None:
|
---|
613 | asResources.append(oTestVm.sHd);
|
---|
614 | if oTestVm.sDvdImage is not None:
|
---|
615 | asResources.append(oTestVm.sDvdImage);
|
---|
616 | return asResources;
|
---|
617 |
|
---|
618 | def actionConfig(self, oTestDrv, eNic0AttachType = None, sDvdImage = None):
|
---|
619 | """
|
---|
620 | For base.TestDriver.actionConfig. Configure the VMs with defaults and
|
---|
621 | a few tweaks as per arguments.
|
---|
622 |
|
---|
623 | Returns True if successful.
|
---|
624 | Returns False if not.
|
---|
625 | """
|
---|
626 |
|
---|
627 | for oTestVm in self.aoTestVms:
|
---|
628 | if oTestVm.fSkip:
|
---|
629 | continue;
|
---|
630 |
|
---|
631 | if oTestVm.fSnapshotRestoreCurrent:
|
---|
632 | # If we want to restore a VM we don't need to create
|
---|
633 | # the machine anymore -- so just add it to the test VM list.
|
---|
634 | oVM = oTestDrv.addTestMachine(oTestVm.sVmName);
|
---|
635 | else:
|
---|
636 | ## @todo This could possibly be moved to the TestVM object.
|
---|
637 | if sDvdImage is not None:
|
---|
638 | sMyDvdImage = sDvdImage;
|
---|
639 | else:
|
---|
640 | sMyDvdImage = oTestVm.sDvdImage;
|
---|
641 |
|
---|
642 | if eNic0AttachType is not None:
|
---|
643 | eMyNic0AttachType = eNic0AttachType;
|
---|
644 | elif oTestVm.sNic0AttachType is None:
|
---|
645 | eMyNic0AttachType = None;
|
---|
646 | elif oTestVm.sNic0AttachType == 'nat':
|
---|
647 | eMyNic0AttachType = vboxcon.NetworkAttachmentType_NAT;
|
---|
648 | elif oTestVm.sNic0AttachType == 'bridged':
|
---|
649 | eMyNic0AttachType = vboxcon.NetworkAttachmentType_Bridged;
|
---|
650 | else:
|
---|
651 | assert False, oTestVm.sNic0AttachType;
|
---|
652 |
|
---|
653 | oVM = oTestDrv.createTestVM(oTestVm.sVmName, 1, \
|
---|
654 | sHd = oTestVm.sHd, \
|
---|
655 | sKind = oTestVm.sKind, \
|
---|
656 | fIoApic = oTestVm.fIoApic, \
|
---|
657 | fPae = oTestVm.fPae, \
|
---|
658 | eNic0AttachType = eMyNic0AttachType, \
|
---|
659 | sDvdImage = sMyDvdImage, \
|
---|
660 | sHddControllerType = oTestVm.sHddControllerType,
|
---|
661 | sFloppy = oTestVm.sFloppy,
|
---|
662 | fVmmDevTestingPart = oTestVm.fVmmDevTestingPart,
|
---|
663 | fVmmDevTestingMmio = oTestVm.fVmmDevTestingPart,
|
---|
664 | sFirmwareType = oTestVm.sFirmwareType);
|
---|
665 | if oVM is None:
|
---|
666 | return False;
|
---|
667 |
|
---|
668 | return True;
|
---|
669 |
|
---|
670 | def _removeUnsupportedVirtModes(self, oTestDrv):
|
---|
671 | """
|
---|
672 | Removes unsupported virtualization modes.
|
---|
673 | """
|
---|
674 | if 'hwvirt' in self.asVirtModes and not oTestDrv.hasHostHwVirt():
|
---|
675 | reporter.log('Hardware assisted virtualization is not available on the host, skipping it.');
|
---|
676 | self.asVirtModes.remove('hwvirt');
|
---|
677 |
|
---|
678 | if 'hwvirt-np' in self.asVirtModes and not oTestDrv.hasHostNestedPaging():
|
---|
679 | reporter.log('Nested paging not supported by the host, skipping it.');
|
---|
680 | self.asVirtModes.remove('hwvirt-np');
|
---|
681 |
|
---|
682 | if 'raw' in self.asVirtModes and not oTestDrv.hasRawModeSupport():
|
---|
683 | reporter.log('Raw-mode virtualization is not available in this build (or perhaps for this host), skipping it.');
|
---|
684 | self.asVirtModes.remove('raw');
|
---|
685 |
|
---|
686 | return True;
|
---|
687 |
|
---|
688 | def actionExecute(self, oTestDrv, fnCallback): # pylint: disable=R0914
|
---|
689 | """
|
---|
690 | For base.TestDriver.actionExecute. Calls the callback function for
|
---|
691 | each of the VMs and basic configuration variations (virt-mode and cpu
|
---|
692 | count).
|
---|
693 |
|
---|
694 | Returns True if all fnCallback calls returned True, otherwise False.
|
---|
695 |
|
---|
696 | The callback can return True, False or None. The latter is for when the
|
---|
697 | test is skipped. (True is for success, False is for failure.)
|
---|
698 | """
|
---|
699 |
|
---|
700 | self._removeUnsupportedVirtModes(oTestDrv);
|
---|
701 | cMaxCpus = oTestDrv.getHostCpuCount();
|
---|
702 |
|
---|
703 | #
|
---|
704 | # The test loop.
|
---|
705 | #
|
---|
706 | fRc = True;
|
---|
707 | for oTestVm in self.aoTestVms:
|
---|
708 | if oTestVm.fSkip and self.fIgnoreSkippedVm:
|
---|
709 | reporter.log2('Ignoring VM %s (fSkip = True).' % (oTestVm.sVmName,));
|
---|
710 | continue;
|
---|
711 | reporter.testStart(oTestVm.sVmName);
|
---|
712 | if oTestVm.fSkip:
|
---|
713 | reporter.testDone(fSkipped = True);
|
---|
714 | continue;
|
---|
715 |
|
---|
716 | # Intersect the supported modes and the ones being testing.
|
---|
717 | asVirtModesSup = [sMode for sMode in oTestVm.asVirtModesSup if sMode in self.asVirtModes];
|
---|
718 |
|
---|
719 | # Ditto for CPUs.
|
---|
720 | acCpusSup = [cCpus for cCpus in oTestVm.acCpusSup if cCpus in self.acCpus];
|
---|
721 |
|
---|
722 | # Ditto for paravirtualization modes, except if not specified we got a less obvious default.
|
---|
723 | if self.asParavirtModes is not None and oTestDrv.fpApiVer >= 5.0:
|
---|
724 | asParavirtModes = [sPvMode for sPvMode in oTestVm.asParavirtModesSup if sPvMode in self.asParavirtModes];
|
---|
725 | assert None not in asParavirtModes;
|
---|
726 | elif oTestDrv.fpApiVer >= 5.0:
|
---|
727 | asParavirtModes = (oTestVm.asParavirtModesSup[0],);
|
---|
728 | assert asParavirtModes[0] is not None;
|
---|
729 | else:
|
---|
730 | asParavirtModes = (None,);
|
---|
731 |
|
---|
732 | for cCpus in acCpusSup:
|
---|
733 | if cCpus == 1:
|
---|
734 | reporter.testStart('1 cpu');
|
---|
735 | else:
|
---|
736 | reporter.testStart('%u cpus' % (cCpus));
|
---|
737 | if cCpus > cMaxCpus:
|
---|
738 | reporter.testDone(fSkipped = True);
|
---|
739 | continue;
|
---|
740 |
|
---|
741 | cTests = 0;
|
---|
742 | for sVirtMode in asVirtModesSup:
|
---|
743 | if sVirtMode == 'raw' and cCpus > 1:
|
---|
744 | continue;
|
---|
745 | reporter.testStart('%s' % ( g_dsVirtModeDescs[sVirtMode], ) );
|
---|
746 | cStartTests = cTests;
|
---|
747 |
|
---|
748 | for sParavirtMode in asParavirtModes:
|
---|
749 | if sParavirtMode is not None:
|
---|
750 | assert oTestDrv.fpApiVer >= 5.0;
|
---|
751 | reporter.testStart('%s' % ( sParavirtMode, ) );
|
---|
752 |
|
---|
753 | # Reconfigure the VM.
|
---|
754 | try:
|
---|
755 | (rc2, oVM) = oTestVm.getReconfiguredVm(oTestDrv, cCpus, sVirtMode, sParavirtMode = sParavirtMode);
|
---|
756 | except KeyboardInterrupt:
|
---|
757 | raise;
|
---|
758 | except:
|
---|
759 | reporter.errorXcpt(cFrames = 9);
|
---|
760 | rc2 = False;
|
---|
761 | if rc2 is True:
|
---|
762 | # Do the testing.
|
---|
763 | try:
|
---|
764 | rc2 = fnCallback(oVM, oTestVm);
|
---|
765 | except KeyboardInterrupt:
|
---|
766 | raise;
|
---|
767 | except:
|
---|
768 | reporter.errorXcpt(cFrames = 9);
|
---|
769 | rc2 = False;
|
---|
770 | if rc2 is False:
|
---|
771 | reporter.maybeErr(reporter.testErrorCount() == 0, 'fnCallback failed');
|
---|
772 | elif rc2 is False:
|
---|
773 | reporter.log('getReconfiguredVm failed');
|
---|
774 | if rc2 is False:
|
---|
775 | fRc = False;
|
---|
776 |
|
---|
777 | cTests = cTests + (rc2 is not None);
|
---|
778 | if sParavirtMode is not None:
|
---|
779 | reporter.testDone(fSkipped = (rc2 is None));
|
---|
780 |
|
---|
781 | reporter.testDone(fSkipped = cTests == cStartTests);
|
---|
782 |
|
---|
783 | reporter.testDone(fSkipped = cTests == 0);
|
---|
784 |
|
---|
785 | _, cErrors = reporter.testDone();
|
---|
786 | if cErrors > 0:
|
---|
787 | fRc = False;
|
---|
788 | return fRc;
|
---|
789 |
|
---|
790 | def enumerateTestVms(self, fnCallback):
|
---|
791 | """
|
---|
792 | Enumerates all the 'active' VMs.
|
---|
793 |
|
---|
794 | Returns True if all fnCallback calls returned True.
|
---|
795 | Returns False if any returned False.
|
---|
796 | Returns None immediately if fnCallback returned None.
|
---|
797 | """
|
---|
798 | fRc = True;
|
---|
799 | for oTestVm in self.aoTestVms:
|
---|
800 | if not oTestVm.fSkip:
|
---|
801 | fRc2 = fnCallback(oTestVm);
|
---|
802 | if fRc2 is None:
|
---|
803 | return fRc2;
|
---|
804 | fRc = fRc and fRc2;
|
---|
805 | return fRc;
|
---|
806 |
|
---|
807 |
|
---|
808 |
|
---|
809 | class TestVmManager(object):
|
---|
810 | """
|
---|
811 | Test VM manager.
|
---|
812 | """
|
---|
813 |
|
---|
814 | def __init__(self, sResourcePath):
|
---|
815 | self.sResourcePath = sResourcePath;
|
---|
816 |
|
---|
817 |
|
---|
818 | def getStandardVmSet(self, sTxsTransport):
|
---|
819 | """
|
---|
820 | Gets the set of standard test VMs.
|
---|
821 |
|
---|
822 | This is supposed to do something seriously clever, like searching the
|
---|
823 | testrsrc tree for usable VMs, but for the moment it's all hard coded. :-)
|
---|
824 | """
|
---|
825 |
|
---|
826 | oSet = TestVmSet(oTestVmManager = self);
|
---|
827 |
|
---|
828 | oTestVm = TestVm(oSet, 'tst-win10-efi', sHd = '4.2/efi/win10-efi-x86.vdi',
|
---|
829 | sKind = 'Windows10', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi');
|
---|
830 | oSet.aoTestVms.append(oTestVm);
|
---|
831 |
|
---|
832 | oTestVm = TestVm(oSet, 'tst-win10-64-efi', sHd = '4.2/efi/win10-efi-amd64.vdi',
|
---|
833 | sKind = 'Windows10_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi');
|
---|
834 | oSet.aoTestVms.append(oTestVm);
|
---|
835 |
|
---|
836 | oTestVm = TestVm(oSet, 'tst-ubuntu-15_10-64-efi', sHd = '4.2/efi/ubuntu-15_10-efi-amd64.vdi',
|
---|
837 | sKind = 'Ubuntu_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi');
|
---|
838 | oSet.aoTestVms.append(oTestVm);
|
---|
839 |
|
---|
840 | oTestVm = TestVm(oSet, 'tst-nt4sp1', sHd = '4.2/' + sTxsTransport + '/nt4sp1/t-nt4sp1.vdi',
|
---|
841 | sKind = 'WindowsNT4', acCpusSup = [1]);
|
---|
842 | oSet.aoTestVms.append(oTestVm);
|
---|
843 |
|
---|
844 | oTestVm = TestVm(oSet, 'tst-xppro', sHd = '4.2/' + sTxsTransport + '/xppro/t-xppro.vdi',
|
---|
845 | sKind = 'WindowsXP', acCpusSup = range(1, 33));
|
---|
846 | oSet.aoTestVms.append(oTestVm);
|
---|
847 |
|
---|
848 | oTestVm = TestVm(oSet, 'tst-nt4sp6', sHd = '4.2/nt4sp6/t-nt4sp6.vdi',
|
---|
849 | sKind = 'WindowsNT4', acCpusSup = range(1, 33));
|
---|
850 | oSet.aoTestVms.append(oTestVm);
|
---|
851 |
|
---|
852 | oTestVm = TestVm(oSet, 'tst-2ksp4', sHd = '4.2/win2ksp4/t-win2ksp4.vdi',
|
---|
853 | sKind = 'Windows2000', acCpusSup = range(1, 33));
|
---|
854 | oSet.aoTestVms.append(oTestVm);
|
---|
855 |
|
---|
856 | oTestVm = TestVm(oSet, 'tst-xpsp2', sHd = '4.2/xpsp2/t-winxpsp2.vdi',
|
---|
857 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True);
|
---|
858 | oSet.aoTestVms.append(oTestVm);
|
---|
859 |
|
---|
860 | oTestVm = TestVm(oSet, 'tst-xpsp2-halaacpi', sHd = '4.2/xpsp2/t-winxp-halaacpi.vdi',
|
---|
861 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True);
|
---|
862 | oSet.aoTestVms.append(oTestVm);
|
---|
863 |
|
---|
864 | oTestVm = TestVm(oSet, 'tst-xpsp2-halacpi', sHd = '4.2/xpsp2/t-winxp-halacpi.vdi',
|
---|
865 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True);
|
---|
866 | oSet.aoTestVms.append(oTestVm);
|
---|
867 |
|
---|
868 | oTestVm = TestVm(oSet, 'tst-xpsp2-halapic', sHd = '4.2/xpsp2/t-winxp-halapic.vdi',
|
---|
869 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True);
|
---|
870 | oSet.aoTestVms.append(oTestVm);
|
---|
871 |
|
---|
872 | oTestVm = TestVm(oSet, 'tst-xpsp2-halmacpi', sHd = '4.2/xpsp2/t-winxp-halmacpi.vdi',
|
---|
873 | sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True);
|
---|
874 | oSet.aoTestVms.append(oTestVm);
|
---|
875 |
|
---|
876 | oTestVm = TestVm(oSet, 'tst-xpsp2-halmps', sHd = '4.2/xpsp2/t-winxp-halmps.vdi',
|
---|
877 | sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True);
|
---|
878 | oSet.aoTestVms.append(oTestVm);
|
---|
879 |
|
---|
880 | oTestVm = TestVm(oSet, 'tst-win7', sHd = '4.2/win7-32/t-win7.vdi',
|
---|
881 | sKind = 'Windows7', acCpusSup = range(1, 33), fIoApic = True);
|
---|
882 | oSet.aoTestVms.append(oTestVm);
|
---|
883 |
|
---|
884 | oTestVm = TestVm(oSet, 'tst-win8', sHd = '4.2/win8-32/t-win8.vdi',
|
---|
885 | sKind = 'Windows8', acCpusSup = range(1, 33), fIoApic = True);
|
---|
886 | oSet.aoTestVms.append(oTestVm);
|
---|
887 |
|
---|
888 | return oSet;
|
---|
889 |
|
---|
890 | def getSmokeVmSet(self):
|
---|
891 | """
|
---|
892 | Gets a representative set of VMs for smoke testing.
|
---|
893 | """
|
---|
894 |
|
---|
895 | oSet = TestVmSet(oTestVmManager = self);
|
---|
896 |
|
---|
897 | oTestVm = TestVm(oSet, 'tst-win10-efi', sHd = '4.2/efi/win10-efi-x86.vdi',
|
---|
898 | sKind = 'Windows10', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi');
|
---|
899 | oSet.aoTestVms.append(oTestVm);
|
---|
900 |
|
---|
901 | oTestVm = TestVm(oSet, 'tst-win10-64-efi', sHd = '4.2/efi/win10-efi-amd64.vdi',
|
---|
902 | sKind = 'Windows10_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi');
|
---|
903 | oSet.aoTestVms.append(oTestVm);
|
---|
904 |
|
---|
905 | oTestVm = TestVm(oSet, 'tst-ubuntu-15_10-64-efi', sHd = '4.2/efi/ubuntu-15_10-efi-amd64.vdi',
|
---|
906 | sKind = 'Ubuntu_64', acCpusSup = range(1, 33), fIoApic = True, sFirmwareType = 'efi');
|
---|
907 | oSet.aoTestVms.append(oTestVm);
|
---|
908 |
|
---|
909 | oTestVm = TestVm(oSet, 'tst-nt4sp1', sHd = '4.2/nat/nt4sp1/t-nt4sp1.vdi',
|
---|
910 | sKind = 'WindowsNT4', acCpusSup = [1], sNic0AttachType = 'nat');
|
---|
911 | oSet.aoTestVms.append(oTestVm);
|
---|
912 |
|
---|
913 | oTestVm = TestVm(oSet, 'tst-xppro', sHd = '4.2/nat/xppro/t-xppro.vdi',
|
---|
914 | sKind = 'WindowsXP', acCpusSup = range(1, 33), sNic0AttachType = 'nat');
|
---|
915 | oSet.aoTestVms.append(oTestVm);
|
---|
916 |
|
---|
917 | oTestVm = TestVm(oSet, 'tst-rhel5', sHd = '3.0/tcp/rhel5.vdi',
|
---|
918 | sKind = 'RedHat', acCpusSup = range(1, 33), fIoApic = True, sNic0AttachType = 'nat');
|
---|
919 | oSet.aoTestVms.append(oTestVm);
|
---|
920 |
|
---|
921 | oTestVm = TestVm(oSet, 'tst-win2k3ent', sHd = '3.0/tcp/win2k3ent-acpi.vdi',
|
---|
922 | sKind = 'Windows2003', acCpusSup = range(1, 33), fPae = True, sNic0AttachType = 'bridged');
|
---|
923 | oSet.aoTestVms.append(oTestVm);
|
---|
924 |
|
---|
925 | oTestVm = TestVm(oSet, 'tst-sol10', sHd = '3.0/tcp/solaris10.vdi',
|
---|
926 | sKind = 'Solaris', acCpusSup = range(1, 33), fPae = True, sNic0AttachType = 'bridged');
|
---|
927 | oSet.aoTestVms.append(oTestVm);
|
---|
928 |
|
---|
929 | oTestVm = TestVm(oSet, 'tst-sol10-64', sHd = '3.0/tcp/solaris10.vdi',
|
---|
930 | sKind = 'Solaris_64', acCpusSup = range(1, 33), sNic0AttachType = 'bridged');
|
---|
931 | oSet.aoTestVms.append(oTestVm);
|
---|
932 |
|
---|
933 | oTestVm = TestVm(oSet, 'tst-sol11u1', sHd = '4.2/nat/sol11u1/t-sol11u1.vdi',
|
---|
934 | sKind = 'Solaris11_64', acCpusSup = range(1, 33), sNic0AttachType = 'nat',
|
---|
935 | fIoApic = True, sHddControllerType = 'SATA Controller');
|
---|
936 | oSet.aoTestVms.append(oTestVm);
|
---|
937 |
|
---|
938 | oTestVm = TestVm(oSet, 'tst-nt4sp6', sHd = '4.2/nt4sp6/t-nt4sp6.vdi',
|
---|
939 | sKind = 'WindowsNT4', acCpusSup = range(1, 33));
|
---|
940 | oSet.aoTestVms.append(oTestVm);
|
---|
941 |
|
---|
942 | oTestVm = TestVm(oSet, 'tst-2ksp4', sHd = '4.2/win2ksp4/t-win2ksp4.vdi',
|
---|
943 | sKind = 'Windows2000', acCpusSup = range(1, 33));
|
---|
944 | oSet.aoTestVms.append(oTestVm);
|
---|
945 |
|
---|
946 | oTestVm = TestVm(oSet, 'tst-xpsp2', sHd = '4.2/xpsp2/t-winxpsp2.vdi',
|
---|
947 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True);
|
---|
948 | oSet.aoTestVms.append(oTestVm);
|
---|
949 |
|
---|
950 | oTestVm = TestVm(oSet, 'tst-xpsp2-halaacpi', sHd = '4.2/xpsp2/t-winxp-halaacpi.vdi',
|
---|
951 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True);
|
---|
952 | oSet.aoTestVms.append(oTestVm);
|
---|
953 |
|
---|
954 | oTestVm = TestVm(oSet, 'tst-xpsp2-halacpi', sHd = '4.2/xpsp2/t-winxp-halacpi.vdi',
|
---|
955 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True);
|
---|
956 | oSet.aoTestVms.append(oTestVm);
|
---|
957 |
|
---|
958 | oTestVm = TestVm(oSet, 'tst-xpsp2-halapic', sHd = '4.2/xpsp2/t-winxp-halapic.vdi',
|
---|
959 | sKind = 'WindowsXP', acCpusSup = range(1, 33), fIoApic = True);
|
---|
960 | oSet.aoTestVms.append(oTestVm);
|
---|
961 |
|
---|
962 | oTestVm = TestVm(oSet, 'tst-xpsp2-halmacpi', sHd = '4.2/xpsp2/t-winxp-halmacpi.vdi',
|
---|
963 | sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True);
|
---|
964 | oSet.aoTestVms.append(oTestVm);
|
---|
965 |
|
---|
966 | oTestVm = TestVm(oSet, 'tst-xpsp2-halmps', sHd = '4.2/xpsp2/t-winxp-halmps.vdi',
|
---|
967 | sKind = 'WindowsXP', acCpusSup = range(2, 33), fIoApic = True);
|
---|
968 | oSet.aoTestVms.append(oTestVm);
|
---|
969 |
|
---|
970 | oTestVm = TestVm(oSet, 'tst-win7', sHd = '4.2/win7-32/t-win7.vdi',
|
---|
971 | sKind = 'Windows7', acCpusSup = range(1, 33), fIoApic = True);
|
---|
972 | oSet.aoTestVms.append(oTestVm);
|
---|
973 |
|
---|
974 | oTestVm = TestVm(oSet, 'tst-win8', sHd = '4.2/win8-32/t-win8.vdi',
|
---|
975 | sKind = 'Windows8', acCpusSup = range(1, 33), fIoApic = True);
|
---|
976 | oSet.aoTestVms.append(oTestVm);
|
---|
977 |
|
---|
978 | return oSet;
|
---|
979 |
|
---|
980 | def shutUpPyLint(self):
|
---|
981 | """ Shut up already! """
|
---|
982 | return self.sResourcePath;
|
---|
983 |
|
---|