VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/installation/tdGuestOsUnattendedInst1.py@ 92050

Last change on this file since 92050 was 92050, checked in by vboxsync, 3 years ago

ValidationKit: bugref:9932 Use host-only networks instead of adapters on Mac OS

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 35.2 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdGuestOsUnattendedInst1.py 92050 2021-10-25 16:58:55Z vboxsync $
4
5"""
6VirtualBox Validation Kit - Guest OS unattended installation tests.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2020 Oracle Corporation
12
13This file is part of VirtualBox Open Source Edition (OSE), as
14available from http://www.virtualbox.org. This file is free software;
15you can redistribute it and/or modify it under the terms of the GNU
16General Public License (GPL) as published by the Free Software
17Foundation, in version 2 as it comes in the "COPYING" file of the
18VirtualBox OSE distribution. VirtualBox OSE is distributed in the
19hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
20
21The contents of this file may alternatively be used under the terms
22of the Common Development and Distribution License Version 1.0
23(CDDL) only, as it comes in the "COPYING.CDDL" file of the
24VirtualBox OSE distribution, in which case the provisions of the
25CDDL are applicable instead of those of the GPL.
26
27You may elect to license modified versions of this file under the
28terms and conditions of either the GPL or the CDDL or both.
29"""
30__version__ = "$Revision: 92050 $"
31
32
33# Standard Python imports.
34import copy;
35import os;
36import sys;
37
38
39# Only the main script needs to modify the path.
40try: __file__
41except: __file__ = sys.argv[0]
42g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
43sys.path.append(g_ksValidationKitDir)
44
45# Validation Kit imports.
46from testdriver import vbox;
47from testdriver import base;
48from testdriver import reporter;
49from testdriver import vboxcon;
50from testdriver import vboxtestvms;
51from common import utils;
52
53# Sub-test driver imports.
54sys.path.append(os.path.join(g_ksValidationKitDir, 'tests', 'additions'));
55from tdAddGuestCtrl import SubTstDrvAddGuestCtrl;
56from tdAddSharedFolders1 import SubTstDrvAddSharedFolders1;
57
58
59class UnattendedVm(vboxtestvms.BaseTestVm):
60 """ Unattended Installation test VM. """
61
62 ## @name VM option flags (OR together).
63 ## @{
64 kfUbuntuAvx2Crash = 0x0001; ##< Disables AVX2 as ubuntu 16.04 think it means AVX512 is available and compiz crashes.
65 kfNoGAs = 0x0002; ##< No guest additions installation possible.
66 kfKeyFile = 0x0004; ##< ISO requires a .key file containing the product key.
67 kfNeedCom1 = 0x0008; ##< Need serial port, typically for satifying the windows kernel debugger.
68
69 kfIdeIrqDelay = 0x1000;
70 kfUbuntuNewAmdBug = 0x2000;
71 kfNoWin81Paravirt = 0x4000;
72 ## @}
73
74 ## kfUbuntuAvx2Crash: Extra data that disables AVX2.
75 kasUbuntuAvx2Crash = [ '/CPUM/IsaExts/AVX2:0', ];
76
77 ## IRQ delay extra data config for win2k VMs.
78 kasIdeIrqDelay = [ 'VBoxInternal/Devices/piix3ide/0/Config/IRQDelay:1', ];
79
80 def __init__(self, oSet, sVmName, sKind, sInstallIso, fFlags = 0):
81 vboxtestvms.BaseTestVm.__init__(self, sVmName, oSet = oSet, sKind = sKind,
82 fRandomPvPModeCrap = (fFlags & self.kfNoWin81Paravirt) == 0);
83 self.sInstallIso = sInstallIso;
84 self.fInstVmFlags = fFlags;
85
86 # Adjustments over the defaults.
87 self.iOptRamAdjust = 0;
88 self.fOptIoApic = None;
89 self.fOptPae = None;
90 self.fOptInstallAdditions = False;
91 self.asOptExtraData = [];
92 if fFlags & self.kfUbuntuAvx2Crash:
93 self.asOptExtraData += self.kasUbuntuAvx2Crash;
94 if fFlags & self.kfIdeIrqDelay:
95 self.asOptExtraData += self.kasIdeIrqDelay;
96 if fFlags & self.kfNeedCom1:
97 self.fCom1RawFile = True;
98
99 def _unattendedConfigure(self, oIUnattended, oTestDrv): # type: (Any, vbox.TestDriver) -> bool
100 """
101 Configures the unattended install object.
102
103 The ISO attribute has been set and detectIsoOS has been done, the rest of the
104 setup is done here.
105
106 Returns True on success, False w/ errors logged on failure.
107 """
108
109 #
110 # Make it install the TXS.
111 #
112 try: oIUnattended.installTestExecService = True;
113 except: return reporter.errorXcpt();
114 try: oIUnattended.validationKitIsoPath = oTestDrv.sVBoxValidationKitIso;
115 except: return reporter.errorXcpt();
116 oTestDrv.processPendingEvents();
117
118 #
119 # Install GAs?
120 #
121 if self.fOptInstallAdditions:
122 if (self.fInstVmFlags & self.kfNoGAs) == 0:
123 try: oIUnattended.installGuestAdditions = True;
124 except: return reporter.errorXcpt();
125 try: oIUnattended.additionsIsoPath = oTestDrv.getGuestAdditionsIso();
126 except: return reporter.errorXcpt();
127 oTestDrv.processPendingEvents();
128 else:
129 reporter.log("Warning! Ignoring request to install Guest Additions as kfNoGAs is set!");
130
131 #
132 # Product key?
133 #
134 if self.fInstVmFlags & UnattendedVm.kfKeyFile:
135 sKeyFile = '';
136 sKey = '';
137 try:
138 sKeyFile = oIUnattended.isoPath + '.key';
139 oFile = utils.openNoInherit(sKeyFile);
140 for sLine in oFile:
141 sLine = sLine.strip();
142 if sLine and not sLine.startswith(';') and not sLine.startswith('#') and not sLine.startswith('//'):
143 sKey = sLine;
144 break;
145 oFile.close();
146 except:
147 return reporter.errorXcpt('sKeyFile=%s' % (sKeyFile,));
148 if not sKey:
149 return reporter.error('No key in keyfile (%s)!' % (sKeyFile,));
150 try: oIUnattended.productKey = sKey;
151 except: return reporter.errorXcpt();
152
153 return True;
154
155 def _unattendedDoIt(self, oIUnattended, oVM, oTestDrv): # type: (Any, Any, vbox.TestDriver) -> bool
156 """
157 Does the unattended installation preparing, media construction and VM reconfiguration.
158
159 Returns True on success, False w/ errors logged on failure.
160 """
161
162 # Associate oVM with the installer:
163 try:
164 oIUnattended.machine = oVM;
165 except:
166 return reporter.errorXcpt();
167 oTestDrv.processPendingEvents();
168
169 # Prepare and log it:
170 try:
171 oIUnattended.prepare();
172 except:
173 return reporter.errorXcpt("IUnattended.prepare failed");
174 oTestDrv.processPendingEvents();
175
176 reporter.log('IUnattended attributes after prepare():');
177 self._unattendedLogIt(oIUnattended, oTestDrv);
178
179 # Create media:
180 try:
181 oIUnattended.constructMedia();
182 except:
183 return reporter.errorXcpt("IUnattended.constructMedia failed");
184 oTestDrv.processPendingEvents();
185
186 # Reconfigure the VM:
187 try:
188 oIUnattended.reconfigureVM();
189 except:
190 return reporter.errorXcpt("IUnattended.reconfigureVM failed");
191 oTestDrv.processPendingEvents();
192
193 return True;
194
195 def _unattendedLogIt(self, oIUnattended, oTestDrv):
196 """
197 Logs the attributes of the unattended installation object.
198 """
199 fRc = True;
200 asAttribs = ( 'isoPath', 'user', 'password', 'fullUserName', 'productKey', 'additionsIsoPath', 'installGuestAdditions',
201 'validationKitIsoPath', 'installTestExecService', 'timeZone', 'locale', 'language', 'country', 'proxy',
202 'packageSelectionAdjustments', 'hostname', 'auxiliaryBasePath', 'imageIndex', 'machine',
203 'scriptTemplatePath', 'postInstallScriptTemplatePath', 'postInstallCommand',
204 'extraInstallKernelParameters', 'detectedOSTypeId', 'detectedOSVersion', 'detectedOSLanguages',
205 'detectedOSFlavor', 'detectedOSHints', );
206 for sAttrib in asAttribs:
207 try:
208 oValue = getattr(oIUnattended, sAttrib);
209 except:
210 fRc = reporter.errorXcpt('sAttrib=%s' % sAttrib);
211 else:
212 reporter.log('%s: %s' % (sAttrib.rjust(32), oValue,));
213 oTestDrv.processPendingEvents();
214 return fRc;
215
216
217 #
218 # Overriden methods.
219 #
220
221 def getResourceSet(self):
222 asRet = [];
223 if not os.path.isabs(self.sInstallIso):
224 asRet.append(self.sInstallIso);
225 if self.fInstVmFlags & UnattendedVm.kfKeyFile:
226 asRet.append(self.sInstallIso + '.key');
227 return asRet;
228
229 def _createVmDoIt(self, oTestDrv, eNic0AttachType, sDvdImage):
230 #
231 # Use HostOnly networking for ubuntu and debian VMs to prevent them from
232 # downloading updates and doing database updates during installation.
233 # We want predicable results.
234 #
235 if eNic0AttachType is None:
236 if self.isLinux() \
237 and ( 'ubuntu' in self.sKind.lower()
238 or 'debian' in self.sKind.lower()):
239 eNic0AttachType = vboxcon.NetworkAttachmentType_HostOnly;
240
241 # Also use it for windows xp to prevent it from ever going online.
242 if self.sKind in ('WindowsXP','WindowsXP_64',):
243 eNic0AttachType = vboxcon.NetworkAttachmentType_HostOnly;
244
245 #
246 # Use host-only networks instead of host-only adapters for trunk builds on Mac OS.
247 #
248 if eNic0AttachType == vboxcon.NetworkAttachmentType_HostOnly \
249 and utils.getHostOs() == 'darwin' \
250 and oTestDrv.fpApiVer >= 7.0:
251 eNic0AttachType = vboxcon.NetworkAttachmentType_HostOnlyNetwork;
252
253 return vboxtestvms.BaseTestVm._createVmDoIt(self, oTestDrv, eNic0AttachType, sDvdImage);
254
255
256 def _createVmPost(self, oTestDrv, oVM, eNic0AttachType, sDvdImage):
257 #
258 # Adjust the ram, I/O APIC and stuff.
259 #
260
261 oSession = oTestDrv.openSession(oVM);
262 if oSession is None:
263 return None;
264
265 fRc = True;
266
267 ## Set proper boot order - IUnattended::reconfigureVM does this, doesn't it?
268 #fRc = fRc and oSession.setBootOrder(1, vboxcon.DeviceType_HardDisk)
269 #fRc = fRc and oSession.setBootOrder(2, vboxcon.DeviceType_DVD)
270
271 # Adjust memory if requested.
272 if self.iOptRamAdjust != 0:
273 try: cMbRam = oSession.o.machine.memorySize;
274 except: fRc = reporter.errorXcpt();
275 else:
276 fRc = oSession.setRamSize(cMbRam + self.iOptRamAdjust) and fRc;
277
278 # I/O APIC:
279 if self.fOptIoApic is not None:
280 fRc = oSession.enableIoApic(self.fOptIoApic) and fRc;
281
282 # I/O APIC:
283 if self.fOptPae is not None:
284 fRc = oSession.enablePae(self.fOptPae) and fRc;
285
286 # Set extra data
287 for sExtraData in self.asOptExtraData:
288 sKey, sValue = sExtraData.split(':');
289 reporter.log('Set extradata: %s => %s' % (sKey, sValue))
290 fRc = oSession.setExtraData(sKey, sValue) and fRc;
291
292 # Save the settings.
293 fRc = fRc and oSession.saveSettings()
294 fRc = oSession.close() and fRc;
295
296 return oVM if fRc else None;
297
298 def _skipVmTest(self, oTestDrv, oVM):
299 _ = oVM;
300 #
301 # Check for ubuntu installer vs. AMD host CPU.
302 #
303 if self.fInstVmFlags & self.kfUbuntuNewAmdBug:
304 if self.isHostCpuAffectedByUbuntuNewAmdBug(oTestDrv):
305 return True;
306
307 return vboxtestvms.BaseTestVm._skipVmTest(self, oTestDrv, oVM);
308
309 def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
310 #
311 # Do the standard reconfig in the base class first, it'll figure out
312 # if we can run the VM as requested.
313 #
314 (fRc, oVM) = vboxtestvms.BaseTestVm.getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode);
315 if fRc is True:
316 #
317 # Make sure there is no HD from the previous run attached nor taking
318 # up storage on the host.
319 #
320 fRc = self.recreateRecommendedHdd(oVM, oTestDrv);
321 if fRc is True:
322 #
323 # Set up unattended installation.
324 #
325 try:
326 oIUnattended = oTestDrv.oVBox.createUnattendedInstaller();
327 except:
328 fRc = reporter.errorXcpt();
329 if fRc is True:
330 fRc = self.unattendedDetectOs(oIUnattended, oTestDrv);
331 if fRc is True:
332 fRc = self._unattendedConfigure(oIUnattended, oTestDrv);
333 if fRc is True:
334 fRc = self._unattendedDoIt(oIUnattended, oVM, oTestDrv);
335
336 # Done.
337 return (fRc, oVM)
338
339 def isLoggedOntoDesktop(self):
340 #
341 # Normally all unattended installations should end up on the desktop.
342 # An exception is a minimal install, but we currently don't support that.
343 #
344 return True;
345
346 def getTestUser(self):
347 # Default unattended installation user (parent knowns its password).
348 return 'vboxuser';
349
350
351 #
352 # Our methods.
353 #
354
355 def unattendedDetectOs(self, oIUnattended, oTestDrv): # type: (Any, vbox.TestDriver) -> bool
356 """
357 Does the detectIsoOS operation and checks that the detect OSTypeId matches.
358
359 Returns True on success, False w/ errors logged on failure.
360 """
361
362 #
363 # Point the installer at the ISO and do the detection.
364 #
365 sInstallIso = self.sInstallIso
366 if not os.path.isabs(sInstallIso):
367 sInstallIso = os.path.join(oTestDrv.sResourcePath, sInstallIso);
368
369 try:
370 oIUnattended.isoPath = sInstallIso;
371 except:
372 return reporter.errorXcpt('sInstallIso=%s' % (sInstallIso,));
373
374 try:
375 oIUnattended.detectIsoOS();
376 except:
377 if oTestDrv.oVBoxMgr.xcptIsNotEqual(None, oTestDrv.oVBoxMgr.statuses.E_NOTIMPL):
378 return reporter.errorXcpt('sInstallIso=%s' % (sInstallIso,));
379
380 #
381 # Get and log the result.
382 #
383 # Note! Current (6.0.97) fails with E_NOTIMPL even if it does some work.
384 #
385 try:
386 sDetectedOSTypeId = oIUnattended.detectedOSTypeId;
387 sDetectedOSVersion = oIUnattended.detectedOSVersion;
388 sDetectedOSFlavor = oIUnattended.detectedOSFlavor;
389 sDetectedOSLanguages = oIUnattended.detectedOSLanguages;
390 sDetectedOSHints = oIUnattended.detectedOSHints;
391 except:
392 return reporter.errorXcpt('sInstallIso=%s' % (sInstallIso,));
393
394 reporter.log('detectIsoOS result for "%s" (vm %s):' % (sInstallIso, self.sVmName));
395 reporter.log(' DetectedOSTypeId: %s' % (sDetectedOSTypeId,));
396 reporter.log(' DetectedOSVersion: %s' % (sDetectedOSVersion,));
397 reporter.log(' DetectedOSFlavor: %s' % (sDetectedOSFlavor,));
398 reporter.log(' DetectedOSLanguages: %s' % (sDetectedOSLanguages,));
399 reporter.log(' DetectedOSHints: %s' % (sDetectedOSHints,));
400
401 #
402 # Check if the OS type matches.
403 #
404 if self.sKind != sDetectedOSTypeId:
405 return reporter.error('sInstallIso=%s: DetectedOSTypeId is %s, expected %s'
406 % (sInstallIso, sDetectedOSTypeId, self.sKind));
407
408 return True;
409
410
411class tdGuestOsInstTest1(vbox.TestDriver):
412 """
413 Unattended Guest OS installation tests using IUnattended.
414
415 Scenario:
416 - Create a new VM with default settings using IMachine::applyDefaults.
417 - Setup unattended installation using IUnattended.
418 - Start the VM and do the installation.
419 - Wait for TXS to report for service.
420 - If installing GAs:
421 - Wait for GAs to report operational runlevel.
422 - Save & restore state.
423 - If installing GAs:
424 - Test guest properties (todo).
425 - Test guest controls.
426 - Test shared folders.
427 """
428
429
430 def __init__(self):
431 """
432 Reinitialize child class instance.
433 """
434 vbox.TestDriver.__init__(self)
435 self.fLegacyOptions = False;
436 assert self.fEnableVrdp; # in parent driver.
437
438 #
439 # Our install test VM set.
440 #
441 oSet = vboxtestvms.TestVmSet(self.oTestVmManager, fIgnoreSkippedVm = True);
442 # pylint: disable=line-too-long
443 oSet.aoTestVms.extend([
444 #
445 # Windows. The older windows ISOs requires a keyfile (for xp sp3
446 # pick a key from the PID.INF file on the ISO).
447 #
448 UnattendedVm(oSet, 'tst-xp-32', 'WindowsXP', '6.0/uaisos/en_winxp_pro_x86_build2600_iso.img', UnattendedVm.kfKeyFile), # >=2GiB
449 UnattendedVm(oSet, 'tst-xpsp2-32', 'WindowsXP', '6.0/uaisos/en_winxp_pro_with_sp2.iso', UnattendedVm.kfKeyFile), # >=2GiB
450 UnattendedVm(oSet, 'tst-xpsp3-32', 'WindowsXP', '6.0/uaisos/en_windows_xp_professional_with_service_pack_3_x86_cd_x14-80428.iso', UnattendedVm.kfKeyFile), # >=2GiB
451 UnattendedVm(oSet, 'tst-xp-64', 'WindowsXP_64', '6.0/uaisos/en_win_xp_pro_x64_vl.iso', UnattendedVm.kfKeyFile), # >=3GiB
452 UnattendedVm(oSet, 'tst-xpsp2-64', 'WindowsXP_64', '6.0/uaisos/en_win_xp_pro_x64_with_sp2_vl_x13-41611.iso', UnattendedVm.kfKeyFile), # >=3GiB
453 #fixme: UnattendedVm(oSet, 'tst-xpchk-64', 'WindowsXP_64', '6.0/uaisos/en_windows_xp_professional_x64_chk.iso', UnattendedVm.kfKeyFile | UnattendedVm.kfNeedCom1), # >=3GiB
454 # No key files needed:
455 UnattendedVm(oSet, 'tst-vista-32', 'WindowsVista', '6.0/uaisos/en_windows_vista_ee_x86_dvd_vl_x13-17271.iso'), # >=6GiB
456 UnattendedVm(oSet, 'tst-vista-64', 'WindowsVista_64', '6.0/uaisos/en_windows_vista_enterprise_x64_dvd_vl_x13-17316.iso'), # >=8GiB
457 UnattendedVm(oSet, 'tst-vistasp1-32', 'WindowsVista', '6.0/uaisos/en_windows_vista_enterprise_with_service_pack_1_x86_dvd_x14-55954.iso'), # >=6GiB
458 UnattendedVm(oSet, 'tst-vistasp1-64', 'WindowsVista_64', '6.0/uaisos/en_windows_vista_enterprise_with_service_pack_1_x64_dvd_x14-55934.iso'), # >=9GiB
459 UnattendedVm(oSet, 'tst-vistasp2-32', 'WindowsVista', '6.0/uaisos/en_windows_vista_enterprise_sp2_x86_dvd_342329.iso'), # >=7GiB
460 UnattendedVm(oSet, 'tst-vistasp2-64', 'WindowsVista_64', '6.0/uaisos/en_windows_vista_enterprise_sp2_x64_dvd_342332.iso'), # >=10GiB
461 UnattendedVm(oSet, 'tst-w7-32', 'Windows7', '6.0/uaisos/en_windows_7_enterprise_x86_dvd_x15-70745.iso'), # >=6GiB
462 UnattendedVm(oSet, 'tst-w7-64', 'Windows7_64', '6.0/uaisos/en_windows_7_enterprise_x64_dvd_x15-70749.iso'), # >=10GiB
463 UnattendedVm(oSet, 'tst-w7sp1-32', 'Windows7', '6.0/uaisos/en_windows_7_enterprise_with_sp1_x86_dvd_u_677710.iso'), # >=6GiB
464 UnattendedVm(oSet, 'tst-w7sp1-64', 'Windows7_64', '6.0/uaisos/en_windows_7_enterprise_with_sp1_x64_dvd_u_677651.iso'), # >=8GiB
465 UnattendedVm(oSet, 'tst-w8-32', 'Windows8', '6.0/uaisos/en_windows_8_enterprise_x86_dvd_917587.iso'), # >=6GiB
466 UnattendedVm(oSet, 'tst-w8-64', 'Windows8_64', '6.0/uaisos/en_windows_8_enterprise_x64_dvd_917522.iso'), # >=9GiB
467 UnattendedVm(oSet, 'tst-w81-32', 'Windows81', '6.0/uaisos/en_windows_8_1_enterprise_x86_dvd_2791510.iso'), # >=5GiB
468 UnattendedVm(oSet, 'tst-w81-64', 'Windows81_64', '6.0/uaisos/en_windows_8_1_enterprise_x64_dvd_2791088.iso'), # >=8GiB
469 UnattendedVm(oSet, 'tst-w10-1507-32', 'Windows10', '6.0/uaisos/en_windows_10_pro_10240_x86_dvd.iso'), # >=6GiB
470 UnattendedVm(oSet, 'tst-w10-1507-64', 'Windows10_64', '6.0/uaisos/en_windows_10_pro_10240_x64_dvd.iso'), # >=9GiB
471 UnattendedVm(oSet, 'tst-w10-1511-32', 'Windows10', '6.0/uaisos/en_windows_10_enterprise_version_1511_updated_feb_2016_x86_dvd_8378870.iso'), # >=7GiB
472 UnattendedVm(oSet, 'tst-w10-1511-64', 'Windows10_64', '6.0/uaisos/en_windows_10_enterprise_version_1511_x64_dvd_7224901.iso'), # >=9GiB
473 UnattendedVm(oSet, 'tst-w10-1607-32', 'Windows10', '6.0/uaisos/en_windows_10_enterprise_version_1607_updated_jul_2016_x86_dvd_9060097.iso'), # >=7GiB
474 UnattendedVm(oSet, 'tst-w10-1607-64', 'Windows10_64', '6.0/uaisos/en_windows_10_enterprise_version_1607_updated_jul_2016_x64_dvd_9054264.iso'), # >=9GiB
475 UnattendedVm(oSet, 'tst-w10-1703-32', 'Windows10', '6.0/uaisos/en_windows_10_enterprise_version_1703_updated_march_2017_x86_dvd_10188981.iso'), # >=7GiB
476 UnattendedVm(oSet, 'tst-w10-1703-64', 'Windows10_64', '6.0/uaisos/en_windows_10_enterprise_version_1703_updated_march_2017_x64_dvd_10189290.iso'), # >=10GiB
477 UnattendedVm(oSet, 'tst-w10-1709-32', 'Windows10', '6.0/uaisos/en_windows_10_multi-edition_vl_version_1709_updated_sept_2017_x86_dvd_100090759.iso'), # >=7GiB
478 UnattendedVm(oSet, 'tst-w10-1709-64', 'Windows10_64', '6.0/uaisos/en_windows_10_multi-edition_vl_version_1709_updated_sept_2017_x64_dvd_100090741.iso'), # >=10GiB
479 UnattendedVm(oSet, 'tst-w10-1803-32', 'Windows10', '6.0/uaisos/en_windows_10_business_editions_version_1803_updated_march_2018_x86_dvd_12063341.iso'), # >=7GiB
480 UnattendedVm(oSet, 'tst-w10-1803-64', 'Windows10_64', '6.0/uaisos/en_windows_10_business_editions_version_1803_updated_march_2018_x64_dvd_12063333.iso'), # >=10GiB
481 UnattendedVm(oSet, 'tst-w10-1809-32', 'Windows10', '6.0/uaisos/en_windows_10_business_edition_version_1809_updated_sept_2018_x86_dvd_2f92403b.iso'), # >=7GiB
482 UnattendedVm(oSet, 'tst-w10-1809-64', 'Windows10_64', '6.0/uaisos/en_windows_10_business_edition_version_1809_updated_sept_2018_x64_dvd_f0b7dc68.iso'), # >=10GiB
483 UnattendedVm(oSet, 'tst-w10-1903-32', 'Windows10', '6.0/uaisos/en_windows_10_business_editions_version_1903_x86_dvd_ca4f0f49.iso'), # >=7GiB
484 UnattendedVm(oSet, 'tst-w10-1903-64', 'Windows10_64', '6.0/uaisos/en_windows_10_business_editions_version_1903_x64_dvd_37200948.iso'), # >=10GiB
485 #
486 # Ubuntu
487 #
488 ## @todo 15.10 fails with grub install error.
489 #UnattendedVm(oSet, 'tst-ubuntu-15.10-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-15.10-desktop-amd64.iso'),
490 UnattendedVm(oSet, 'tst-ubuntu-16.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.04-desktop-amd64.iso', # ~5GiB
491 UnattendedVm.kfUbuntuAvx2Crash),
492 UnattendedVm(oSet, 'tst-ubuntu-16.04-32', 'Ubuntu', '6.0/uaisos/ubuntu-16.04-desktop-i386.iso'), # >=4.5GiB
493 UnattendedVm(oSet, 'tst-ubuntu-16.04.1-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.04.1-desktop-amd64.iso'), # >=5GiB
494 UnattendedVm(oSet, 'tst-ubuntu-16.04.1-32', 'Ubuntu', '6.0/uaisos/ubuntu-16.04.1-desktop-i386.iso'), # >=4.5GiB
495 UnattendedVm(oSet, 'tst-ubuntu-16.04.2-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.04.2-desktop-amd64.iso'), # >=5GiB
496 UnattendedVm(oSet, 'tst-ubuntu-16.04.2-32', 'Ubuntu', '6.0/uaisos/ubuntu-16.04.2-desktop-i386.iso'), # >=4.5GiB
497 UnattendedVm(oSet, 'tst-ubuntu-16.04.3-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.04.3-desktop-amd64.iso'), # >=5GiB
498 UnattendedVm(oSet, 'tst-ubuntu-16.04.3-32', 'Ubuntu', '6.0/uaisos/ubuntu-16.04.3-desktop-i386.iso'), # >=4.5GiB
499 UnattendedVm(oSet, 'tst-ubuntu-16.04.4-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.04.4-desktop-amd64.iso'), # >=5GiB
500 UnattendedVm(oSet, 'tst-ubuntu-16.04.4-32', 'Ubuntu', '6.0/uaisos/ubuntu-16.04.4-desktop-i386.iso'), # >=4.5GiB
501 UnattendedVm(oSet, 'tst-ubuntu-16.04.5-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.04.5-desktop-amd64.iso'), # >=5GiB
502 UnattendedVm(oSet, 'tst-ubuntu-16.04.5-32', 'Ubuntu', '6.0/uaisos/ubuntu-16.04.5-desktop-i386.iso'), # >=4.5GiB
503 UnattendedVm(oSet, 'tst-ubuntu-16.04.6-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.04.6-desktop-amd64.iso'), # >=5GiB
504 UnattendedVm(oSet, 'tst-ubuntu-16.04.6-32', 'Ubuntu', '6.0/uaisos/ubuntu-16.04.6-desktop-i386.iso'), # >=4.5GiB
505 UnattendedVm(oSet, 'tst-ubuntu-16.10-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-16.10-desktop-amd64.iso'), # >=5.5GiB
506 ## @todo 16.10-32 doesn't ask for an IP, so it always fails.
507 #UnattendedVm(oSet, 'tst-ubuntu-16.10-32', 'Ubuntu', '6.0/uaisos/ubuntu-16.10-desktop-i386.iso'), # >=5.5GiB?
508 UnattendedVm(oSet, 'tst-ubuntu-17.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-17.04-desktop-amd64.iso'), # >=5GiB
509 UnattendedVm(oSet, 'tst-ubuntu-17.04-32', 'Ubuntu', '6.0/uaisos/ubuntu-17.04-desktop-i386.iso'), # >=4.5GiB
510 ## @todo ubuntu 17.10, 18.04 & 18.10 do not work. They misses all the the build tools (make, gcc, perl, ++)
511 ## and has signed kmods:
512 UnattendedVm(oSet, 'tst-ubuntu-17.10-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-17.10-desktop-amd64.iso', # >=4Gib
513 UnattendedVm.kfNoGAs),
514 UnattendedVm(oSet, 'tst-ubuntu-18.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-18.04-desktop-amd64.iso', # >=6GiB
515 UnattendedVm.kfNoGAs),
516 # 18.10 hangs reading install DVD during "starting partitioner..."
517 #UnattendedVm(oSet, 'tst-ubuntu-18.10-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-18.10-desktop-amd64.iso',
518 # UnattendedVm.kfNoGAs),
519 UnattendedVm(oSet, 'tst-ubuntu-19.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-19.04-desktop-amd64.iso', # >=6GiB
520 UnattendedVm.kfNoGAs),
521 ]);
522 # pylint: enable=line-too-long
523 self.oTestVmSet = oSet;
524
525 # For option parsing:
526 self.aoSelectedVms = oSet.aoTestVms # type: list(UnattendedVm)
527
528 # Number of VMs to test in parallel:
529 self.cInParallel = 1;
530
531 # Whether to do the save-and-restore test.
532 self.fTestSaveAndRestore = True;
533
534 #
535 # Sub-test drivers.
536 #
537 self.addSubTestDriver(SubTstDrvAddSharedFolders1(self));
538 self.addSubTestDriver(SubTstDrvAddGuestCtrl(self));
539
540
541 #
542 # Overridden methods.
543 #
544
545 def showUsage(self):
546 """
547 Extend usage info
548 """
549 rc = vbox.TestDriver.showUsage(self)
550 reporter.log('');
551 reporter.log('tdGuestOsUnattendedInst1 options:');
552 reporter.log(' --parallel <num>');
553 reporter.log(' Number of VMs to test in parallel.');
554 reporter.log(' Default: 1');
555 reporter.log('');
556 reporter.log(' Options for working on selected test VMs:');
557 reporter.log(' --select <vm1[:vm2[:..]]>');
558 reporter.log(' Selects a test VM for the following configuration alterations.');
559 reporter.log(' Default: All possible test VMs');
560 reporter.log(' --copy <old-vm>=<new-vm>');
561 reporter.log(' Creates and selects <new-vm> as a copy of <old-vm>.');
562 reporter.log(' --guest-type <guest-os-type>');
563 reporter.log(' Sets the guest-os type of the currently selected test VM.');
564 reporter.log(' --install-iso <ISO file name>');
565 reporter.log(' Sets ISO image to use for the selected test VM.');
566 reporter.log(' --ram-adjust <MBs>');
567 reporter.log(' Adjust the VM ram size by the given delta. Both negative and positive');
568 reporter.log(' values are accepted.');
569 reporter.log(' --max-cpus <# CPUs>');
570 reporter.log(' Sets the maximum number of guest CPUs for the selected VM.');
571 reporter.log(' --set-extradata <key>:value');
572 reporter.log(' Set VM extra data for the selected VM. Can be repeated.');
573 reporter.log(' --ioapic, --no-ioapic');
574 reporter.log(' Enable or disable the I/O apic for the selected VM.');
575 reporter.log(' --pae, --no-pae');
576 reporter.log(' Enable or disable PAE support (32-bit guests only) for the selected VM.');
577 return rc
578
579 def parseOption(self, asArgs, iArg):
580 """
581 Extend standard options set
582 """
583
584 if asArgs[iArg] == '--parallel':
585 iArg = self.requireMoreArgs(1, asArgs, iArg);
586 self.cInParallel = int(asArgs[iArg]);
587 if self.cInParallel <= 0:
588 self.cInParallel = 1;
589 elif asArgs[iArg] == '--select':
590 iArg = self.requireMoreArgs(1, asArgs, iArg);
591 self.aoSelectedVms = [];
592 for sTestVm in asArgs[iArg].split(':'):
593 oTestVm = self.oTestVmSet.findTestVmByName(sTestVm);
594 if not oTestVm:
595 raise base.InvalidOption('Unknown test VM: %s' % (sTestVm,));
596 self.aoSelectedVms.append(oTestVm);
597 elif asArgs[iArg] == '--copy':
598 iArg = self.requireMoreArgs(1, asArgs, iArg);
599 asNames = asArgs[iArg].split('=');
600 if len(asNames) != 2 or not asNames[0] or not asNames[1]:
601 raise base.InvalidOption('The --copy option expects value on the form "old=new": %s' % (asArgs[iArg],));
602 oOldTestVm = self.oTestVmSet.findTestVmByName(asNames[0]);
603 if not oOldTestVm:
604 raise base.InvalidOption('Unknown test VM: %s' % (asNames[0],));
605 oNewTestVm = copy.deepcopy(oOldTestVm);
606 oNewTestVm.sVmName = asNames[1];
607 self.oTestVmSet.aoTestVms.append(oNewTestVm);
608 self.aoSelectedVms = [oNewTestVm];
609 elif asArgs[iArg] == '--guest-type':
610 iArg = self.requireMoreArgs(1, asArgs, iArg);
611 for oTestVm in self.aoSelectedVms:
612 oTestVm.sKind = asArgs[iArg];
613 elif asArgs[iArg] == '--install-iso':
614 iArg = self.requireMoreArgs(1, asArgs, iArg);
615 for oTestVm in self.aoSelectedVms:
616 oTestVm.sInstallIso = asArgs[iArg];
617 elif asArgs[iArg] == '--ram-adjust':
618 iArg = self.requireMoreArgs(1, asArgs, iArg);
619 for oTestVm in self.aoSelectedVms:
620 oTestVm.iOptRamAdjust = int(asArgs[iArg]);
621 elif asArgs[iArg] == '--max-cpus':
622 iArg = self.requireMoreArgs(1, asArgs, iArg);
623 for oTestVm in self.aoSelectedVms:
624 oTestVm.iOptMaxCpus = int(asArgs[iArg]);
625 elif asArgs[iArg] == '--set-extradata':
626 iArg = self.requireMoreArgs(1, asArgs, iArg)
627 sExtraData = asArgs[iArg];
628 try: _, _ = sExtraData.split(':');
629 except: raise base.InvalidOption('Invalid extradata specified: %s' % (sExtraData, ));
630 for oTestVm in self.aoSelectedVms:
631 oTestVm.asOptExtraData.append(sExtraData);
632 elif asArgs[iArg] == '--ioapic':
633 for oTestVm in self.aoSelectedVms:
634 oTestVm.fOptIoApic = True;
635 elif asArgs[iArg] == '--no-ioapic':
636 for oTestVm in self.aoSelectedVms:
637 oTestVm.fOptIoApic = False;
638 elif asArgs[iArg] == '--pae':
639 for oTestVm in self.aoSelectedVms:
640 oTestVm.fOptPae = True;
641 elif asArgs[iArg] == '--no-pae':
642 for oTestVm in self.aoSelectedVms:
643 oTestVm.fOptPae = False;
644 elif asArgs[iArg] == '--install-additions':
645 for oTestVm in self.aoSelectedVms:
646 oTestVm.fOptInstallAdditions = True;
647 elif asArgs[iArg] == '--no-install-additions':
648 for oTestVm in self.aoSelectedVms:
649 oTestVm.fOptInstallAdditions = False;
650 else:
651 return vbox.TestDriver.parseOption(self, asArgs, iArg);
652 return iArg + 1;
653
654 def actionConfig(self):
655 if not self.importVBoxApi(): # So we can use the constant below.
656 return False;
657 return self.oTestVmSet.actionConfig(self);
658
659 def actionExecute(self):
660 """
661 Execute the testcase.
662 """
663 return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
664
665 def testOneVmConfig(self, oVM, oTestVm): # type: (Any, UnattendedVm) -> bool
666 """
667 Install guest OS and wait for result
668 """
669
670 self.logVmInfo(oVM)
671 reporter.testStart('Installing %s%s' % (oTestVm.sVmName, ' with GAs' if oTestVm.fOptInstallAdditions else ''))
672
673 cMsTimeout = 40*60000;
674 if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
675 cMsTimeout = 180 * 60000; # will be adjusted down.
676
677 oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
678 #oSession = self.startVmByName(oTestVm.sVmName); # (for quickly testing waitForGAs)
679 if oSession is not None:
680 # The guest has connected to TXS.
681 reporter.log('Guest reported success via TXS.');
682 reporter.testDone();
683
684 fRc = True;
685 # Kudge: GAs doesn't come up correctly, so we have to reboot the guest first:
686 # Looks like VBoxService isn't there.
687 if oTestVm.fOptInstallAdditions:
688 reporter.testStart('Rebooting');
689 fRc, oTxsSession = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession);
690 reporter.testDone();
691
692 # If we're installing GAs, wait for them to come online:
693 if oTestVm.fOptInstallAdditions and fRc is True:
694 reporter.testStart('Guest additions');
695 aenmRunLevels = [vboxcon.AdditionsRunLevelType_Userland,];
696 if oTestVm.isLoggedOntoDesktop():
697 aenmRunLevels.append(vboxcon.AdditionsRunLevelType_Desktop);
698 fRc = self.waitForGAs(oSession, cMsTimeout = cMsTimeout / 2, aenmWaitForRunLevels = aenmRunLevels,
699 aenmWaitForActive = (vboxcon.AdditionsFacilityType_VBoxGuestDriver,
700 vboxcon.AdditionsFacilityType_VBoxService,));
701 reporter.testDone();
702
703 # Now do a save & restore test:
704 if fRc is True and self.fTestSaveAndRestore:
705 fRc, oSession, oTxsSession = self.testSaveAndRestore(oSession, oTxsSession, oTestVm);
706
707 # Test GAs if requested:
708 if oTestVm.fOptInstallAdditions and fRc is True:
709 for oSubTstDrv in self.aoSubTstDrvs:
710 if oSubTstDrv.fEnabled:
711 reporter.testStart(oSubTstDrv.sTestName);
712 fRc2, oTxsSession = oSubTstDrv.testIt(oTestVm, oSession, oTxsSession);
713 reporter.testDone(fRc2 is None);
714 if fRc2 is False:
715 fRc = False;
716
717 if oSession is not None:
718 fRc = self.terminateVmBySession(oSession) and fRc;
719 return fRc is True
720
721 reporter.error('Installation of %s has failed' % (oTestVm.sVmName,))
722 #oTestVm.detatchAndDeleteHd(self); # Save space.
723 reporter.testDone()
724 return False
725
726 def testSaveAndRestore(self, oSession, oTxsSession, oTestVm):
727 """
728 Tests saving and restoring the VM.
729 """
730 _ = oTestVm;
731 reporter.testStart('Save');
732 ## @todo
733 reporter.testDone();
734 reporter.testStart('Restore');
735 ## @todo
736 reporter.testDone();
737 return (True, oSession, oTxsSession);
738
739if __name__ == '__main__':
740 sys.exit(tdGuestOsInstTest1().main(sys.argv))
741
Note: See TracBrowser for help on using the repository browser.

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