VirtualBox

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

Last change on this file was 106061, checked in by vboxsync, 4 days 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.9 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdGuestOsInstOs2.py 106061 2024-09-16 14:03:52Z vboxsync $
4
5"""
6VirtualBox Validation Kit - OS/2 install tests.
7"""
8
9__copyright__ = \
10"""
11Copyright (C) 2010-2024 Oracle and/or its affiliates.
12
13This file is part of VirtualBox base platform packages, as
14available from https://www.virtualbox.org.
15
16This program is free software; you can redistribute it and/or
17modify it under the terms of the GNU General Public License
18as published by the Free Software Foundation, in version 3 of the
19License.
20
21This program is distributed in the hope that it will be useful, but
22WITHOUT ANY WARRANTY; without even the implied warranty of
23MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24General Public License for more details.
25
26You should have received a copy of the GNU General Public License
27along with this program; if not, see <https://www.gnu.org/licenses>.
28
29The contents of this file may alternatively be used under the terms
30of the Common Development and Distribution License Version 1.0
31(CDDL), a copy of it is provided in the "COPYING.CDDL" file included
32in the VirtualBox distribution, in which case the provisions of the
33CDDL are applicable instead of those of the GPL.
34
35You may elect to license modified versions of this file under the
36terms and conditions of either the GPL or the CDDL or both.
37
38SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
39"""
40__version__ = "$Revision: 106061 $"
41
42
43# Standard Python imports.
44import os
45import sys
46
47
48# Only the main script needs to modify the path.
49try: __file__ # pylint: disable=used-before-assignment
50except: __file__ = sys.argv[0]
51g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
52sys.path.append(g_ksValidationKitDir)
53
54# Validation Kit imports.
55from testdriver import vbox
56from testdriver import base
57from testdriver import reporter
58from testdriver import vboxcon
59
60
61class tdGuestOsInstOs2(vbox.TestDriver):
62 """
63 OS/2 unattended installation.
64
65 Scenario:
66 - Create new VM that corresponds specified installation ISO image
67 - Create HDD that corresponds to OS type that will be installed
68 - Set VM boot order: HDD, Floppy, ISO
69 - Start VM: sinse there is no OS installed on HDD, VM will booted from floppy
70 - After first reboot VM will continue installation from HDD automatically
71 - Wait for incomming TCP connection (guest should initiate such a
72 connection in case installation has been completed successfully)
73 """
74
75 ksSataController = 'SATA Controller'
76 ksIdeController = 'IDE Controller'
77
78 # VM parameters required to run ISO image.
79 # Format: (cBytesHdd, sKind)
80 kaoVmParams = {
81 'acp2-txs.iso': ( 2*1024*1024*1024, 'OS2', ksIdeController ),
82 'mcp2-txs.iso': ( 2*1024*1024*1024, 'OS2', ksIdeController ),
83 }
84
85 def __init__(self):
86 """
87 Reinitialize child class instance.
88 """
89 vbox.TestDriver.__init__(self)
90
91 self.sVmName = 'TestVM'
92 self.sHddName = 'TestHdd.vdi'
93 self.sIso = None
94 self.sFloppy = None
95 self.sIsoPathBase = os.path.join(self.sResourcePath, '4.2', 'isos')
96 self.fEnableIOAPIC = True
97 self.cCpus = 1
98 self.fEnableNestedPaging = True
99 self.fEnablePAE = False
100 self.asExtraData = []
101
102 #
103 # Overridden methods.
104 #
105
106 def showUsage(self):
107 """
108 Extend usage info
109 """
110 rc = vbox.TestDriver.showUsage(self)
111 reporter.log(' --install-iso <ISO file name>')
112 reporter.log(' --cpus <# CPUs>')
113 reporter.log(' --no-ioapic')
114 reporter.log(' --no-nested-paging')
115 reporter.log(' --pae')
116 reporter.log(' --set-extradata <key>:value')
117 reporter.log(' Set VM extra data. This command line option might be used multiple times.')
118 return rc
119
120 def parseOption(self, asArgs, iArg):
121 """
122 Extend standard options set
123 """
124 if asArgs[iArg] == '--install-iso':
125 iArg += 1
126 if iArg >= len(asArgs): raise base.InvalidOption('The "--install-iso" option requires an argument')
127 self.sIso = asArgs[iArg]
128 elif asArgs[iArg] == '--cpus':
129 iArg += 1
130 if iArg >= len(asArgs): raise base.InvalidOption('The "--cpus" option requires an argument')
131 self.cCpus = int(asArgs[iArg])
132 elif asArgs[iArg] == '--no-ioapic':
133 self.fEnableIOAPIC = False
134 elif asArgs[iArg] == '--no-nested-paging':
135 self.fEnableNestedPaging = False
136 elif asArgs[iArg] == '--pae':
137 self.fEnablePAE = True
138 elif asArgs[iArg] == '--extra-mem':
139 self.fEnablePAE = True
140 elif asArgs[iArg] == '--set-extradata':
141 iArg = self.requireMoreArgs(1, asArgs, iArg)
142 self.asExtraData.append(asArgs[iArg])
143 else:
144 return vbox.TestDriver.parseOption(self, asArgs, iArg)
145
146 return iArg + 1
147
148 def actionConfig(self):
149 """
150 Configure pre-conditions.
151 """
152
153 if not self.importVBoxApi():
154 return False
155
156 assert self.sIso is not None
157 if self.sIso not in self.kaoVmParams:
158 reporter.log('Error: unknown ISO image specified: %s' % self.sIso)
159 return False
160
161 # Get VM params specific to ISO image
162 cBytesHdd, sKind, sController = self.kaoVmParams[self.sIso]
163
164 # Create VM itself
165 eNic0AttachType = vboxcon.NetworkAttachmentType_NAT
166 self.sIso = os.path.join(self.sIsoPathBase, self.sIso)
167 assert os.path.isfile(self.sIso)
168
169 self.sFloppy = os.path.join(self.sIsoPathBase, os.path.splitext(self.sIso)[0] + '.img')
170
171 oVM = self.createTestVM(self.sVmName, 1, sKind = sKind, sDvdImage = self.sIso, cCpus = self.cCpus,
172 sFloppy = self.sFloppy, eNic0AttachType = eNic0AttachType)
173 assert oVM is not None
174
175 oSession = self.openSession(oVM)
176
177 # Create HDD
178 sHddPath = os.path.join(self.sScratchPath, self.sHddName)
179 fRc = True
180 if sController == self.ksSataController:
181 fRc = oSession.setStorageControllerType(vboxcon.StorageControllerType_IntelAhci, sController)
182
183 fRc = fRc and oSession.createAndAttachHd(sHddPath, cb = cBytesHdd,
184 sController = sController, iPort = 0, fImmutable=False)
185 if sController == self.ksSataController:
186 fRc = fRc and oSession.setStorageControllerPortCount(sController, 1)
187
188 # Set proper boot order
189 fRc = fRc and oSession.setBootOrder(1, vboxcon.DeviceType_HardDisk)
190 fRc = fRc and oSession.setBootOrder(2, vboxcon.DeviceType_Floppy)
191
192 # Enable HW virt
193 fRc = fRc and oSession.enableVirtExX86(True)
194
195 # Enable I/O APIC
196 fRc = fRc and oSession.enableIoApic(self.fEnableIOAPIC)
197
198 # Enable Nested Paging
199 fRc = fRc and oSession.enableNestedPagingX86(self.fEnableNestedPaging)
200
201 # Enable PAE
202 fRc = fRc and oSession.enablePaeX86(self.fEnablePAE)
203
204 # Remote desktop
205 oSession.setupVrdp(True)
206
207 # Set extra data
208 if self.asExtraData:
209 for sExtraData in self.asExtraData:
210 try:
211 sKey, sValue = sExtraData.split(':')
212 except ValueError:
213 raise base.InvalidOption('Invalid extradata specified: %s' % sExtraData)
214 reporter.log('Set extradata: %s => %s' % (sKey, sValue))
215 fRc = fRc and oSession.setExtraData(sKey, sValue)
216
217 fRc = fRc and oSession.saveSettings()
218 fRc = oSession.close()
219 assert fRc is True
220
221 return vbox.TestDriver.actionConfig(self)
222
223 def actionExecute(self):
224 """
225 Execute the testcase itself.
226 """
227 if not self.importVBoxApi():
228 return False
229 return self.testDoInstallGuestOs()
230
231 #
232 # Test execution helpers.
233 #
234
235 def testDoInstallGuestOs(self):
236 """
237 Install guest OS and wait for result
238 """
239 reporter.testStart('Installing %s' % (os.path.basename(self.sIso),))
240
241 cMsTimeout = 40*60000;
242 if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
243 cMsTimeout = 180 * 60000; # will be adjusted down.
244
245 oSession, _ = self.startVmAndConnectToTxsViaTcp(self.sVmName, fCdWait = False, cMsTimeout = cMsTimeout)
246 if oSession is not None:
247 # Wait until guest reported success
248 reporter.log('Guest reported success')
249 reporter.testDone()
250 fRc = self.terminateVmBySession(oSession)
251 return fRc is True
252 reporter.error('Installation of %s has failed' % (self.sIso,))
253 reporter.testDone()
254 return False
255
256if __name__ == '__main__':
257 sys.exit(tdGuestOsInstOs2().main(sys.argv));
258
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