VirtualBox

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

最後變更 在這個檔案從65262是 65262,由 vboxsync 提交於 8 年 前

Added vista full installation.

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

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