VirtualBox

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

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

Added Ubuntu 14.04 32/64bit installations.

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