VirtualBox

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

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

fix OSE

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 18.7 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdGuestOsInstTest1.py 52776 2014-09-17 14:51:43Z 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: 52776 $"
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-debian7', 'Debian', 'debian-7.0.0-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf32Bit),
265 InstallTestVm(oSet, 'tst-debian7-64', 'Debian_64', 'debian-7.0.0-x64-txs.iso', InstallTestVm.ksSataController, 8, InstallTestVm.kf64Bit),
266 InstallTestVm(oSet, 'tst-w7-64', 'Windows7_64', 'win7-x64-txs.iso', InstallTestVm.ksSataController, 25, InstallTestVm.kf64Bit),
267 InstallTestVm(oSet, 'tst-w2k3', 'Windows2003', 'win2k3ent-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit),
268 InstallTestVm(oSet, 'tst-w2k', 'Windows2000', 'win2ksp0-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit | InstallTestVm.kfIdeIrqDelay),
269 InstallTestVm(oSet, 'tst-w2ksp4', 'Windows2000', 'win2ksp4-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit | InstallTestVm.kfIdeIrqDelay),
270 InstallTestVm(oSet, 'tst-wxp', 'WindowsXP', 'winxppro-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit),
271 InstallTestVm(oSet, 'tst-wxpsp2', 'WindowsXP', 'winxpsp2-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf32Bit),
272 InstallTestVm(oSet, 'tst-wxp64', 'WindowsXP_64', 'winxp64-txs.iso', InstallTestVm.ksIdeController, 25, InstallTestVm.kf64Bit),
273 # pylint: enable=C0301
274 ]);
275 self.oTestVmSet = oSet;
276
277
278
279 #
280 # Overridden methods.
281 #
282
283 def showUsage(self):
284 """
285 Extend usage info
286 """
287 rc = vbox.TestDriver.showUsage(self)
288 reporter.log('');
289 reporter.log('tdGuestOsInstTest1 options:');
290 reporter.log(' --ioapic, --no-ioapic');
291 reporter.log(' Enable or disable the I/O apic.');
292 reporter.log(' Default: --ioapic');
293 reporter.log(' --pae, --no-pae');
294 reporter.log(' Enable or disable PAE support for 32-bit guests.');
295 reporter.log(' Default: Guest dependent.');
296 reporter.log(' --ram-adjust <MBs>')
297 reporter.log(' Adjust the VM ram size by the given delta. Both negative and positive');
298 reporter.log(' values are accepted.');
299 reporter.log(' --set-extradata <key>:value')
300 reporter.log(' Set VM extra data. This command line option might be used multiple times.')
301 reporter.log('obsolete:');
302 reporter.log(' --nested-paging, --no-nested-paging');
303 reporter.log(' --raw-mode');
304 reporter.log(' --cpus <# CPUs>');
305 reporter.log(' --install-iso <ISO file name>');
306
307 return rc
308
309 def parseOption(self, asArgs, iArg):
310 """
311 Extend standard options set
312 """
313
314 if False:
315 pass;
316 elif asArgs[iArg] == '--ioapic':
317 for oTestVm in self.oTestVmSet.aoTestVms:
318 oTestVm.fIoApic = True;
319 elif asArgs[iArg] == '--no-ioapic':
320 for oTestVm in self.oTestVmSet.aoTestVms:
321 oTestVm.fIoApic = False;
322 elif asArgs[iArg] == '--pae':
323 for oTestVm in self.oTestVmSet.aoTestVms:
324 oTestVm.fPae = True;
325 elif asArgs[iArg] == '--no-pae':
326 for oTestVm in self.oTestVmSet.aoTestVms:
327 oTestVm.fPae = False;
328 elif asArgs[iArg] == '--ram-adjust':
329 iArg = self.requireMoreArgs(1, asArgs, iArg);
330 for oTestVm in self.oTestVmSet.aoTestVms:
331 oTestVm.iOptRamAdjust = int(asArgs[iArg]);
332 elif asArgs[iArg] == '--set-extradata':
333 iArg = self.requireMoreArgs(1, asArgs, iArg)
334 for oTestVm in self.oTestVmSet.aoTestVms:
335 oTestVm.asExtraData.append(asArgs[iArg]);
336
337 # legacy, to be removed once TM is reconfigured.
338 elif asArgs[iArg] == '--install-iso':
339 self.legacyOptions();
340 iArg = self.requireMoreArgs(1, asArgs, iArg);
341 for oTestVm in self.oTestVmSet.aoTestVms:
342 oTestVm.fSkip = os.path.basename(oTestVm.sDvdImage) != asArgs[iArg];
343 elif asArgs[iArg] == '--cpus':
344 self.legacyOptions();
345 iArg = self.requireMoreArgs(1, asArgs, iArg);
346 self.oTestVmSet.acCpus = [ int(asArgs[iArg]), ];
347 elif asArgs[iArg] == '--raw-mode':
348 self.legacyOptions();
349 self.oTestVmSet.asVirtModes = [ 'raw', ];
350 elif asArgs[iArg] == '--nested-paging':
351 self.legacyOptions();
352 self.oTestVmSet.asVirtModes = [ 'hwvirt-np', ];
353 elif asArgs[iArg] == '--no-nested-paging':
354 self.legacyOptions();
355 self.oTestVmSet.asVirtModes = [ 'hwvirt', ];
356 else:
357 return vbox.TestDriver.parseOption(self, asArgs, iArg)
358
359 return iArg + 1
360
361 def legacyOptions(self):
362 """ Enables legacy option mode. """
363 if not self.fLegacyOptions:
364 self.fLegacyOptions = True;
365 self.oTestVmSet.asVirtModes = [ 'hwvirt', ];
366 self.oTestVmSet.acCpus = [ 1, ];
367 return True;
368
369 def actionConfig(self):
370 if not self.importVBoxApi(): # So we can use the constant below.
371 return False;
372 return self.oTestVmSet.actionConfig(self, eNic0AttachType = vboxcon.NetworkAttachmentType_NAT);
373
374 def actionExecute(self):
375 """
376 Execute the testcase.
377 """
378 return self.oTestVmSet.actionExecute(self, self.testOneVmConfig)
379
380 def testOneVmConfig(self, oVM, oTestVm):
381 """
382 Install guest OS and wait for result
383 """
384
385 self.logVmInfo(oVM)
386 reporter.testStart('Installing %s' % (oTestVm.sVmName,))
387
388 cMsTimeout = 40*60000;
389 if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
390 cMsTimeout = 180 * 60000; # will be adjusted down.
391
392 oSession, _ = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False, cMsTimeout = cMsTimeout);
393 if oSession is not None:
394 # The guest has connected to TXS, so we're done (for now anyways).
395 reporter.log('Guest reported success')
396 ## @todo Do save + restore.
397
398 reporter.testDone()
399 fRc = self.terminateVmBySession(oSession)
400 return fRc is True
401
402 reporter.error('Installation of %s has failed' % (oTestVm.sVmName,))
403 oTestVm.detatchAndDeleteHd(self); # Save space.
404 reporter.testDone()
405 return False
406
407if __name__ == '__main__':
408 sys.exit(tdGuestOsInstTest1().main(sys.argv))
409
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