VirtualBox

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

Last change on this file since 66399 was 66399, checked in by vboxsync, 8 years ago

Validation Kit: comment

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 21.2 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdGuestOsInstTest1.py 66399 2017-04-03 12:50:18Z vboxsync $
4
5"""
6VirtualBox Validation Kit - Guest OS installation tests.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2016 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: 66399 $"
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, oSet, sVmName, 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 # Enable audio adapter
183 oSession.o.machine.audioAdapter.enabled = True;
184
185 # Other variations?
186
187 # Save the settings.
188 fRc = fRc and oSession.saveSettings()
189 fRc = oSession.close() and fRc;
190 else:
191 fRc = False;
192 if fRc is not True:
193 oVM = None;
194
195 # Done.
196 return (fRc, oVM)
197
198 def isHostCpuAffectedByUbuntuNewAmdBug(self, oTestDrv):
199 """
200 Checks if the host OS is affected by older ubuntu installers being very
201 picky about which families of AMD CPUs it would run on.
202
203 The installer checks for family 15, later 16, later 20, and in 11.10
204 they remove the family check for AMD CPUs.
205 """
206 if not oTestDrv.isHostCpuAmd():
207 return False;
208 try:
209 (uMaxExt, _, _, _) = oTestDrv.oVBox.host.getProcessorCPUIDLeaf(0, 0x80000000, 0);
210 (uFamilyModel, _, _, _) = oTestDrv.oVBox.host.getProcessorCPUIDLeaf(0, 0x80000001, 0);
211 except:
212 reporter.logXcpt();
213 return False;
214 if uMaxExt < 0x80000001 or uMaxExt > 0x8000ffff:
215 return False;
216
217 uFamily = (uFamilyModel >> 8) & 0xf
218 if uFamily == 0xf:
219 uFamily = ((uFamilyModel >> 20) & 0x7f) + 0xf;
220 ## @todo Break this down into which old ubuntu release supports exactly
221 ## which AMD family, if we care.
222 if uFamily <= 15:
223 return False;
224 reporter.log('Skipping "%s" because host CPU is a family %u AMD, which may cause trouble for the guest OS installer.'
225 % (self.sVmName, uFamily,));
226 return True;
227
228
229
230
231
232class tdGuestOsInstTest1(vbox.TestDriver):
233 """
234 Guest OS installation tests.
235
236 Scenario:
237 - Create new VM that corresponds specified installation ISO image.
238 - Create HDD that corresponds to OS type that will be installed.
239 - Boot VM from ISO image (i.e. install guest OS).
240 - Wait for incomming TCP connection (guest should initiate such a
241 connection in case installation has been completed successfully).
242 """
243
244
245 def __init__(self):
246 """
247 Reinitialize child class instance.
248 """
249 vbox.TestDriver.__init__(self)
250 self.fLegacyOptions = False;
251 assert self.fEnableVrdp; # in parent driver.
252
253 #
254 # Our install test VM set.
255 #
256 oSet = vboxtestvms.TestVmSet(self.oTestVmManager, fIgnoreSkippedVm = True);
257 oSet.aoTestVms.extend([
258 # pylint: disable=C0301
259 InstallTestVm(oSet, 'tst-fedora4', 'Fedora', 'fedora4-txs.iso', InstallTestVm.ksIdeController, 8, InstallTestVm.kf32Bit),
260 InstallTestVm(oSet, 'tst-fedora5', 'Fedora', 'fedora5-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae | InstallTestVm.kfReqIoApicSmp),
261 InstallTestVm(oSet, 'tst-fedora6', 'Fedora', 'fedora6-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqIoApic),
262 InstallTestVm(oSet, 'tst-fedora7', 'Fedora', 'fedora7-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfUbuntuNewAmdBug | InstallTestVm.kfReqIoApic),
263 InstallTestVm(oSet, 'tst-fedora9', 'Fedora', 'fedora9-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit),
264 InstallTestVm(oSet, 'tst-fedora18-64', 'Fedora_64', 'fedora18-x64-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf64Bit),
265 InstallTestVm(oSet, 'tst-fedora18', 'Fedora', 'fedora18-txs.iso', InstallTestVm.ksScsiController, 8, InstallTestVm.kf32Bit),
266 InstallTestVm(oSet, 'tst-ols6', 'Oracle', 'ols6-i386-txs.iso', InstallTestVm.ksSataController, 12, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae),
267 InstallTestVm(oSet, 'tst-ols6-64', 'Oracle_64', 'ols6-x86_64-txs.iso', InstallTestVm.ksSataController, 12, InstallTestVm.kf64Bit),
268 InstallTestVm(oSet, 'tst-rhel5', 'RedHat', 'rhel5-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae | InstallTestVm.kfReqIoApic),
269 InstallTestVm(oSet, 'tst-suse102', 'OpenSUSE', 'opensuse102-txs.iso', InstallTestVm.ksIdeController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqIoApic),
270 ## @todo InstallTestVm(oSet, 'tst-ubuntu606', 'Ubuntu', 'ubuntu606-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit),
271 ## @todo InstallTestVm(oSet, 'tst-ubuntu710', 'Ubuntu', 'ubuntu710-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit),
272 InstallTestVm(oSet, 'tst-ubuntu804', 'Ubuntu', 'ubuntu804-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfUbuntuNewAmdBug | InstallTestVm.kfReqPae | InstallTestVm.kfReqIoApic),
273 InstallTestVm(oSet, 'tst-ubuntu804-64', 'Ubuntu_64', 'ubuntu804-amd64-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf64Bit),
274 InstallTestVm(oSet, 'tst-ubuntu904', 'Ubuntu', 'ubuntu904-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfUbuntuNewAmdBug | InstallTestVm.kfReqPae),
275 InstallTestVm(oSet, 'tst-ubuntu904-64', 'Ubuntu_64', 'ubuntu904-amd64-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf64Bit),
276 #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'?
277 InstallTestVm(oSet, 'tst-ubuntu1404', 'Ubuntu', 'ubuntu1404-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae),
278 InstallTestVm(oSet, 'tst-ubuntu1404-64','Ubuntu_64', 'ubuntu1404-amd64-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf64Bit),
279 InstallTestVm(oSet, 'tst-debian7', 'Debian', 'debian-7.0.0-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit),
280 InstallTestVm(oSet, 'tst-debian7-64', 'Debian_64', 'debian-7.0.0-x64-txs.iso', InstallTestVm.ksScsiController, 8, InstallTestVm.kf64Bit),
281 InstallTestVm(oSet, 'tst-vista-64', 'WindowsVista_64', 'vista-x64-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf64Bit),
282 InstallTestVm(oSet, 'tst-vista-32', 'WindowsVista', 'vista-x86-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf32Bit),
283 InstallTestVm(oSet, 'tst-w7-64', 'Windows7_64', 'win7-x64-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf64Bit),
284 InstallTestVm(oSet, 'tst-w7-32', 'Windows7', 'win7-x86-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf32Bit),
285 InstallTestVm(oSet, 'tst-w2k3', 'Windows2003', 'win2k3ent-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit),
286 InstallTestVm(oSet, 'tst-w2k', 'Windows2000', 'win2ksp0-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit | InstallTestVm.kfIdeIrqDelay),
287 InstallTestVm(oSet, 'tst-w2ksp4', 'Windows2000', 'win2ksp4-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit | InstallTestVm.kfIdeIrqDelay),
288 InstallTestVm(oSet, 'tst-wxp', 'WindowsXP', 'winxppro-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit),
289 InstallTestVm(oSet, 'tst-wxpsp2', 'WindowsXP', 'winxpsp2-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit),
290 InstallTestVm(oSet, 'tst-wxp64', 'WindowsXP_64', 'winxp64-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf64Bit),
291 ## @todo disable paravirt for Windows 8.1 guests as long as it's not fixed in the code
292 InstallTestVm(oSet, 'tst-w81-32', 'Windows81', 'win81-x86-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf32Bit),
293 InstallTestVm(oSet, 'tst-w81-64', 'Windows81_64', 'win81-x64-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf64Bit),
294 InstallTestVm(oSet, 'tst-w10-32', 'Windows10', 'win10-x86-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf32Bit | InstallTestVm.kfReqPae),
295 InstallTestVm(oSet, 'tst-w10-64', 'Windows10_64', 'win10-x64-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf64Bit),
296 # pylint: enable=C0301
297 ]);
298 self.oTestVmSet = oSet;
299
300
301
302 #
303 # Overridden methods.
304 #
305
306 def showUsage(self):
307 """
308 Extend usage info
309 """
310 rc = vbox.TestDriver.showUsage(self)
311 reporter.log('');
312 reporter.log('tdGuestOsInstTest1 options:');
313 reporter.log(' --ioapic, --no-ioapic');
314 reporter.log(' Enable or disable the I/O apic.');
315 reporter.log(' Default: --ioapic');
316 reporter.log(' --pae, --no-pae');
317 reporter.log(' Enable or disable PAE support for 32-bit guests.');
318 reporter.log(' Default: Guest dependent.');
319 reporter.log(' --ram-adjust <MBs>')
320 reporter.log(' Adjust the VM ram size by the given delta. Both negative and positive');
321 reporter.log(' values are accepted.');
322 reporter.log(' --set-extradata <key>:value')
323 reporter.log(' Set VM extra data. This command line option might be used multiple times.')
324 reporter.log('obsolete:');
325 reporter.log(' --nested-paging, --no-nested-paging');
326 reporter.log(' --raw-mode');
327 reporter.log(' --cpus <# CPUs>');
328 reporter.log(' --install-iso <ISO file name>');
329
330 return rc
331
332 def parseOption(self, asArgs, iArg):
333 """
334 Extend standard options set
335 """
336
337 if False is True:
338 pass;
339 elif asArgs[iArg] == '--ioapic':
340 for oTestVm in self.oTestVmSet.aoTestVms:
341 oTestVm.fIoApic = True;
342 elif asArgs[iArg] == '--no-ioapic':
343 for oTestVm in self.oTestVmSet.aoTestVms:
344 oTestVm.fIoApic = False;
345 elif asArgs[iArg] == '--pae':
346 for oTestVm in self.oTestVmSet.aoTestVms:
347 oTestVm.fPae = True;
348 elif asArgs[iArg] == '--no-pae':
349 for oTestVm in self.oTestVmSet.aoTestVms:
350 oTestVm.fPae = False;
351 elif asArgs[iArg] == '--ram-adjust':
352 iArg = self.requireMoreArgs(1, asArgs, iArg);
353 for oTestVm in self.oTestVmSet.aoTestVms:
354 oTestVm.iOptRamAdjust = int(asArgs[iArg]);
355 elif asArgs[iArg] == '--set-extradata':
356 iArg = self.requireMoreArgs(1, asArgs, iArg)
357 for oTestVm in self.oTestVmSet.aoTestVms:
358 oTestVm.asExtraData.append(asArgs[iArg]);
359
360 # legacy, to be removed once TM is reconfigured.
361 elif asArgs[iArg] == '--install-iso':
362 self.legacyOptions();
363 iArg = self.requireMoreArgs(1, asArgs, iArg);
364 for oTestVm in self.oTestVmSet.aoTestVms:
365 oTestVm.fSkip = os.path.basename(oTestVm.sDvdImage) != asArgs[iArg];
366 elif asArgs[iArg] == '--cpus':
367 self.legacyOptions();
368 iArg = self.requireMoreArgs(1, asArgs, iArg);
369 self.oTestVmSet.acCpus = [ int(asArgs[iArg]), ];
370 elif asArgs[iArg] == '--raw-mode':
371 self.legacyOptions();
372 self.oTestVmSet.asVirtModes = [ 'raw', ];
373 elif asArgs[iArg] == '--nested-paging':
374 self.legacyOptions();
375 self.oTestVmSet.asVirtModes = [ 'hwvirt-np', ];
376 elif asArgs[iArg] == '--no-nested-paging':
377 self.legacyOptions();
378 self.oTestVmSet.asVirtModes = [ 'hwvirt', ];
379 else:
380 return vbox.TestDriver.parseOption(self, asArgs, iArg)
381
382 return iArg + 1
383
384 def legacyOptions(self):
385 """ Enables legacy option mode. """
386 if not self.fLegacyOptions:
387 self.fLegacyOptions = True;
388 self.oTestVmSet.asVirtModes = [ 'hwvirt', ];
389 self.oTestVmSet.acCpus = [ 1, ];
390 return True;
391
392 def actionConfig(self):
393 if not self.importVBoxApi(): # So we can use the constant below.
394 return False;
395 return self.oTestVmSet.actionConfig(self, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT);
396
397 def actionExecute(self):
398 """
399 Execute the testcase.
400 """
401 return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
402
403 def testOneVmConfig(self, oVM, oTestVm):
404 """
405 Install guest OS and wait for result
406 """
407
408 self.logVmInfo(oVM)
409 reporter.testStart('Installing %s' % (oTestVm.sVmName,))
410
411 cMsTimeout = 40*60000;
412 if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
413 cMsTimeout = 180 * 60000; # will be adjusted down.
414
415 oSession, _ = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
416 if oSession is not None:
417 # The guest has connected to TXS, so we're done (for now anyways).
418 reporter.log('Guest reported success')
419 ## @todo Do save + restore.
420
421 reporter.testDone()
422 fRc = self.terminateVmBySession(oSession)
423 return fRc is True
424
425 reporter.error('Installation of %s has failed' % (oTestVm.sVmName,))
426 oTestVm.detatchAndDeleteHd(self); # Save space.
427 reporter.testDone()
428 return False
429
430if __name__ == '__main__':
431 sys.exit(tdGuestOsInstTest1().main(sys.argv))
432
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