1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdGuestOsUnattendedInst1.py 79452 2019-07-01 16:49:51Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | VirtualBox Validation Kit - Guest OS unattended installation tests.
|
---|
7 | """
|
---|
8 |
|
---|
9 | __copyright__ = \
|
---|
10 | """
|
---|
11 | Copyright (C) 2010-2019 Oracle Corporation
|
---|
12 |
|
---|
13 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | available from http://www.virtualbox.org. This file is free software;
|
---|
15 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | General Public License (GPL) as published by the Free Software
|
---|
17 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 |
|
---|
21 | The contents of this file may alternatively be used under the terms
|
---|
22 | of the Common Development and Distribution License Version 1.0
|
---|
23 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
24 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
25 | CDDL are applicable instead of those of the GPL.
|
---|
26 |
|
---|
27 | You may elect to license modified versions of this file under the
|
---|
28 | terms and conditions of either the GPL or the CDDL or both.
|
---|
29 | """
|
---|
30 | __version__ = "$Revision: 79452 $"
|
---|
31 |
|
---|
32 |
|
---|
33 | # Standard Python imports.
|
---|
34 | import copy;
|
---|
35 | import os;
|
---|
36 | import sys;
|
---|
37 |
|
---|
38 |
|
---|
39 | # Only the main script needs to modify the path.
|
---|
40 | try: __file__
|
---|
41 | except: __file__ = sys.argv[0]
|
---|
42 | g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
---|
43 | sys.path.append(g_ksValidationKitDir)
|
---|
44 |
|
---|
45 | # Validation Kit imports.
|
---|
46 | from testdriver import vbox;
|
---|
47 | from testdriver import base;
|
---|
48 | from testdriver import reporter;
|
---|
49 | from testdriver import vboxcon;
|
---|
50 | from testdriver import vboxtestvms;
|
---|
51 |
|
---|
52 | # Sub-test driver imports.
|
---|
53 | sys.path.append(os.path.join(g_ksValidationKitDir, 'tests', 'additions'));
|
---|
54 | from tdAddGuestCtrl import SubTstDrvAddGuestCtrl;
|
---|
55 | from tdAddSharedFolders1 import SubTstDrvAddSharedFolders1;
|
---|
56 |
|
---|
57 |
|
---|
58 | class UnattendedVm(vboxtestvms.BaseTestVm):
|
---|
59 | """ Unattended Installation test VM. """
|
---|
60 |
|
---|
61 | ## @name VM option flags (OR together).
|
---|
62 | ## @{
|
---|
63 | kfIdeIrqDelay = 0x1;
|
---|
64 | kfUbuntuNewAmdBug = 0x2;
|
---|
65 | kfNoWin81Paravirt = 0x4;
|
---|
66 | ## @}
|
---|
67 |
|
---|
68 | ## IRQ delay extra data config for win2k VMs.
|
---|
69 | kasIdeIrqDelay = [ 'VBoxInternal/Devices/piix3ide/0/Config/IRQDelay:1', ];
|
---|
70 |
|
---|
71 | def __init__(self, oSet, sVmName, sKind, sInstallIso, fFlags = 0):
|
---|
72 | vboxtestvms.BaseTestVm.__init__(self, sVmName, oSet = oSet, sKind = sKind,
|
---|
73 | fRandomPvPModeCrap = (fFlags & self.kfNoWin81Paravirt) == 0);
|
---|
74 | self.sInstallIso = sInstallIso;
|
---|
75 | self.fInstVmFlags = fFlags;
|
---|
76 |
|
---|
77 | # Adjustments over the defaults.
|
---|
78 | self.iOptRamAdjust = 0;
|
---|
79 | self.fOptIoApic = None;
|
---|
80 | self.fOptPae = None;
|
---|
81 | self.fOptInstallAdditions = False;
|
---|
82 | self.asOptExtraData = [];
|
---|
83 | if fFlags & self.kfIdeIrqDelay:
|
---|
84 | self.asOptExtraData = self.kasIdeIrqDelay;
|
---|
85 |
|
---|
86 | def _unattendedConfigure(self, oIUnattended, oTestDrv): # type: (Any, vbox.TestDriver) -> bool
|
---|
87 | """
|
---|
88 | Configures the unattended install object.
|
---|
89 |
|
---|
90 | The ISO attribute has been set and detectIsoOS has been done, the rest of the
|
---|
91 | setup is done here.
|
---|
92 |
|
---|
93 | Returns True on success, False w/ errors logged on failure.
|
---|
94 | """
|
---|
95 |
|
---|
96 | #
|
---|
97 | # Make it install the TXS.
|
---|
98 | #
|
---|
99 | try: oIUnattended.installTestExecService = True;
|
---|
100 | except: return reporter.errorXcpt();
|
---|
101 | try: oIUnattended.validationKitIsoPath = oTestDrv.sVBoxValidationKitIso;
|
---|
102 | except: return reporter.errorXcpt();
|
---|
103 | oTestDrv.processPendingEvents();
|
---|
104 |
|
---|
105 | #
|
---|
106 | # Install GAs?
|
---|
107 | #
|
---|
108 | if self.fOptInstallAdditions:
|
---|
109 | try: oIUnattended.installGuestAdditions = True;
|
---|
110 | except: return reporter.errorXcpt();
|
---|
111 | try: oIUnattended.additionsIsoPath = oTestDrv.getGuestAdditionsIso();
|
---|
112 | except: return reporter.errorXcpt();
|
---|
113 | oTestDrv.processPendingEvents();
|
---|
114 |
|
---|
115 | return True;
|
---|
116 |
|
---|
117 | def _unattendedDoIt(self, oIUnattended, oVM, oTestDrv): # type: (Any, Any, vbox.TestDriver) -> bool
|
---|
118 | """
|
---|
119 | Does the unattended installation preparing, media construction and VM reconfiguration.
|
---|
120 |
|
---|
121 | Returns True on success, False w/ errors logged on failure.
|
---|
122 | """
|
---|
123 |
|
---|
124 | # Associate oVM with the installer:
|
---|
125 | try:
|
---|
126 | oIUnattended.machine = oVM;
|
---|
127 | except:
|
---|
128 | return reporter.errorXcpt();
|
---|
129 | oTestDrv.processPendingEvents();
|
---|
130 |
|
---|
131 | # Prepare and log it:
|
---|
132 | try:
|
---|
133 | oIUnattended.prepare();
|
---|
134 | except:
|
---|
135 | return reporter.errorXcpt("IUnattended.prepare failed");
|
---|
136 | oTestDrv.processPendingEvents();
|
---|
137 |
|
---|
138 | reporter.log('IUnattended attributes after prepare():');
|
---|
139 | self._unattendedLogIt(oIUnattended, oTestDrv);
|
---|
140 |
|
---|
141 | # Create media:
|
---|
142 | try:
|
---|
143 | oIUnattended.constructMedia();
|
---|
144 | except:
|
---|
145 | return reporter.errorXcpt("IUnattended.constructMedia failed");
|
---|
146 | oTestDrv.processPendingEvents();
|
---|
147 |
|
---|
148 | # Reconfigure the VM:
|
---|
149 | try:
|
---|
150 | oIUnattended.reconfigureVM();
|
---|
151 | except:
|
---|
152 | return reporter.errorXcpt("IUnattended.reconfigureVM failed");
|
---|
153 | oTestDrv.processPendingEvents();
|
---|
154 |
|
---|
155 | return True;
|
---|
156 |
|
---|
157 | def _unattendedLogIt(self, oIUnattended, oTestDrv):
|
---|
158 | """
|
---|
159 | Logs the attributes of the unattended installation object.
|
---|
160 | """
|
---|
161 | fRc = True;
|
---|
162 | asAttribs = ( 'isoPath', 'user', 'password', 'fullUserName', 'productKey', 'additionsIsoPath', 'installGuestAdditions',
|
---|
163 | 'validationKitIsoPath', 'installTestExecService', 'timeZone', 'locale', 'language', 'country', 'proxy',
|
---|
164 | 'packageSelectionAdjustments', 'hostname', 'auxiliaryBasePath', 'imageIndex', 'machine',
|
---|
165 | 'scriptTemplatePath', 'postInstallScriptTemplatePath', 'postInstallCommand',
|
---|
166 | 'extraInstallKernelParameters', 'detectedOSTypeId', 'detectedOSVersion', 'detectedOSLanguages',
|
---|
167 | 'detectedOSFlavor', 'detectedOSHints', );
|
---|
168 | for sAttrib in asAttribs:
|
---|
169 | try:
|
---|
170 | oValue = getattr(oIUnattended, sAttrib);
|
---|
171 | except:
|
---|
172 | fRc = reporter.errorXcpt('sAttrib=%s' % sAttrib);
|
---|
173 | else:
|
---|
174 | reporter.log('%s: %s' % (sAttrib.rjust(32), oValue,));
|
---|
175 | oTestDrv.processPendingEvents();
|
---|
176 | return fRc;
|
---|
177 |
|
---|
178 |
|
---|
179 | #
|
---|
180 | # Overriden methods.
|
---|
181 | #
|
---|
182 |
|
---|
183 | def getResourceSet(self):
|
---|
184 | if not os.path.isabs(self.sInstallIso):
|
---|
185 | return [self.sInstallIso,];
|
---|
186 | return [];
|
---|
187 |
|
---|
188 | def _createVmDoIt(self, oTestDrv, eNic0AttachType, sDvdImage):
|
---|
189 | #
|
---|
190 | # Use HostOnly networking for ubuntu and debian VMs to prevent them from
|
---|
191 | # downloading updates and doing database updates during installation.
|
---|
192 | # We want predicable results.
|
---|
193 | #
|
---|
194 | if eNic0AttachType is None \
|
---|
195 | and self.isLinux() \
|
---|
196 | and ( 'ubuntu' in self.sKind.lower()
|
---|
197 | or 'debian' in self.sKind.lower() ):
|
---|
198 | eNic0AttachType = vboxcon.NetworkAttachmentType_HostOnly;
|
---|
199 |
|
---|
200 | return vboxtestvms.BaseTestVm._createVmDoIt(self, oTestDrv, eNic0AttachType, sDvdImage);
|
---|
201 |
|
---|
202 |
|
---|
203 | def _createVmPost(self, oTestDrv, oVM, eNic0AttachType, sDvdImage):
|
---|
204 | #
|
---|
205 | # Adjust the ram, I/O APIC and stuff.
|
---|
206 | #
|
---|
207 |
|
---|
208 | oSession = oTestDrv.openSession(oVM);
|
---|
209 | if oSession is None:
|
---|
210 | return None;
|
---|
211 |
|
---|
212 | fRc = True;
|
---|
213 |
|
---|
214 | ## Set proper boot order - IUnattended::reconfigureVM does this, doesn't it?
|
---|
215 | #fRc = fRc and oSession.setBootOrder(1, vboxcon.DeviceType_HardDisk)
|
---|
216 | #fRc = fRc and oSession.setBootOrder(2, vboxcon.DeviceType_DVD)
|
---|
217 |
|
---|
218 | # Adjust memory if requested.
|
---|
219 | if self.iOptRamAdjust != 0:
|
---|
220 | try: cMbRam = oSession.o.machine.memorySize;
|
---|
221 | except: fRc = reporter.errorXcpt();
|
---|
222 | else:
|
---|
223 | fRc = oSession.setRamSize(cMbRam + self.iOptRamAdjust) and fRc;
|
---|
224 |
|
---|
225 | # I/O APIC:
|
---|
226 | if self.fOptIoApic is not None:
|
---|
227 | fRc = oSession.enableIoApic(self.fOptIoApic) and fRc;
|
---|
228 |
|
---|
229 | # I/O APIC:
|
---|
230 | if self.fOptPae is not None:
|
---|
231 | fRc = oSession.enablePae(self.fOptPae) and fRc;
|
---|
232 |
|
---|
233 | # Set extra data
|
---|
234 | for sExtraData in self.asOptExtraData:
|
---|
235 | sKey, sValue = sExtraData.split(':');
|
---|
236 | reporter.log('Set extradata: %s => %s' % (sKey, sValue))
|
---|
237 | fRc = oSession.setExtraData(sKey, sValue) and fRc;
|
---|
238 |
|
---|
239 | # Save the settings.
|
---|
240 | fRc = fRc and oSession.saveSettings()
|
---|
241 | fRc = oSession.close() and fRc;
|
---|
242 |
|
---|
243 | return oVM if fRc else None;
|
---|
244 |
|
---|
245 | def _skipVmTest(self, oTestDrv, oVM):
|
---|
246 | _ = oVM;
|
---|
247 | #
|
---|
248 | # Check for ubuntu installer vs. AMD host CPU.
|
---|
249 | #
|
---|
250 | if self.fInstVmFlags & self.kfUbuntuNewAmdBug:
|
---|
251 | if self.isHostCpuAffectedByUbuntuNewAmdBug(oTestDrv):
|
---|
252 | return True;
|
---|
253 |
|
---|
254 | return vboxtestvms.BaseTestVm._skipVmTest(self, oTestDrv, oVM);
|
---|
255 |
|
---|
256 | def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
|
---|
257 | #
|
---|
258 | # Do the standard reconfig in the base class first, it'll figure out
|
---|
259 | # if we can run the VM as requested.
|
---|
260 | #
|
---|
261 | (fRc, oVM) = vboxtestvms.BaseTestVm.getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode);
|
---|
262 | if fRc is True:
|
---|
263 | #
|
---|
264 | # Make sure there is no HD from the previous run attached nor taking
|
---|
265 | # up storage on the host.
|
---|
266 | #
|
---|
267 | fRc = self.recreateRecommendedHdd(oVM, oTestDrv);
|
---|
268 | if fRc is True:
|
---|
269 | #
|
---|
270 | # Set up unattended installation.
|
---|
271 | #
|
---|
272 | try:
|
---|
273 | oIUnattended = oTestDrv.oVBox.createUnattendedInstaller();
|
---|
274 | except:
|
---|
275 | fRc = reporter.errorXcpt();
|
---|
276 | if fRc is True:
|
---|
277 | fRc = self.unattendedDetectOs(oIUnattended, oTestDrv);
|
---|
278 | if fRc is True:
|
---|
279 | fRc = self._unattendedConfigure(oIUnattended, oTestDrv);
|
---|
280 | if fRc is True:
|
---|
281 | fRc = self._unattendedDoIt(oIUnattended, oVM, oTestDrv);
|
---|
282 |
|
---|
283 | # Done.
|
---|
284 | return (fRc, oVM)
|
---|
285 |
|
---|
286 | def isLoggedOntoDesktop(self):
|
---|
287 | #
|
---|
288 | # Normally all unattended installations should end up on the desktop.
|
---|
289 | # An exception is a minimal install, but we currently don't support that.
|
---|
290 | #
|
---|
291 | return True;
|
---|
292 |
|
---|
293 | def getTestUser(self):
|
---|
294 | # Default unattended installation user (parent knowns its password).
|
---|
295 | return 'vboxuser';
|
---|
296 |
|
---|
297 |
|
---|
298 | #
|
---|
299 | # Our methods.
|
---|
300 | #
|
---|
301 |
|
---|
302 | def unattendedDetectOs(self, oIUnattended, oTestDrv): # type: (Any, vbox.TestDriver) -> bool
|
---|
303 | """
|
---|
304 | Does the detectIsoOS operation and checks that the detect OSTypeId matches.
|
---|
305 |
|
---|
306 | Returns True on success, False w/ errors logged on failure.
|
---|
307 | """
|
---|
308 |
|
---|
309 | #
|
---|
310 | # Point the installer at the ISO and do the detection.
|
---|
311 | #
|
---|
312 | sInstallIso = self.sInstallIso
|
---|
313 | if not os.path.isabs(sInstallIso):
|
---|
314 | sInstallIso = os.path.join(oTestDrv.sResourcePath, sInstallIso);
|
---|
315 |
|
---|
316 | try:
|
---|
317 | oIUnattended.isoPath = sInstallIso;
|
---|
318 | except:
|
---|
319 | return reporter.errorXcpt('sInstallIso=%s' % (sInstallIso,));
|
---|
320 |
|
---|
321 | try:
|
---|
322 | oIUnattended.detectIsoOS();
|
---|
323 | except:
|
---|
324 | if oTestDrv.oVBoxMgr.xcptIsNotEqual(None, oTestDrv.oVBoxMgr.statuses.E_NOTIMPL):
|
---|
325 | return reporter.errorXcpt('sInstallIso=%s' % (sInstallIso,));
|
---|
326 |
|
---|
327 | #
|
---|
328 | # Get and log the result.
|
---|
329 | #
|
---|
330 | # Note! Current (6.0.97) fails with E_NOTIMPL even if it does some work.
|
---|
331 | #
|
---|
332 | try:
|
---|
333 | sDetectedOSTypeId = oIUnattended.detectedOSTypeId;
|
---|
334 | sDetectedOSVersion = oIUnattended.detectedOSVersion;
|
---|
335 | sDetectedOSFlavor = oIUnattended.detectedOSFlavor;
|
---|
336 | sDetectedOSLanguages = oIUnattended.detectedOSLanguages;
|
---|
337 | sDetectedOSHints = oIUnattended.detectedOSHints;
|
---|
338 | except:
|
---|
339 | return reporter.errorXcpt('sInstallIso=%s' % (sInstallIso,));
|
---|
340 |
|
---|
341 | reporter.log('detectIsoOS result for "%s" (vm %s):' % (sInstallIso, self.sVmName));
|
---|
342 | reporter.log(' DetectedOSTypeId: %s' % (sDetectedOSTypeId,));
|
---|
343 | reporter.log(' DetectedOSVersion: %s' % (sDetectedOSVersion,));
|
---|
344 | reporter.log(' DetectedOSFlavor: %s' % (sDetectedOSFlavor,));
|
---|
345 | reporter.log(' DetectedOSLanguages: %s' % (sDetectedOSLanguages,));
|
---|
346 | reporter.log(' DetectedOSHints: %s' % (sDetectedOSHints,));
|
---|
347 |
|
---|
348 | #
|
---|
349 | # Check if the OS type matches.
|
---|
350 | #
|
---|
351 | if self.sKind != sDetectedOSTypeId:
|
---|
352 | return reporter.error('sInstallIso=%s: DetectedOSTypeId is %s, expected %s'
|
---|
353 | % (sInstallIso, sDetectedOSTypeId, self.sKind));
|
---|
354 |
|
---|
355 | return True;
|
---|
356 |
|
---|
357 |
|
---|
358 | class tdGuestOsInstTest1(vbox.TestDriver):
|
---|
359 | """
|
---|
360 | Unattended Guest OS installation tests using IUnattended.
|
---|
361 |
|
---|
362 | Scenario:
|
---|
363 | - Create a new VM with default settings using IMachine::applyDefaults.
|
---|
364 | - Setup unattended installation using IUnattended.
|
---|
365 | - Start the VM and do the installation.
|
---|
366 | - Wait for TXS to report for service.
|
---|
367 | - If installing GAs:
|
---|
368 | - Wait for GAs to report operational runlevel.
|
---|
369 | - Save & restore state.
|
---|
370 | - If installing GAs:
|
---|
371 | - Test guest properties (todo).
|
---|
372 | - Test guest controls.
|
---|
373 | - Test shared folders.
|
---|
374 | """
|
---|
375 |
|
---|
376 |
|
---|
377 | def __init__(self):
|
---|
378 | """
|
---|
379 | Reinitialize child class instance.
|
---|
380 | """
|
---|
381 | vbox.TestDriver.__init__(self)
|
---|
382 | self.fLegacyOptions = False;
|
---|
383 | assert self.fEnableVrdp; # in parent driver.
|
---|
384 |
|
---|
385 | #
|
---|
386 | # Our install test VM set.
|
---|
387 | #
|
---|
388 | oSet = vboxtestvms.TestVmSet(self.oTestVmManager, fIgnoreSkippedVm = True);
|
---|
389 | oSet.aoTestVms.extend([
|
---|
390 | # Windows7 RTM:
|
---|
391 | UnattendedVm(oSet, 'tst-w7-32', 'Windows7', '6.0/uaisos/en_windows_7_enterprise_x86_dvd_x15-70745.iso'), # 5.7GiB
|
---|
392 | UnattendedVm(oSet, 'tst-w7-64', 'Windows7_64', '6.0/uaisos/en_windows_7_enterprise_x64_dvd_x15-70749.iso'), # 10GiB
|
---|
393 | UnattendedVm(oSet, 'tst-ubuntu-16.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.04-desktop-amd64.iso'),
|
---|
394 | #UnattendedVm(oSet, 'tst-ubuntu-18.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-18.04-desktop-amd64.iso'), # >=5.7GiB
|
---|
395 | ]);
|
---|
396 | self.oTestVmSet = oSet;
|
---|
397 |
|
---|
398 | # For option parsing:
|
---|
399 | self.aoSelectedVms = oSet.aoTestVms # type: list(UnattendedVm)
|
---|
400 |
|
---|
401 | # Number of VMs to test in parallel:
|
---|
402 | self.cInParallel = 1;
|
---|
403 |
|
---|
404 | # Whether to do the save-and-restore test.
|
---|
405 | self.fTestSaveAndRestore = True;
|
---|
406 |
|
---|
407 | #
|
---|
408 | # Sub-test drivers.
|
---|
409 | #
|
---|
410 | self.addSubTestDriver(SubTstDrvAddSharedFolders1(self));
|
---|
411 | self.addSubTestDriver(SubTstDrvAddGuestCtrl(self));
|
---|
412 |
|
---|
413 |
|
---|
414 | #
|
---|
415 | # Overridden methods.
|
---|
416 | #
|
---|
417 |
|
---|
418 | def showUsage(self):
|
---|
419 | """
|
---|
420 | Extend usage info
|
---|
421 | """
|
---|
422 | rc = vbox.TestDriver.showUsage(self)
|
---|
423 | reporter.log('');
|
---|
424 | reporter.log('tdGuestOsUnattendedInst1 options:');
|
---|
425 | reporter.log(' --parallel <num>');
|
---|
426 | reporter.log(' Number of VMs to test in parallel.');
|
---|
427 | reporter.log(' Default: 1');
|
---|
428 | reporter.log('');
|
---|
429 | reporter.log(' Options for working on selected test VMs:');
|
---|
430 | reporter.log(' --select <vm1[:vm2[:..]]>');
|
---|
431 | reporter.log(' Selects a test VM for the following configuration alterations.');
|
---|
432 | reporter.log(' Default: All possible test VMs');
|
---|
433 | reporter.log(' --copy <old-vm>=<new-vm>');
|
---|
434 | reporter.log(' Creates and selects <new-vm> as a copy of <old-vm>.');
|
---|
435 | reporter.log(' --guest-type <guest-os-type>');
|
---|
436 | reporter.log(' Sets the guest-os type of the currently selected test VM.');
|
---|
437 | reporter.log(' --install-iso <ISO file name>');
|
---|
438 | reporter.log(' Sets ISO image to use for the selected test VM.');
|
---|
439 | reporter.log(' --ram-adjust <MBs>');
|
---|
440 | reporter.log(' Adjust the VM ram size by the given delta. Both negative and positive');
|
---|
441 | reporter.log(' values are accepted.');
|
---|
442 | reporter.log(' --max-cpus <# CPUs>');
|
---|
443 | reporter.log(' Sets the maximum number of guest CPUs for the selected VM.');
|
---|
444 | reporter.log(' --set-extradata <key>:value');
|
---|
445 | reporter.log(' Set VM extra data for the selected VM. Can be repeated.');
|
---|
446 | reporter.log(' --ioapic, --no-ioapic');
|
---|
447 | reporter.log(' Enable or disable the I/O apic for the selected VM.');
|
---|
448 | reporter.log(' --pae, --no-pae');
|
---|
449 | reporter.log(' Enable or disable PAE support (32-bit guests only) for the selected VM.');
|
---|
450 | return rc
|
---|
451 |
|
---|
452 | def parseOption(self, asArgs, iArg):
|
---|
453 | """
|
---|
454 | Extend standard options set
|
---|
455 | """
|
---|
456 |
|
---|
457 | if asArgs[iArg] == '--parallel':
|
---|
458 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
459 | self.cInParallel = int(asArgs[iArg]);
|
---|
460 | if self.cInParallel <= 0:
|
---|
461 | self.cInParallel = 1;
|
---|
462 | elif asArgs[iArg] == '--select':
|
---|
463 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
464 | self.aoSelectedVms = [];
|
---|
465 | for sTestVm in asArgs[iArg].split(':'):
|
---|
466 | oTestVm = self.oTestVmSet.findTestVmByName(sTestVm);
|
---|
467 | if not oTestVm:
|
---|
468 | raise base.InvalidOption('Unknown test VM: %s' % (sTestVm,));
|
---|
469 | self.aoSelectedVms.append(oTestVm);
|
---|
470 | elif asArgs[iArg] == '--copy':
|
---|
471 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
472 | asNames = asArgs[iArg].split('=');
|
---|
473 | if len(asNames) != 2 or not asNames[0] or not asNames[1]:
|
---|
474 | raise base.InvalidOption('The --copy option expects value on the form "old=new": %s' % (asArgs[iArg],));
|
---|
475 | oOldTestVm = self.oTestVmSet.findTestVmByName(asNames[0]);
|
---|
476 | if not oOldTestVm:
|
---|
477 | raise base.InvalidOption('Unknown test VM: %s' % (asNames[0],));
|
---|
478 | oNewTestVm = copy.deepcopy(oOldTestVm);
|
---|
479 | oNewTestVm.sVmName = asNames[1];
|
---|
480 | self.oTestVmSet.aoTestVms.append(oNewTestVm);
|
---|
481 | self.aoSelectedVms = [oNewTestVm];
|
---|
482 | elif asArgs[iArg] == '--guest-type':
|
---|
483 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
484 | for oTestVm in self.aoSelectedVms:
|
---|
485 | oTestVm.sKind = asArgs[iArg];
|
---|
486 | elif asArgs[iArg] == '--install-iso':
|
---|
487 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
488 | for oTestVm in self.aoSelectedVms:
|
---|
489 | oTestVm.sInstallIso = asArgs[iArg];
|
---|
490 | elif asArgs[iArg] == '--ram-adjust':
|
---|
491 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
492 | for oTestVm in self.aoSelectedVms:
|
---|
493 | oTestVm.iOptRamAdjust = int(asArgs[iArg]);
|
---|
494 | elif asArgs[iArg] == '--max-cpus':
|
---|
495 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
496 | for oTestVm in self.aoSelectedVms:
|
---|
497 | oTestVm.iOptMaxCpus = int(asArgs[iArg]);
|
---|
498 | elif asArgs[iArg] == '--set-extradata':
|
---|
499 | iArg = self.requireMoreArgs(1, asArgs, iArg)
|
---|
500 | sExtraData = asArgs[iArg];
|
---|
501 | try: _, _ = sExtraData.split(':');
|
---|
502 | except: raise base.InvalidOption('Invalid extradata specified: %s' % (sExtraData, ));
|
---|
503 | for oTestVm in self.aoSelectedVms:
|
---|
504 | oTestVm.asOptExtraData.append(sExtraData);
|
---|
505 | elif asArgs[iArg] == '--ioapic':
|
---|
506 | for oTestVm in self.aoSelectedVms:
|
---|
507 | oTestVm.fOptIoApic = True;
|
---|
508 | elif asArgs[iArg] == '--no-ioapic':
|
---|
509 | for oTestVm in self.aoSelectedVms:
|
---|
510 | oTestVm.fOptIoApic = False;
|
---|
511 | elif asArgs[iArg] == '--pae':
|
---|
512 | for oTestVm in self.aoSelectedVms:
|
---|
513 | oTestVm.fOptPae = True;
|
---|
514 | elif asArgs[iArg] == '--no-pae':
|
---|
515 | for oTestVm in self.aoSelectedVms:
|
---|
516 | oTestVm.fOptPae = False;
|
---|
517 | elif asArgs[iArg] == '--install-additions':
|
---|
518 | for oTestVm in self.aoSelectedVms:
|
---|
519 | oTestVm.fOptInstallAdditions = True;
|
---|
520 | elif asArgs[iArg] == '--no-install-additions':
|
---|
521 | for oTestVm in self.aoSelectedVms:
|
---|
522 | oTestVm.fOptInstallAdditions = False;
|
---|
523 | else:
|
---|
524 | return vbox.TestDriver.parseOption(self, asArgs, iArg);
|
---|
525 | return iArg + 1;
|
---|
526 |
|
---|
527 | def actionConfig(self):
|
---|
528 | if not self.importVBoxApi(): # So we can use the constant below.
|
---|
529 | return False;
|
---|
530 | return self.oTestVmSet.actionConfig(self);
|
---|
531 |
|
---|
532 | def actionExecute(self):
|
---|
533 | """
|
---|
534 | Execute the testcase.
|
---|
535 | """
|
---|
536 | return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
|
---|
537 |
|
---|
538 | def testOneVmConfig(self, oVM, oTestVm): # type: (Any, UnattendedVm) -> bool
|
---|
539 | """
|
---|
540 | Install guest OS and wait for result
|
---|
541 | """
|
---|
542 |
|
---|
543 | self.logVmInfo(oVM)
|
---|
544 | reporter.testStart('Installing %s%s' % (oTestVm.sVmName, ' with GAs' if oTestVm.fOptInstallAdditions else ''))
|
---|
545 |
|
---|
546 | cMsTimeout = 40*60000;
|
---|
547 | if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
|
---|
548 | cMsTimeout = 180 * 60000; # will be adjusted down.
|
---|
549 |
|
---|
550 | oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
|
---|
551 | #oSession = self.startVmByName(oTestVm.sVmName); # (for quickly testing waitForGAs)
|
---|
552 | if oSession is not None:
|
---|
553 | # The guest has connected to TXS.
|
---|
554 | reporter.log('Guest reported success via TXS.');
|
---|
555 | reporter.testDone();
|
---|
556 |
|
---|
557 | fRc = True;
|
---|
558 | # Kudge: GAs doesn't come up correctly, so we have to reboot the guest first:
|
---|
559 | # Looks like VBoxService isn't there.
|
---|
560 | if oTestVm.fOptInstallAdditions:
|
---|
561 | reporter.testStart('Rebooting');
|
---|
562 | fRc, oTxsSession = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession);
|
---|
563 | reporter.testDone();
|
---|
564 |
|
---|
565 | # If we're installing GAs, wait for them to come online:
|
---|
566 | if oTestVm.fOptInstallAdditions and fRc is True:
|
---|
567 | reporter.testStart('Guest additions');
|
---|
568 | aenmRunLevels = [vboxcon.AdditionsRunLevelType_Userland,];
|
---|
569 | if oTestVm.isLoggedOntoDesktop():
|
---|
570 | aenmRunLevels.append(vboxcon.AdditionsRunLevelType_Desktop);
|
---|
571 | fRc = self.waitForGAs(oSession, cMsTimeout = cMsTimeout / 2, aenmWaitForRunLevels = aenmRunLevels,
|
---|
572 | aenmWaitForActive = (vboxcon.AdditionsFacilityType_VBoxGuestDriver,
|
---|
573 | vboxcon.AdditionsFacilityType_VBoxService,));
|
---|
574 | reporter.testDone();
|
---|
575 |
|
---|
576 | # Now do a save & restore test:
|
---|
577 | if fRc is True and self.fTestSaveAndRestore:
|
---|
578 | fRc, oSession, oTxsSession = self.testSaveAndRestore(oSession, oTxsSession, oTestVm);
|
---|
579 |
|
---|
580 | # Test GAs if requested:
|
---|
581 | if oTestVm.fOptInstallAdditions and fRc is True:
|
---|
582 | for oSubTstDrv in self.aoSubTstDrvs:
|
---|
583 | if oSubTstDrv.fEnabled:
|
---|
584 | reporter.testStart(oSubTstDrv.sTestName);
|
---|
585 | fRc2, oTxsSession = oSubTstDrv.testIt(oTestVm, oSession, oTxsSession);
|
---|
586 | reporter.testDone(fRc2 is None);
|
---|
587 | if fRc2 is False:
|
---|
588 | fRc = False;
|
---|
589 |
|
---|
590 | if oSession is not None:
|
---|
591 | fRc = self.terminateVmBySession(oSession) and fRc;
|
---|
592 | return fRc is True
|
---|
593 |
|
---|
594 | reporter.error('Installation of %s has failed' % (oTestVm.sVmName,))
|
---|
595 | #oTestVm.detatchAndDeleteHd(self); # Save space.
|
---|
596 | reporter.testDone()
|
---|
597 | return False
|
---|
598 |
|
---|
599 | def testSaveAndRestore(self, oSession, oTxsSession, oTestVm):
|
---|
600 | """
|
---|
601 | Tests saving and restoring the VM.
|
---|
602 | """
|
---|
603 | _ = oTestVm;
|
---|
604 | reporter.testStart('Save');
|
---|
605 | ## @todo
|
---|
606 | reporter.testDone();
|
---|
607 | reporter.testStart('Restore');
|
---|
608 | ## @todo
|
---|
609 | reporter.testDone();
|
---|
610 | return (True, oSession, oTxsSession);
|
---|
611 |
|
---|
612 | if __name__ == '__main__':
|
---|
613 | sys.exit(tdGuestOsInstTest1().main(sys.argv))
|
---|
614 |
|
---|