VirtualBox

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

Last change on this file since 98477 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

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