VirtualBox

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

Last change on this file since 54596 was 54596, checked in by vboxsync, 10 years ago

tdGuestOsInstTest1.py: don't try to install Fedora 7 on the new piledriver hosts

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