VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/installation/tdGuestOsInstOs2.py@ 82968

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 8.5 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdGuestOsInstOs2.py 82968 2020-02-04 10:35:17Z vboxsync $
4
5"""
6VirtualBox Validation Kit - OS/2 install tests.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2020 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: 82968 $"
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
49
50
51class tdGuestOsInstOs2(vbox.TestDriver):
52 """
53 OS/2 unattended installation.
54
55 Scenario:
56 - Create new VM that corresponds specified installation ISO image
57 - Create HDD that corresponds to OS type that will be installed
58 - Set VM boot order: HDD, Floppy, ISO
59 - Start VM: sinse there is no OS installed on HDD, VM will booted from floppy
60 - After first reboot VM will continue installation from HDD automatically
61 - Wait for incomming TCP connection (guest should initiate such a
62 connection in case installation has been completed successfully)
63 """
64
65 ksSataController = 'SATA Controller'
66 ksIdeController = 'IDE Controller'
67
68 # VM parameters required to run ISO image.
69 # Format: (cBytesHdd, sKind)
70 kaoVmParams = {
71 'acp2-txs.iso': ( 2*1024*1024*1024, 'OS2', ksIdeController ),
72 'mcp2-txs.iso': ( 2*1024*1024*1024, 'OS2', ksIdeController ),
73 }
74
75 def __init__(self):
76 """
77 Reinitialize child class instance.
78 """
79 vbox.TestDriver.__init__(self)
80
81 self.sVmName = 'TestVM'
82 self.sHddName = 'TestHdd.vdi'
83 self.sIso = None
84 self.sFloppy = None
85 self.sIsoPathBase = os.path.join(self.sResourcePath, '4.2', 'isos')
86 self.fEnableIOAPIC = True
87 self.cCpus = 1
88 self.fEnableNestedPaging = True
89 self.fEnablePAE = False
90 self.asExtraData = []
91
92 #
93 # Overridden methods.
94 #
95
96 def showUsage(self):
97 """
98 Extend usage info
99 """
100 rc = vbox.TestDriver.showUsage(self)
101 reporter.log(' --install-iso <ISO file name>')
102 reporter.log(' --cpus <# CPUs>')
103 reporter.log(' --no-ioapic')
104 reporter.log(' --no-nested-paging')
105 reporter.log(' --pae')
106 reporter.log(' --set-extradata <key>:value')
107 reporter.log(' Set VM extra data. This command line option might be used multiple times.')
108 return rc
109
110 def parseOption(self, asArgs, iArg):
111 """
112 Extend standard options set
113 """
114 if asArgs[iArg] == '--install-iso':
115 iArg += 1
116 if iArg >= len(asArgs): raise base.InvalidOption('The "--install-iso" option requires an argument')
117 self.sIso = asArgs[iArg]
118 elif asArgs[iArg] == '--cpus':
119 iArg += 1
120 if iArg >= len(asArgs): raise base.InvalidOption('The "--cpus" option requires an argument')
121 self.cCpus = int(asArgs[iArg])
122 elif asArgs[iArg] == '--no-ioapic':
123 self.fEnableIOAPIC = False
124 elif asArgs[iArg] == '--no-nested-paging':
125 self.fEnableNestedPaging = False
126 elif asArgs[iArg] == '--pae':
127 self.fEnablePAE = True
128 elif asArgs[iArg] == '--extra-mem':
129 self.fEnablePAE = True
130 elif asArgs[iArg] == '--set-extradata':
131 iArg = self.requireMoreArgs(1, asArgs, iArg)
132 self.asExtraData.append(asArgs[iArg])
133 else:
134 return vbox.TestDriver.parseOption(self, asArgs, iArg)
135
136 return iArg + 1
137
138 def actionConfig(self):
139 """
140 Configure pre-conditions.
141 """
142
143 if not self.importVBoxApi():
144 return False
145
146 assert self.sIso is not None
147 if self.sIso not in self.kaoVmParams:
148 reporter.log('Error: unknown ISO image specified: %s' % self.sIso)
149 return False
150
151 # Get VM params specific to ISO image
152 cBytesHdd, sKind, sController = self.kaoVmParams[self.sIso]
153
154 # Create VM itself
155 eNic0AttachType = vboxcon.NetworkAttachmentType_NAT
156 self.sIso = os.path.join(self.sIsoPathBase, self.sIso)
157 assert os.path.isfile(self.sIso)
158
159 self.sFloppy = os.path.join(self.sIsoPathBase, os.path.splitext(self.sIso)[0] + '.img')
160
161 oVM = self.createTestVM(self.sVmName, 1, sKind = sKind, sDvdImage = self.sIso, cCpus = self.cCpus,
162 sFloppy = self.sFloppy, eNic0AttachType = eNic0AttachType)
163 assert oVM is not None
164
165 oSession = self.openSession(oVM)
166
167 # Create HDD
168 sHddPath = os.path.join(self.sScratchPath, self.sHddName)
169 fRc = True
170 if sController == self.ksSataController:
171 fRc = oSession.setStorageControllerType(vboxcon.StorageControllerType_IntelAhci, sController)
172
173 fRc = fRc and oSession.createAndAttachHd(sHddPath, cb = cBytesHdd,
174 sController = sController, iPort = 0, fImmutable=False)
175 if sController == self.ksSataController:
176 fRc = fRc and oSession.setStorageControllerPortCount(sController, 1)
177
178 # Set proper boot order
179 fRc = fRc and oSession.setBootOrder(1, vboxcon.DeviceType_HardDisk)
180 fRc = fRc and oSession.setBootOrder(2, vboxcon.DeviceType_Floppy)
181
182 # Enable HW virt
183 fRc = fRc and oSession.enableVirtEx(True)
184
185 # Enable I/O APIC
186 fRc = fRc and oSession.enableIoApic(self.fEnableIOAPIC)
187
188 # Enable Nested Paging
189 fRc = fRc and oSession.enableNestedPaging(self.fEnableNestedPaging)
190
191 # Enable PAE
192 fRc = fRc and oSession.enablePae(self.fEnablePAE)
193
194 # Remote desktop
195 oSession.setupVrdp(True)
196
197 # Set extra data
198 if self.asExtraData != []:
199 for sExtraData in self.asExtraData:
200 try:
201 sKey, sValue = sExtraData.split(':')
202 except ValueError:
203 raise base.InvalidOption('Invalid extradata specified: %s' % sExtraData)
204 reporter.log('Set extradata: %s => %s' % (sKey, sValue))
205 fRc = fRc and oSession.setExtraData(sKey, sValue)
206
207 fRc = fRc and oSession.saveSettings()
208 fRc = oSession.close()
209 assert fRc is True
210
211 return vbox.TestDriver.actionConfig(self)
212
213 def actionExecute(self):
214 """
215 Execute the testcase itself.
216 """
217 if not self.importVBoxApi():
218 return False
219 return self.testDoInstallGuestOs()
220
221 #
222 # Test execution helpers.
223 #
224
225 def testDoInstallGuestOs(self):
226 """
227 Install guest OS and wait for result
228 """
229 reporter.testStart('Installing %s' % (os.path.basename(self.sIso),))
230
231 cMsTimeout = 40*60000;
232 if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
233 cMsTimeout = 180 * 60000; # will be adjusted down.
234
235 oSession, _ = self.startVmAndConnectToTxsViaTcp(self.sVmName, fCdWait = False, cMsTimeout = cMsTimeout)
236 if oSession is not None:
237 # Wait until guest reported success
238 reporter.log('Guest reported success')
239 reporter.testDone()
240 fRc = self.terminateVmBySession(oSession)
241 return fRc is True
242 reporter.error('Installation of %s has failed' % (self.sIso,))
243 reporter.testDone()
244 return False
245
246if __name__ == '__main__':
247 sys.exit(tdGuestOsInstOs2().main(sys.argv));
248
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