1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdGuestOsInstOs2.py 69577 2017-11-04 10:19:04Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | VirtualBox Validation Kit - OS/2 install tests.
|
---|
7 | """
|
---|
8 |
|
---|
9 | __copyright__ = \
|
---|
10 | """
|
---|
11 | Copyright (C) 2010-2017 Oracle Corporation
|
---|
12 |
|
---|
13 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
14 | available from http://www.virtualbox.org. This file is free software;
|
---|
15 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
16 | General Public License (GPL) as published by the Free Software
|
---|
17 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
18 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
19 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
20 |
|
---|
21 | The contents of this file may alternatively be used under the terms
|
---|
22 | of the Common Development and Distribution License Version 1.0
|
---|
23 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
24 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
25 | CDDL are applicable instead of those of the GPL.
|
---|
26 |
|
---|
27 | You may elect to license modified versions of this file under the
|
---|
28 | terms and conditions of either the GPL or the CDDL or both.
|
---|
29 | """
|
---|
30 | __version__ = "$Revision: 69577 $"
|
---|
31 |
|
---|
32 |
|
---|
33 | # Standard Python imports.
|
---|
34 | import os
|
---|
35 | import sys
|
---|
36 |
|
---|
37 |
|
---|
38 | # Only the main script needs to modify the path.
|
---|
39 | try: __file__
|
---|
40 | except: __file__ = sys.argv[0]
|
---|
41 | g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
---|
42 | sys.path.append(g_ksValidationKitDir)
|
---|
43 |
|
---|
44 | # Validation Kit imports.
|
---|
45 | from testdriver import vbox
|
---|
46 | from testdriver import base
|
---|
47 | from testdriver import reporter
|
---|
48 | from testdriver import vboxcon
|
---|
49 |
|
---|
50 |
|
---|
51 | class 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.oVM = None
|
---|
87 | self.fEnableIOAPIC = True
|
---|
88 | self.cCpus = 1
|
---|
89 | self.fEnableNestedPaging = True
|
---|
90 | self.fEnablePAE = False
|
---|
91 | self.asExtraData = []
|
---|
92 |
|
---|
93 | #
|
---|
94 | # Overridden methods.
|
---|
95 | #
|
---|
96 |
|
---|
97 | def showUsage(self):
|
---|
98 | """
|
---|
99 | Extend usage info
|
---|
100 | """
|
---|
101 | rc = vbox.TestDriver.showUsage(self)
|
---|
102 | reporter.log(' --install-iso <ISO file name>')
|
---|
103 | reporter.log(' --cpus <# CPUs>')
|
---|
104 | reporter.log(' --no-ioapic')
|
---|
105 | reporter.log(' --no-nested-paging')
|
---|
106 | reporter.log(' --pae')
|
---|
107 | reporter.log(' --set-extradata <key>:value')
|
---|
108 | reporter.log(' Set VM extra data. This command line option might be used multiple times.')
|
---|
109 | return rc
|
---|
110 |
|
---|
111 | def parseOption(self, asArgs, iArg):
|
---|
112 | """
|
---|
113 | Extend standard options set
|
---|
114 | """
|
---|
115 | if asArgs[iArg] == '--install-iso':
|
---|
116 | iArg += 1
|
---|
117 | if iArg >= len(asArgs): raise base.InvalidOption('The "--install-iso" option requires an argument')
|
---|
118 | self.sIso = asArgs[iArg]
|
---|
119 | elif asArgs[iArg] == '--cpus':
|
---|
120 | iArg += 1
|
---|
121 | if iArg >= len(asArgs): raise base.InvalidOption('The "--cpus" option requires an argument')
|
---|
122 | self.cCpus = int(asArgs[iArg])
|
---|
123 | elif asArgs[iArg] == '--no-ioapic':
|
---|
124 | self.fEnableIOAPIC = False
|
---|
125 | elif asArgs[iArg] == '--no-nested-paging':
|
---|
126 | self.fEnableNestedPaging = False
|
---|
127 | elif asArgs[iArg] == '--pae':
|
---|
128 | self.fEnablePAE = True
|
---|
129 | elif asArgs[iArg] == '--extra-mem':
|
---|
130 | self.fEnablePAE = True
|
---|
131 | elif asArgs[iArg] == '--set-extradata':
|
---|
132 | iArg = self.requireMoreArgs(1, asArgs, iArg)
|
---|
133 | self.asExtraData.append(asArgs[iArg])
|
---|
134 | else:
|
---|
135 | return vbox.TestDriver.parseOption(self, asArgs, iArg)
|
---|
136 |
|
---|
137 | return iArg + 1
|
---|
138 |
|
---|
139 | def actionConfig(self):
|
---|
140 | """
|
---|
141 | Configure pre-conditions.
|
---|
142 | """
|
---|
143 |
|
---|
144 | if not self.importVBoxApi():
|
---|
145 | return False
|
---|
146 |
|
---|
147 | assert self.sIso is not None
|
---|
148 | if self.sIso not in self.kaoVmParams:
|
---|
149 | reporter.log('Error: unknown ISO image specified: %s' % self.sIso)
|
---|
150 | return False
|
---|
151 |
|
---|
152 | # Get VM params specific to ISO image
|
---|
153 | cBytesHdd, sKind, sController = self.kaoVmParams[self.sIso]
|
---|
154 |
|
---|
155 | # Create VM itself
|
---|
156 | eNic0AttachType = vboxcon.NetworkAttachmentType_NAT
|
---|
157 | self.sIso = os.path.join(self.sIsoPathBase, self.sIso)
|
---|
158 | assert os.path.isfile(self.sIso)
|
---|
159 |
|
---|
160 | self.sFloppy = os.path.join(self.sIsoPathBase, os.path.splitext(self.sIso)[0] + '.img')
|
---|
161 |
|
---|
162 | self.oVM = self.createTestVM(self.sVmName, 1, sKind = sKind, sDvdImage = self.sIso, cCpus = self.cCpus,
|
---|
163 | sFloppy = self.sFloppy, eNic0AttachType = eNic0AttachType)
|
---|
164 | assert self.oVM is not None
|
---|
165 |
|
---|
166 | oSession = self.openSession(self.oVM)
|
---|
167 |
|
---|
168 | # Create HDD
|
---|
169 | sHddPath = os.path.join(self.sScratchPath, self.sHddName)
|
---|
170 | fRc = True
|
---|
171 | if sController == self.ksSataController:
|
---|
172 | fRc = oSession.setStorageControllerType(vboxcon.StorageControllerType_IntelAhci, sController)
|
---|
173 |
|
---|
174 | fRc = fRc and oSession.createAndAttachHd(sHddPath, cb = cBytesHdd,
|
---|
175 | sController = sController, iPort = 0, fImmutable=False)
|
---|
176 | if sController == self.ksSataController:
|
---|
177 | fRc = fRc and oSession.setStorageControllerPortCount(sController, 1)
|
---|
178 |
|
---|
179 | # Set proper boot order
|
---|
180 | fRc = fRc and oSession.setBootOrder(1, vboxcon.DeviceType_HardDisk)
|
---|
181 | fRc = fRc and oSession.setBootOrder(2, vboxcon.DeviceType_Floppy)
|
---|
182 |
|
---|
183 | # Enable HW virt
|
---|
184 | fRc = fRc and oSession.enableVirtEx(True)
|
---|
185 |
|
---|
186 | # Enable I/O APIC
|
---|
187 | fRc = fRc and oSession.enableIoApic(self.fEnableIOAPIC)
|
---|
188 |
|
---|
189 | # Enable Nested Paging
|
---|
190 | fRc = fRc and oSession.enableNestedPaging(self.fEnableNestedPaging)
|
---|
191 |
|
---|
192 | # Enable PAE
|
---|
193 | fRc = fRc and oSession.enablePae(self.fEnablePAE)
|
---|
194 |
|
---|
195 | # Remote desktop
|
---|
196 | oSession.setupVrdp(True)
|
---|
197 |
|
---|
198 | # Set extra data
|
---|
199 | if self.asExtraData != []:
|
---|
200 | for sExtraData in self.asExtraData:
|
---|
201 | try:
|
---|
202 | sKey, sValue = sExtraData.split(':')
|
---|
203 | except ValueError:
|
---|
204 | raise base.InvalidOption('Invalid extradata specified: %s' % sExtraData)
|
---|
205 | reporter.log('Set extradata: %s => %s' % (sKey, sValue))
|
---|
206 | fRc = fRc and oSession.setExtraData(sKey, sValue)
|
---|
207 |
|
---|
208 | fRc = fRc and oSession.saveSettings()
|
---|
209 | fRc = oSession.close()
|
---|
210 | assert fRc is True
|
---|
211 |
|
---|
212 | return vbox.TestDriver.actionConfig(self)
|
---|
213 |
|
---|
214 | def actionExecute(self):
|
---|
215 | """
|
---|
216 | Execute the testcase itself.
|
---|
217 | """
|
---|
218 | return self.testDoInstallGuestOs()
|
---|
219 |
|
---|
220 | #
|
---|
221 | # Test execution helpers.
|
---|
222 | #
|
---|
223 |
|
---|
224 | def testDoInstallGuestOs(self):
|
---|
225 | """
|
---|
226 | Install guest OS and wait for result
|
---|
227 | """
|
---|
228 |
|
---|
229 | self.logVmInfo(self.oVM)
|
---|
230 | reporter.testStart('Installing %s' % (os.path.basename(self.sIso),))
|
---|
231 |
|
---|
232 | cMsTimeout = 40*60000;
|
---|
233 | if not reporter.isLocal(): ## @todo need to figure a better way of handling timeouts on the testboxes ...
|
---|
234 | cMsTimeout = 180 * 60000; # will be adjusted down.
|
---|
235 |
|
---|
236 | oSession, _ = self.startVmAndConnectToTxsViaTcp(self.sVmName, fCdWait = False, cMsTimeout = cMsTimeout)
|
---|
237 | if oSession is not None:
|
---|
238 | # Wait until guest reported success
|
---|
239 | reporter.log('Guest reported success')
|
---|
240 | reporter.testDone()
|
---|
241 | fRc = self.terminateVmBySession(oSession)
|
---|
242 | return fRc is True
|
---|
243 | reporter.error('Installation of %s has failed' % (self.sIso,))
|
---|
244 | reporter.testDone()
|
---|
245 | return False
|
---|
246 |
|
---|
247 | if __name__ == '__main__':
|
---|
248 | sys.exit(tdGuestOsInstOs2().main(sys.argv);
|
---|
249 |
|
---|