1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdGuestOsUnattendedInst1.py 79422 2019-06-28 20:34:59Z 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: 79422 $"
|
---|
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 _createVmPost(self, oTestDrv, oVM, eNic0AttachType, sDvdImage):
|
---|
189 | #
|
---|
190 | # Adjust the ram, I/O APIC and stuff.
|
---|
191 | #
|
---|
192 |
|
---|
193 | oSession = oTestDrv.openSession(oVM);
|
---|
194 | if oSession is None:
|
---|
195 | return None;
|
---|
196 |
|
---|
197 | fRc = True;
|
---|
198 |
|
---|
199 | ## Set proper boot order - IUnattended::reconfigureVM does this, doesn't it?
|
---|
200 | #fRc = fRc and oSession.setBootOrder(1, vboxcon.DeviceType_HardDisk)
|
---|
201 | #fRc = fRc and oSession.setBootOrder(2, vboxcon.DeviceType_DVD)
|
---|
202 |
|
---|
203 | # Adjust memory if requested.
|
---|
204 | if self.iOptRamAdjust != 0:
|
---|
205 | try: cMbRam = oSession.o.machine.memorySize;
|
---|
206 | except: fRc = reporter.errorXcpt();
|
---|
207 | else:
|
---|
208 | fRc = oSession.setRamSize(cMbRam + self.iOptRamAdjust) and fRc;
|
---|
209 |
|
---|
210 | # I/O APIC:
|
---|
211 | if self.fOptIoApic is not None:
|
---|
212 | fRc = oSession.enableIoApic(self.fOptIoApic) and fRc;
|
---|
213 |
|
---|
214 | # I/O APIC:
|
---|
215 | if self.fOptPae is not None:
|
---|
216 | fRc = oSession.enablePae(self.fOptPae) and fRc;
|
---|
217 |
|
---|
218 | # Set extra data
|
---|
219 | for sExtraData in self.asOptExtraData:
|
---|
220 | sKey, sValue = sExtraData.split(':');
|
---|
221 | reporter.log('Set extradata: %s => %s' % (sKey, sValue))
|
---|
222 | fRc = oSession.setExtraData(sKey, sValue) and fRc;
|
---|
223 |
|
---|
224 | # Save the settings.
|
---|
225 | fRc = fRc and oSession.saveSettings()
|
---|
226 | fRc = oSession.close() and fRc;
|
---|
227 |
|
---|
228 | return oVM if fRc else None;
|
---|
229 |
|
---|
230 | def _skipVmTest(self, oTestDrv, oVM):
|
---|
231 | _ = oVM;
|
---|
232 | #
|
---|
233 | # Check for ubuntu installer vs. AMD host CPU.
|
---|
234 | #
|
---|
235 | if self.fInstVmFlags & self.kfUbuntuNewAmdBug:
|
---|
236 | if self.isHostCpuAffectedByUbuntuNewAmdBug(oTestDrv):
|
---|
237 | return True;
|
---|
238 |
|
---|
239 | return vboxtestvms.BaseTestVm._skipVmTest(self, oTestDrv, oVM);
|
---|
240 |
|
---|
241 | def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
|
---|
242 | #
|
---|
243 | # Do the standard reconfig in the base class first, it'll figure out
|
---|
244 | # if we can run the VM as requested.
|
---|
245 | #
|
---|
246 | (fRc, oVM) = vboxtestvms.BaseTestVm.getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode);
|
---|
247 | if fRc is True:
|
---|
248 | #
|
---|
249 | # Make sure there is no HD from the previous run attached nor taking
|
---|
250 | # up storage on the host.
|
---|
251 | #
|
---|
252 | fRc = self.recreateRecommendedHdd(oVM, oTestDrv);
|
---|
253 | if fRc is True:
|
---|
254 | #
|
---|
255 | # Set up unattended installation.
|
---|
256 | #
|
---|
257 | try:
|
---|
258 | oIUnattended = oTestDrv.oVBox.createUnattendedInstaller();
|
---|
259 | except:
|
---|
260 | fRc = reporter.errorXcpt();
|
---|
261 | if fRc is True:
|
---|
262 | fRc = self.unattendedDetectOs(oIUnattended, oTestDrv);
|
---|
263 | if fRc is True:
|
---|
264 | fRc = self._unattendedConfigure(oIUnattended, oTestDrv);
|
---|
265 | if fRc is True:
|
---|
266 | fRc = self._unattendedDoIt(oIUnattended, oVM, oTestDrv);
|
---|
267 |
|
---|
268 | # Done.
|
---|
269 | return (fRc, oVM)
|
---|
270 |
|
---|
271 | def isLoggedOntoDesktop(self):
|
---|
272 | #
|
---|
273 | # Normally all unattended installations should end up on the desktop.
|
---|
274 | # An exception is a minimal install, but we currently don't support that.
|
---|
275 | #
|
---|
276 | return True;
|
---|
277 |
|
---|
278 | def getTestUser(self):
|
---|
279 | # Default unattended installation user (parent knowns its password).
|
---|
280 | return 'vboxuser';
|
---|
281 |
|
---|
282 |
|
---|
283 | #
|
---|
284 | # Our methods.
|
---|
285 | #
|
---|
286 |
|
---|
287 | def unattendedDetectOs(self, oIUnattended, oTestDrv): # type: (Any, vbox.TestDriver) -> bool
|
---|
288 | """
|
---|
289 | Does the detectIsoOS operation and checks that the detect OSTypeId matches.
|
---|
290 |
|
---|
291 | Returns True on success, False w/ errors logged on failure.
|
---|
292 | """
|
---|
293 |
|
---|
294 | #
|
---|
295 | # Point the installer at the ISO and do the detection.
|
---|
296 | #
|
---|
297 | sInstallIso = self.sInstallIso
|
---|
298 | if not os.path.isabs(sInstallIso):
|
---|
299 | sInstallIso = os.path.join(oTestDrv.sResourcePath, sInstallIso);
|
---|
300 |
|
---|
301 | try:
|
---|
302 | oIUnattended.isoPath = sInstallIso;
|
---|
303 | except:
|
---|
304 | return reporter.errorXcpt('sInstallIso=%s' % (sInstallIso,));
|
---|
305 |
|
---|
306 | try:
|
---|
307 | oIUnattended.detectIsoOS();
|
---|
308 | except:
|
---|
309 | if oTestDrv.oVBoxMgr.xcptIsNotEqual(None, oTestDrv.oVBoxMgr.statuses.E_NOTIMPL):
|
---|
310 | return reporter.errorXcpt('sInstallIso=%s' % (sInstallIso,));
|
---|
311 |
|
---|
312 | #
|
---|
313 | # Get and log the result.
|
---|
314 | #
|
---|
315 | # Note! Current (6.0.97) fails with E_NOTIMPL even if it does some work.
|
---|
316 | #
|
---|
317 | try:
|
---|
318 | sDetectedOSTypeId = oIUnattended.detectedOSTypeId;
|
---|
319 | sDetectedOSVersion = oIUnattended.detectedOSVersion;
|
---|
320 | sDetectedOSFlavor = oIUnattended.detectedOSFlavor;
|
---|
321 | sDetectedOSLanguages = oIUnattended.detectedOSLanguages;
|
---|
322 | sDetectedOSHints = oIUnattended.detectedOSHints;
|
---|
323 | except:
|
---|
324 | return reporter.errorXcpt('sInstallIso=%s' % (sInstallIso,));
|
---|
325 |
|
---|
326 | reporter.log('detectIsoOS result for "%s" (vm %s):' % (sInstallIso, self.sVmName));
|
---|
327 | reporter.log(' DetectedOSTypeId: %s' % (sDetectedOSTypeId,));
|
---|
328 | reporter.log(' DetectedOSVersion: %s' % (sDetectedOSVersion,));
|
---|
329 | reporter.log(' DetectedOSFlavor: %s' % (sDetectedOSFlavor,));
|
---|
330 | reporter.log(' DetectedOSLanguages: %s' % (sDetectedOSLanguages,));
|
---|
331 | reporter.log(' DetectedOSHints: %s' % (sDetectedOSHints,));
|
---|
332 |
|
---|
333 | #
|
---|
334 | # Check if the OS type matches.
|
---|
335 | #
|
---|
336 | if self.sKind != sDetectedOSTypeId:
|
---|
337 | return reporter.error('sInstallIso=%s: DetectedOSTypeId is %s, expected %s'
|
---|
338 | % (sInstallIso, sDetectedOSTypeId, self.sKind));
|
---|
339 |
|
---|
340 | return True;
|
---|
341 |
|
---|
342 |
|
---|
343 | class tdGuestOsInstTest1(vbox.TestDriver):
|
---|
344 | """
|
---|
345 | Unattended Guest OS installation tests using IUnattended.
|
---|
346 |
|
---|
347 | Scenario:
|
---|
348 | - Create a new VM with default settings using IMachine::applyDefaults.
|
---|
349 | - Setup unattended installation using IUnattended.
|
---|
350 | - Start the VM and do the installation.
|
---|
351 | - Wait for TXS to report for service.
|
---|
352 | - If installing GAs:
|
---|
353 | - Wait for GAs to report operational runlevel.
|
---|
354 | - Save & restore state.
|
---|
355 | - If installing GAs:
|
---|
356 | - Test guest properties (todo).
|
---|
357 | - Test guest controls.
|
---|
358 | - Test shared folders.
|
---|
359 | """
|
---|
360 |
|
---|
361 |
|
---|
362 | def __init__(self):
|
---|
363 | """
|
---|
364 | Reinitialize child class instance.
|
---|
365 | """
|
---|
366 | vbox.TestDriver.__init__(self)
|
---|
367 | self.fLegacyOptions = False;
|
---|
368 | assert self.fEnableVrdp; # in parent driver.
|
---|
369 |
|
---|
370 | #
|
---|
371 | # Our install test VM set.
|
---|
372 | #
|
---|
373 | oSet = vboxtestvms.TestVmSet(self.oTestVmManager, fIgnoreSkippedVm = True);
|
---|
374 | oSet.aoTestVms.extend([
|
---|
375 | # Windows7 RTM:
|
---|
376 | UnattendedVm(oSet, 'tst-w7-32', 'Windows7', '6.0/uaisos/en_windows_7_enterprise_x86_dvd_x15-70745.iso'), # 5.7GiB
|
---|
377 | UnattendedVm(oSet, 'tst-w7-64', 'Windows7_64', '6.0/uaisos/en_windows_7_enterprise_x64_dvd_x15-70749.iso'), # 10GiB
|
---|
378 | UnattendedVm(oSet, 'tst-ubuntu-16.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.04-desktop-amd64.iso'),
|
---|
379 | #UnattendedVm(oSet, 'tst-ubuntu-18.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-18.04-desktop-amd64.iso'), # >=5.7GiB
|
---|
380 | ]);
|
---|
381 | self.oTestVmSet = oSet;
|
---|
382 |
|
---|
383 | # For option parsing:
|
---|
384 | self.aoSelectedVms = oSet.aoTestVms # type: list(UnattendedVm)
|
---|
385 |
|
---|
386 | # Number of VMs to test in parallel:
|
---|
387 | self.cInParallel = 1;
|
---|
388 |
|
---|
389 | # Whether to do the save-and-restore test.
|
---|
390 | self.fTestSaveAndRestore = True;
|
---|
391 |
|
---|
392 | #
|
---|
393 | # Sub-test drivers.
|
---|
394 | #
|
---|
395 | self.addSubTestDriver(SubTstDrvAddSharedFolders1(self, fUseAltFsPerfPathForWindows = True)); # !HACK ALERT! UDF cloning.
|
---|
396 | self.addSubTestDriver(SubTstDrvAddGuestCtrl(self));
|
---|
397 |
|
---|
398 |
|
---|
399 | #
|
---|
400 | # Overridden methods.
|
---|
401 | #
|
---|
402 |
|
---|
403 | def showUsage(self):
|
---|
404 | """
|
---|
405 | Extend usage info
|
---|
406 | """
|
---|
407 | rc = vbox.TestDriver.showUsage(self)
|
---|
408 | reporter.log('');
|
---|
409 | reporter.log('tdGuestOsUnattendedInst1 options:');
|
---|
410 | reporter.log(' --parallel <num>');
|
---|
411 | reporter.log(' Number of VMs to test in parallel.');
|
---|
412 | reporter.log(' Default: 1');
|
---|
413 | reporter.log('');
|
---|
414 | reporter.log(' Options for working on selected test VMs:');
|
---|
415 | reporter.log(' --select <vm1[:vm2[:..]]>');
|
---|
416 | reporter.log(' Selects a test VM for the following configuration alterations.');
|
---|
417 | reporter.log(' Default: All possible test VMs');
|
---|
418 | reporter.log(' --copy <old-vm>=<new-vm>');
|
---|
419 | reporter.log(' Creates and selects <new-vm> as a copy of <old-vm>.');
|
---|
420 | reporter.log(' --guest-type <guest-os-type>');
|
---|
421 | reporter.log(' Sets the guest-os type of the currently selected test VM.');
|
---|
422 | reporter.log(' --install-iso <ISO file name>');
|
---|
423 | reporter.log(' Sets ISO image to use for the selected test VM.');
|
---|
424 | reporter.log(' --ram-adjust <MBs>');
|
---|
425 | reporter.log(' Adjust the VM ram size by the given delta. Both negative and positive');
|
---|
426 | reporter.log(' values are accepted.');
|
---|
427 | reporter.log(' --max-cpus <# CPUs>');
|
---|
428 | reporter.log(' Sets the maximum number of guest CPUs for the selected VM.');
|
---|
429 | reporter.log(' --set-extradata <key>:value');
|
---|
430 | reporter.log(' Set VM extra data for the selected VM. Can be repeated.');
|
---|
431 | reporter.log(' --ioapic, --no-ioapic');
|
---|
432 | reporter.log(' Enable or disable the I/O apic for the selected VM.');
|
---|
433 | reporter.log(' --pae, --no-pae');
|
---|
434 | reporter.log(' Enable or disable PAE support (32-bit guests only) for the selected VM.');
|
---|
435 | return rc
|
---|
436 |
|
---|
437 | def parseOption(self, asArgs, iArg):
|
---|
438 | """
|
---|
439 | Extend standard options set
|
---|
440 | """
|
---|
441 |
|
---|
442 | if asArgs[iArg] == '--parallel':
|
---|
443 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
444 | self.cInParallel = int(asArgs[iArg]);
|
---|
445 | if self.cInParallel <= 0:
|
---|
446 | self.cInParallel = 1;
|
---|
447 | elif asArgs[iArg] == '--select':
|
---|
448 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
449 | self.aoSelectedVms = [];
|
---|
450 | for sTestVm in asArgs[iArg].split(':'):
|
---|
451 | oTestVm = self.oTestVmSet.findTestVmByName(sTestVm);
|
---|
452 | if not oTestVm:
|
---|
453 | raise base.InvalidOption('Unknown test VM: %s' % (sTestVm,));
|
---|
454 | self.aoSelectedVms.append(oTestVm);
|
---|
455 | elif asArgs[iArg] == '--copy':
|
---|
456 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
457 | asNames = asArgs[iArg].split('=');
|
---|
458 | if len(asNames) != 2 or not asNames[0] or not asNames[1]:
|
---|
459 | raise base.InvalidOption('The --copy option expects value on the form "old=new": %s' % (asArgs[iArg],));
|
---|
460 | oOldTestVm = self.oTestVmSet.findTestVmByName(asNames[0]);
|
---|
461 | if not oOldTestVm:
|
---|
462 | raise base.InvalidOption('Unknown test VM: %s' % (asNames[0],));
|
---|
463 | oNewTestVm = copy.deepcopy(oOldTestVm);
|
---|
464 | oNewTestVm.sVmName = asNames[1];
|
---|
465 | self.oTestVmSet.aoTestVms.append(oNewTestVm);
|
---|
466 | self.aoSelectedVms = [oNewTestVm];
|
---|
467 | elif asArgs[iArg] == '--guest-type':
|
---|
468 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
469 | for oTestVm in self.aoSelectedVms:
|
---|
470 | oTestVm.sKind = asArgs[iArg];
|
---|
471 | elif asArgs[iArg] == '--install-iso':
|
---|
472 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
473 | for oTestVm in self.aoSelectedVms:
|
---|
474 | oTestVm.sInstallIso = asArgs[iArg];
|
---|
475 | elif asArgs[iArg] == '--ram-adjust':
|
---|
476 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
477 | for oTestVm in self.aoSelectedVms:
|
---|
478 | oTestVm.iOptRamAdjust = int(asArgs[iArg]);
|
---|
479 | elif asArgs[iArg] == '--max-cpus':
|
---|
480 | iArg = self.requireMoreArgs(1, asArgs, iArg);
|
---|
481 | for oTestVm in self.aoSelectedVms:
|
---|
482 | oTestVm.iOptMaxCpus = int(asArgs[iArg]);
|
---|
483 | elif asArgs[iArg] == '--set-extradata':
|
---|
484 | iArg = self.requireMoreArgs(1, asArgs, iArg)
|
---|
485 | sExtraData = asArgs[iArg];
|
---|
486 | try: _, _ = sExtraData.split(':');
|
---|
487 | except: raise base.InvalidOption('Invalid extradata specified: %s' % (sExtraData, ));
|
---|
488 | for oTestVm in self.aoSelectedVms:
|
---|
489 | oTestVm.asOptExtraData.append(sExtraData);
|
---|
490 | elif asArgs[iArg] == '--ioapic':
|
---|
491 | for oTestVm in self.aoSelectedVms:
|
---|
492 | oTestVm.fOptIoApic = True;
|
---|
493 | elif asArgs[iArg] == '--no-ioapic':
|
---|
494 | for oTestVm in self.aoSelectedVms:
|
---|
495 | oTestVm.fOptIoApic = False;
|
---|
496 | elif asArgs[iArg] == '--pae':
|
---|
497 | for oTestVm in self.aoSelectedVms:
|
---|
498 | oTestVm.fOptPae = True;
|
---|
499 | elif asArgs[iArg] == '--no-pae':
|
---|
500 | for oTestVm in self.aoSelectedVms:
|
---|
501 | oTestVm.fOptPae = False;
|
---|
502 | elif asArgs[iArg] == '--install-additions':
|
---|
503 | for oTestVm in self.aoSelectedVms:
|
---|
504 | oTestVm.fOptInstallAdditions = True;
|
---|
505 | elif asArgs[iArg] == '--no-install-additions':
|
---|
506 | for oTestVm in self.aoSelectedVms:
|
---|
507 | oTestVm.fOptInstallAdditions = False;
|
---|
508 | else:
|
---|
509 | return vbox.TestDriver.parseOption(self, asArgs, iArg);
|
---|
510 | return iArg + 1;
|
---|
511 |
|
---|
512 | def actionConfig(self):
|
---|
513 | if not self.importVBoxApi(): # So we can use the constant below.
|
---|
514 | return False;
|
---|
515 | return self.oTestVmSet.actionConfig(self, eNic0AttachType = vboxcon.NetworkAttachmentType_HostOnly);
|
---|
516 |
|
---|
517 | def actionExecute(self):
|
---|
518 | """
|
---|
519 | Execute the testcase.
|
---|
520 | """
|
---|
521 | return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
|
---|
522 |
|
---|
523 | def testOneVmConfig(self, oVM, oTestVm): # type: (Any, UnattendedVm) -> bool
|
---|
524 | """
|
---|
525 | Install guest OS and wait for result
|
---|
526 | """
|
---|
527 |
|
---|
528 | self.logVmInfo(oVM)
|
---|
529 | reporter.testStart('Installing %s%s' % (oTestVm.sVmName, ' with GAs' if oTestVm.fOptInstallAdditions else ''))
|
---|
530 |
|
---|
531 | cMsTimeout = 40*60000;
|
---|
532 | if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
|
---|
533 | cMsTimeout = 180 * 60000; # will be adjusted down.
|
---|
534 |
|
---|
535 | oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
|
---|
536 | #oSession = self.startVmByName(oTestVm.sVmName); # (for quickly testing waitForGAs)
|
---|
537 | if oSession is not None:
|
---|
538 | # The guest has connected to TXS.
|
---|
539 | reporter.log('Guest reported success via TXS.');
|
---|
540 | reporter.testDone();
|
---|
541 |
|
---|
542 | fRc = True;
|
---|
543 | # Kudge: GAs doesn't come up correctly, so we have to reboot the guest first:
|
---|
544 | # Looks like VBoxService isn't there.
|
---|
545 | if oTestVm.fOptInstallAdditions:
|
---|
546 | reporter.testStart('Rebooting');
|
---|
547 | fRc, oTxsSession = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession);
|
---|
548 | reporter.testDone();
|
---|
549 |
|
---|
550 | # If we're installing GAs, wait for them to come online:
|
---|
551 | if oTestVm.fOptInstallAdditions and fRc is True:
|
---|
552 | reporter.testStart('Guest additions');
|
---|
553 | aenmRunLevels = [vboxcon.AdditionsRunLevelType_Userland,];
|
---|
554 | if oTestVm.isLoggedOntoDesktop():
|
---|
555 | aenmRunLevels.append(vboxcon.AdditionsRunLevelType_Desktop);
|
---|
556 | fRc = self.waitForGAs(oSession, cMsTimeout = cMsTimeout / 2, aenmWaitForRunLevels = aenmRunLevels,
|
---|
557 | aenmWaitForActive = (vboxcon.AdditionsFacilityType_VBoxGuestDriver,
|
---|
558 | vboxcon.AdditionsFacilityType_VBoxService,));
|
---|
559 | reporter.testDone();
|
---|
560 |
|
---|
561 | # Now do a save & restore test:
|
---|
562 | if fRc is True and self.fTestSaveAndRestore:
|
---|
563 | fRc, oSession, oTxsSession = self.testSaveAndRestore(oSession, oTxsSession, oTestVm);
|
---|
564 |
|
---|
565 | # Test GAs if requested:
|
---|
566 | if oTestVm.fOptInstallAdditions and fRc is True:
|
---|
567 | for oSubTstDrv in self.aoSubTstDrvs:
|
---|
568 | if oSubTstDrv.fEnabled:
|
---|
569 | reporter.testStart(oSubTstDrv.sTestName);
|
---|
570 | fRc2, oTxsSession = oSubTstDrv.testIt(oTestVm, oSession, oTxsSession);
|
---|
571 | reporter.testDone(fRc2 is None);
|
---|
572 | if fRc2 is False:
|
---|
573 | fRc = False;
|
---|
574 |
|
---|
575 | if oSession is not None:
|
---|
576 | fRc = self.terminateVmBySession(oSession) and fRc;
|
---|
577 | return fRc is True
|
---|
578 |
|
---|
579 | reporter.error('Installation of %s has failed' % (oTestVm.sVmName,))
|
---|
580 | #oTestVm.detatchAndDeleteHd(self); # Save space.
|
---|
581 | reporter.testDone()
|
---|
582 | return False
|
---|
583 |
|
---|
584 | def testSaveAndRestore(self, oSession, oTxsSession, oTestVm):
|
---|
585 | """
|
---|
586 | Tests saving and restoring the VM.
|
---|
587 | """
|
---|
588 | _ = oTestVm;
|
---|
589 | reporter.testStart('Save');
|
---|
590 | ## @todo
|
---|
591 | reporter.testDone();
|
---|
592 | reporter.testStart('Restore');
|
---|
593 | ## @todo
|
---|
594 | reporter.testDone();
|
---|
595 | return (True, oSession, oTxsSession);
|
---|
596 |
|
---|
597 | if __name__ == '__main__':
|
---|
598 | sys.exit(tdGuestOsInstTest1().main(sys.argv))
|
---|
599 |
|
---|