VirtualBox

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

Last change on this file since 61464 was 59608, checked in by vboxsync, 9 years ago

Controller setup fix.

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

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