VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/installation/tdGuestOsInstTest1.py@ 76583

Last change on this file since 76583 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 21.1 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdGuestOsInstTest1.py 76553 2019-01-01 01:45:53Z vboxsync $
4
5"""
6VirtualBox Validation Kit - Guest OS installation tests.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2019 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: 76553 $"
31
32
33# Standard Python imports.
34import os
35import sys
36
37
38# Only the main script needs to modify the path.
39try: __file__
40except: __file__ = sys.argv[0]
41g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
42sys.path.append(g_ksValidationKitDir)
43
44# Validation Kit imports.
45from testdriver import vbox;
46from testdriver import base;
47from testdriver import reporter;
48from testdriver import vboxcon;
49from testdriver import vboxtestvms;
50
51
52class InstallTestVm(vboxtestvms.TestVm):
53 """ Installation test VM. """
54
55 ## @name The primary controller, to which the disk will be attached.
56 ## @{
57 ksScsiController = 'SCSI Controller'
58 ksSataController = 'SATA Controller'
59 ksIdeController = 'IDE Controller'
60 ## @}
61
62 ## @name VM option flags (OR together).
63 ## @{
64 kf32Bit = 0x01;
65 kf64Bit = 0x02;
66 # most likely for ancient Linux kernels assuming that AMD processors have always an I/O-APIC
67 kfReqIoApic = 0x10;
68 kfReqIoApicSmp = 0x20;
69 kfReqPae = 0x40;
70 kfIdeIrqDelay = 0x80;
71 kfUbuntuNewAmdBug = 0x100;
72 kfNoWin81Paravirt = 0x200;
73 ## @}
74
75 ## IRQ delay extra data config for win2k VMs.
76 kasIdeIrqDelay = [ 'VBoxInternal/Devices/piix3ide/0/Config/IRQDelay:1', ];
77
78 ## Install ISO path relative to the testrsrc root.
79 ksIsoPathBase = os.path.join('4.2', 'isos');
80
81
82 def __init__(self, oSet, sVmName, sKind, sInstallIso, sHdCtrlNm, cGbHdd, fFlags):
83 vboxtestvms.TestVm.__init__(self, sVmName, oSet = oSet, sKind = sKind, sHddControllerType = sHdCtrlNm,
84 fRandomPvPMode = (fFlags & self.kfNoWin81Paravirt) == 0);
85 self.sDvdImage = os.path.join(self.ksIsoPathBase, sInstallIso);
86 self.cGbHdd = cGbHdd;
87 self.fInstVmFlags = fFlags;
88 if fFlags & self.kfReqPae:
89 self.fPae = True;
90 if fFlags & (self.kfReqIoApic | self.kfReqIoApicSmp):
91 self.fIoApic = True;
92
93 # Tweaks
94 self.iOptRamAdjust = 0;
95 self.asExtraData = [];
96 if fFlags & self.kfIdeIrqDelay:
97 self.asExtraData = self.kasIdeIrqDelay;
98
99 def detatchAndDeleteHd(self, oTestDrv):
100 """
101 Detaches and deletes the HD.
102 Returns success indicator, error info logged.
103 """
104 fRc = False;
105 oVM = oTestDrv.getVmByName(self.sVmName);
106 if oVM is not None:
107 oSession = oTestDrv.openSession(oVM);
108 if oSession is not None:
109 (fRc, oHd) = oSession.detachHd(self.sHddControllerType, iPort = 0, iDevice = 0);
110 if fRc is True and oHd is not None:
111 fRc = oSession.saveSettings();
112 fRc = fRc and oTestDrv.oVBox.deleteHdByMedium(oHd);
113 fRc = fRc and oSession.saveSettings(); # Necessary for media reg?
114 fRc = oSession.close() and fRc;
115 return fRc;
116
117 def getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode = None):
118 #
119 # Do the standard reconfig in the base class first, it'll figure out
120 # if we can run the VM as requested.
121 #
122 (fRc, oVM) = vboxtestvms.TestVm.getReconfiguredVm(self, oTestDrv, cCpus, sVirtMode, sParavirtMode);
123
124 #
125 # Make sure there is no HD from the previous run attached nor taking
126 # up storage on the host.
127 #
128 if fRc is True:
129 fRc = self.detatchAndDeleteHd(oTestDrv);
130
131 #
132 # Check for ubuntu installer vs. AMD host CPU.
133 #
134 if fRc is True and (self.fInstVmFlags & self.kfUbuntuNewAmdBug):
135 if self.isHostCpuAffectedByUbuntuNewAmdBug(oTestDrv):
136 return (None, None); # (skip)
137
138 #
139 # Make adjustments to the default config, and adding a fresh HD.
140 #
141 if fRc is True:
142 oSession = oTestDrv.openSession(oVM);
143 if oSession is not None:
144 if self.sHddControllerType == self.ksSataController:
145 fRc = fRc and oSession.setStorageControllerType(vboxcon.StorageControllerType_IntelAhci,
146 self.sHddControllerType);
147 fRc = fRc and oSession.setStorageControllerPortCount(self.sHddControllerType, 1);
148 elif self.sHddControllerType == self.ksScsiController:
149 fRc = fRc and oSession.setStorageControllerType(vboxcon.StorageControllerType_LsiLogic,
150 self.sHddControllerType);
151 try:
152 sHddPath = os.path.join(os.path.dirname(oVM.settingsFilePath),
153 '%s-%s-%s.vdi' % (self.sVmName, sVirtMode, cCpus,));
154 except:
155 reporter.errorXcpt();
156 sHddPath = None;
157 fRc = False;
158
159 fRc = fRc and oSession.createAndAttachHd(sHddPath,
160 cb = self.cGbHdd * 1024*1024*1024,
161 sController = self.sHddControllerType,
162 iPort = 0,
163 fImmutable = False);
164
165 # Set proper boot order
166 fRc = fRc and oSession.setBootOrder(1, vboxcon.DeviceType_HardDisk)
167 fRc = fRc and oSession.setBootOrder(2, vboxcon.DeviceType_DVD)
168
169 # Adjust memory if requested.
170 if self.iOptRamAdjust != 0:
171 fRc = fRc and oSession.setRamSize(oSession.o.machine.memorySize + self.iOptRamAdjust);
172
173 # Set extra data
174 for sExtraData in self.asExtraData:
175 try:
176 sKey, sValue = sExtraData.split(':')
177 except ValueError:
178 raise base.InvalidOption('Invalid extradata specified: %s' % sExtraData)
179 reporter.log('Set extradata: %s => %s' % (sKey, sValue))
180 fRc = fRc and oSession.setExtraData(sKey, sValue)
181
182 # Other variations?
183
184 # Save the settings.
185 fRc = fRc and oSession.saveSettings()
186 fRc = oSession.close() and fRc;
187 else:
188 fRc = False;
189 if fRc is not True:
190 oVM = None;
191
192 # Done.
193 return (fRc, oVM)
194
195 def isHostCpuAffectedByUbuntuNewAmdBug(self, oTestDrv):
196 """
197 Checks if the host OS is affected by older ubuntu installers being very
198 picky about which families of AMD CPUs it would run on.
199
200 The installer checks for family 15, later 16, later 20, and in 11.10
201 they remove the family check for AMD CPUs.
202 """
203 if not oTestDrv.isHostCpuAmd():
204 return False;
205 try:
206 (uMaxExt, _, _, _) = oTestDrv.oVBox.host.getProcessorCPUIDLeaf(0, 0x80000000, 0);
207 (uFamilyModel, _, _, _) = oTestDrv.oVBox.host.getProcessorCPUIDLeaf(0, 0x80000001, 0);
208 except:
209 reporter.logXcpt();
210 return False;
211 if uMaxExt < 0x80000001 or uMaxExt > 0x8000ffff:
212 return False;
213
214 uFamily = (uFamilyModel >> 8) & 0xf
215 if uFamily == 0xf:
216 uFamily = ((uFamilyModel >> 20) & 0x7f) + 0xf;
217 ## @todo Break this down into which old ubuntu release supports exactly
218 ## which AMD family, if we care.
219 if uFamily <= 15:
220 return False;
221 reporter.log('Skipping "%s" because host CPU is a family %u AMD, which may cause trouble for the guest OS installer.'
222 % (self.sVmName, uFamily,));
223 return True;
224
225
226
227
228
229class tdGuestOsInstTest1(vbox.TestDriver):
230 """
231 Guest OS installation tests.
232
233 Scenario:
234 - Create new VM that corresponds specified installation ISO image.
235 - Create HDD that corresponds to OS type that will be installed.
236 - Boot VM from ISO image (i.e. install guest OS).
237 - Wait for incomming TCP connection (guest should initiate such a
238 connection in case installation has been completed successfully).
239 """
240
241
242 def __init__(self):
243 """
244 Reinitialize child class instance.
245 """
246 vbox.TestDriver.__init__(self)
247 self.fLegacyOptions = False;
248 assert self.fEnableVrdp; # in parent driver.
249
250 #
251 # Our install test VM set.
252 #
253 oSet = vboxtestvms.TestVmSet(self.oTestVmManager, fIgnoreSkippedVm = True);
254 oSet.aoTestVms.extend([
255 # pylint: disable=C0301
256 InstallTestVm(oSet, 'tst-fedora4', 'Fedora', 'fedora4-txs.iso', InstallTestVm.ksIdeController, 8, InstallTestVm.kf32Bit),
257 InstallTestVm(oSet, 'tst-fedora5', 'Fedora', 'fedora5-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae | InstallTestVm.kfReqIoApicSmp),
258 InstallTestVm(oSet, 'tst-fedora6', 'Fedora', 'fedora6-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqIoApic),
259 InstallTestVm(oSet, 'tst-fedora7', 'Fedora', 'fedora7-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfUbuntuNewAmdBug | InstallTestVm.kfReqIoApic),
260 InstallTestVm(oSet, 'tst-fedora9', 'Fedora', 'fedora9-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit),
261 InstallTestVm(oSet, 'tst-fedora18-64', 'Fedora_64', 'fedora18-x64-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf64Bit),
262 InstallTestVm(oSet, 'tst-fedora18', 'Fedora', 'fedora18-txs.iso', InstallTestVm.ksScsiController, 8, InstallTestVm.kf32Bit),
263 InstallTestVm(oSet, 'tst-ols6', 'Oracle', 'ols6-i386-txs.iso', InstallTestVm.ksSataController, 12, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae),
264 InstallTestVm(oSet, 'tst-ols6-64', 'Oracle_64', 'ols6-x86_64-txs.iso', InstallTestVm.ksSataController, 12, InstallTestVm.kf64Bit),
265 InstallTestVm(oSet, 'tst-rhel5', 'RedHat', 'rhel5-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae | InstallTestVm.kfReqIoApic),
266 InstallTestVm(oSet, 'tst-suse102', 'OpenSUSE', 'opensuse102-txs.iso', InstallTestVm.ksIdeController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqIoApic),
267 ## @todo InstallTestVm(oSet, 'tst-ubuntu606', 'Ubuntu', 'ubuntu606-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit),
268 ## @todo InstallTestVm(oSet, 'tst-ubuntu710', 'Ubuntu', 'ubuntu710-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit),
269 InstallTestVm(oSet, 'tst-ubuntu804', 'Ubuntu', 'ubuntu804-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfUbuntuNewAmdBug | InstallTestVm.kfReqPae | InstallTestVm.kfReqIoApic),
270 InstallTestVm(oSet, 'tst-ubuntu804-64', 'Ubuntu_64', 'ubuntu804-amd64-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf64Bit),
271 InstallTestVm(oSet, 'tst-ubuntu904', 'Ubuntu', 'ubuntu904-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfUbuntuNewAmdBug | InstallTestVm.kfReqPae),
272 InstallTestVm(oSet, 'tst-ubuntu904-64', 'Ubuntu_64', 'ubuntu904-amd64-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf64Bit),
273 #InstallTestVm(oSet, 'tst-ubuntu1404', 'Ubuntu', 'ubuntu1404-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfUbuntuNewAmdBug | InstallTestVm.kfReqPae), bird: Is 14.04 one of the 'older ones'?
274 InstallTestVm(oSet, 'tst-ubuntu1404', 'Ubuntu', 'ubuntu1404-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae),
275 InstallTestVm(oSet, 'tst-ubuntu1404-64','Ubuntu_64', 'ubuntu1404-amd64-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf64Bit),
276 InstallTestVm(oSet, 'tst-debian7', 'Debian', 'debian-7.0.0-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit),
277 InstallTestVm(oSet, 'tst-debian7-64', 'Debian_64', 'debian-7.0.0-x64-txs.iso', InstallTestVm.ksScsiController, 8, InstallTestVm.kf64Bit),
278 InstallTestVm(oSet, 'tst-vista-64', 'WindowsVista_64', 'vista-x64-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf64Bit),
279 InstallTestVm(oSet, 'tst-vista-32', 'WindowsVista', 'vista-x86-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf32Bit),
280 InstallTestVm(oSet, 'tst-w7-64', 'Windows7_64', 'win7-x64-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf64Bit),
281 InstallTestVm(oSet, 'tst-w7-32', 'Windows7', 'win7-x86-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf32Bit),
282 InstallTestVm(oSet, 'tst-w2k3', 'Windows2003', 'win2k3ent-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit),
283 InstallTestVm(oSet, 'tst-w2k', 'Windows2000', 'win2ksp0-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit | InstallTestVm.kfIdeIrqDelay),
284 InstallTestVm(oSet, 'tst-w2ksp4', 'Windows2000', 'win2ksp4-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit | InstallTestVm.kfIdeIrqDelay),
285 InstallTestVm(oSet, 'tst-wxp', 'WindowsXP', 'winxppro-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit),
286 InstallTestVm(oSet, 'tst-wxpsp2', 'WindowsXP', 'winxpsp2-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit),
287 InstallTestVm(oSet, 'tst-wxp64', 'WindowsXP_64', 'winxp64-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf64Bit),
288 ## @todo disable paravirt for Windows 8.1 guests as long as it's not fixed in the code
289 InstallTestVm(oSet, 'tst-w81-32', 'Windows81', 'win81-x86-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf32Bit),
290 InstallTestVm(oSet, 'tst-w81-64', 'Windows81_64', 'win81-x64-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf64Bit),
291 InstallTestVm(oSet, 'tst-w10-32', 'Windows10', 'win10-x86-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae),
292 InstallTestVm(oSet, 'tst-w10-64', 'Windows10_64', 'win10-x64-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf64Bit),
293 # pylint: enable=C0301
294 ]);
295 self.oTestVmSet = oSet;
296
297
298
299 #
300 # Overridden methods.
301 #
302
303 def showUsage(self):
304 """
305 Extend usage info
306 """
307 rc = vbox.TestDriver.showUsage(self)
308 reporter.log('');
309 reporter.log('tdGuestOsInstTest1 options:');
310 reporter.log(' --ioapic, --no-ioapic');
311 reporter.log(' Enable or disable the I/O apic.');
312 reporter.log(' Default: --ioapic');
313 reporter.log(' --pae, --no-pae');
314 reporter.log(' Enable or disable PAE support for 32-bit guests.');
315 reporter.log(' Default: Guest dependent.');
316 reporter.log(' --ram-adjust <MBs>')
317 reporter.log(' Adjust the VM ram size by the given delta. Both negative and positive');
318 reporter.log(' values are accepted.');
319 reporter.log(' --set-extradata <key>:value')
320 reporter.log(' Set VM extra data. This command line option might be used multiple times.')
321 reporter.log('obsolete:');
322 reporter.log(' --nested-paging, --no-nested-paging');
323 reporter.log(' --raw-mode');
324 reporter.log(' --cpus <# CPUs>');
325 reporter.log(' --install-iso <ISO file name>');
326
327 return rc
328
329 def parseOption(self, asArgs, iArg):
330 """
331 Extend standard options set
332 """
333
334 if False is True:
335 pass;
336 elif asArgs[iArg] == '--ioapic':
337 for oTestVm in self.oTestVmSet.aoTestVms:
338 oTestVm.fIoApic = True;
339 elif asArgs[iArg] == '--no-ioapic':
340 for oTestVm in self.oTestVmSet.aoTestVms:
341 oTestVm.fIoApic = False;
342 elif asArgs[iArg] == '--pae':
343 for oTestVm in self.oTestVmSet.aoTestVms:
344 oTestVm.fPae = True;
345 elif asArgs[iArg] == '--no-pae':
346 for oTestVm in self.oTestVmSet.aoTestVms:
347 oTestVm.fPae = False;
348 elif asArgs[iArg] == '--ram-adjust':
349 iArg = self.requireMoreArgs(1, asArgs, iArg);
350 for oTestVm in self.oTestVmSet.aoTestVms:
351 oTestVm.iOptRamAdjust = int(asArgs[iArg]);
352 elif asArgs[iArg] == '--set-extradata':
353 iArg = self.requireMoreArgs(1, asArgs, iArg)
354 for oTestVm in self.oTestVmSet.aoTestVms:
355 oTestVm.asExtraData.append(asArgs[iArg]);
356
357 # legacy, to be removed once TM is reconfigured.
358 elif asArgs[iArg] == '--install-iso':
359 self.legacyOptions();
360 iArg = self.requireMoreArgs(1, asArgs, iArg);
361 for oTestVm in self.oTestVmSet.aoTestVms:
362 oTestVm.fSkip = os.path.basename(oTestVm.sDvdImage) != asArgs[iArg];
363 elif asArgs[iArg] == '--cpus':
364 self.legacyOptions();
365 iArg = self.requireMoreArgs(1, asArgs, iArg);
366 self.oTestVmSet.acCpus = [ int(asArgs[iArg]), ];
367 elif asArgs[iArg] == '--raw-mode':
368 self.legacyOptions();
369 self.oTestVmSet.asVirtModes = [ 'raw', ];
370 elif asArgs[iArg] == '--nested-paging':
371 self.legacyOptions();
372 self.oTestVmSet.asVirtModes = [ 'hwvirt-np', ];
373 elif asArgs[iArg] == '--no-nested-paging':
374 self.legacyOptions();
375 self.oTestVmSet.asVirtModes = [ 'hwvirt', ];
376 else:
377 return vbox.TestDriver.parseOption(self, asArgs, iArg)
378
379 return iArg + 1
380
381 def legacyOptions(self):
382 """ Enables legacy option mode. """
383 if not self.fLegacyOptions:
384 self.fLegacyOptions = True;
385 self.oTestVmSet.asVirtModes = [ 'hwvirt', ];
386 self.oTestVmSet.acCpus = [ 1, ];
387 return True;
388
389 def actionConfig(self):
390 if not self.importVBoxApi(): # So we can use the constant below.
391 return False;
392 return self.oTestVmSet.actionConfig(self, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT);
393
394 def actionExecute(self):
395 """
396 Execute the testcase.
397 """
398 return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
399
400 def testOneVmConfig(self, oVM, oTestVm):
401 """
402 Install guest OS and wait for result
403 """
404
405 self.logVmInfo(oVM)
406 reporter.testStart('Installing %s' % (oTestVm.sVmName,))
407
408 cMsTimeout = 40*60000;
409 if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
410 cMsTimeout = 180 * 60000; # will be adjusted down.
411
412 oSession, _ = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
413 if oSession is not None:
414 # The guest has connected to TXS, so we're done (for now anyways).
415 reporter.log('Guest reported success')
416 ## @todo Do save + restore.
417
418 reporter.testDone()
419 fRc = self.terminateVmBySession(oSession)
420 return fRc is True
421
422 reporter.error('Installation of %s has failed' % (oTestVm.sVmName,))
423 oTestVm.detatchAndDeleteHd(self); # Save space.
424 reporter.testDone()
425 return False
426
427if __name__ == '__main__':
428 sys.exit(tdGuestOsInstTest1().main(sys.argv))
429
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