VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/additions/tdAddBasic1.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: 11.2 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdAddBasic1.py 52776 2014-09-17 14:51:43Z vboxsync $
4
5"""
6VirtualBox Validation Kit - Additions Basics #1.
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# Only the main script needs to modify the path.
38try: __file__
39except: __file__ = sys.argv[0];
40g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
41sys.path.append(g_ksValidationKitDir);
42
43# Validation Kit imports.
44from testdriver import reporter;
45from testdriver import base;
46from testdriver import vbox;
47from testdriver import vboxcon;
48
49# Sub test driver imports.
50sys.path.append(os.path.dirname(os.path.abspath(__file__))); # For sub-test drivers.
51from tdAddGuestCtrl import SubTstDrvAddGuestCtrl;
52
53
54class tdAddBasic1(vbox.TestDriver): # pylint: disable=R0902
55 """
56 Additions Basics #1.
57 """
58 ## @todo
59 # - More of the settings stuff can e and need to be generalized!
60 #
61
62 def __init__(self):
63 vbox.TestDriver.__init__(self);
64 self.oTestVmSet = self.oTestVmManager.getStandardVmSet('nat');
65 self.asTestsDef = ['guestprops', 'stdguestprops', 'guestcontrol'];
66 self.asTests = self.asTestsDef;
67
68 self.addSubTestDriver(SubTstDrvAddGuestCtrl(self));
69
70 #
71 # Overridden methods.
72 #
73 def showUsage(self):
74 rc = vbox.TestDriver.showUsage(self);
75 reporter.log('');
76 reporter.log('tdAddBasic1 Options:');
77 reporter.log(' --tests <s1[:s2[:]]>');
78 reporter.log(' Default: %s (all)' % (':'.join(self.asTestsDef)));
79 reporter.log(' --quick');
80 reporter.log(' Same as --virt-modes hwvirt --cpu-counts 1.');
81 return rc;
82
83 def parseOption(self, asArgs, iArg): # pylint: disable=R0912,R0915
84 if asArgs[iArg] == '--tests':
85 iArg += 1;
86 if iArg >= len(asArgs): raise base.InvalidOption('The "--tests" takes a colon separated list of tests');
87 self.asTests = asArgs[iArg].split(':');
88 for s in self.asTests:
89 if s not in self.asTestsDef:
90 raise base.InvalidOption('The "--tests" value "%s" is not valid; valid values are: %s' \
91 % (s, ' '.join(self.asTestsDef)));
92
93 elif asArgs[iArg] == '--quick':
94 self.parseOption(['--virt-modes', 'hwvirt'], 0);
95 self.parseOption(['--cpu-counts', '1'], 0);
96
97 else:
98 return vbox.TestDriver.parseOption(self, asArgs, iArg);
99 return iArg + 1;
100
101 def actionConfig(self):
102 if not self.importVBoxApi(): # So we can use the constant below.
103 return False;
104
105 eNic0AttachType = vboxcon.NetworkAttachmentType_NAT;
106 sGaIso = self.getGuestAdditionsIso();
107 return self.oTestVmSet.actionConfig(self, eNic0AttachType = eNic0AttachType, sDvdImage = sGaIso);
108
109 def actionExecute(self):
110 return self.oTestVmSet.actionExecute(self, self.testOneCfg);
111
112
113 #
114 # Test execution helpers.
115 #
116
117 def testOneCfg(self, oVM, oTestVm):
118 """
119 Runs the specified VM thru the tests.
120
121 Returns a success indicator on the general test execution. This is not
122 the actual test result.
123 """
124 fRc = False;
125
126 self.logVmInfo(oVM);
127 oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = True, \
128 sFileCdWait = 'AUTORUN.INF');
129 if oSession is not None:
130 self.addTask(oSession);
131 # Do the testing.
132 reporter.testStart('Install');
133 fRc, oTxsSession = self.testInstallAdditions(oSession, oTxsSession, oTestVm);
134 reporter.testDone();
135 fSkip = not fRc;
136
137 reporter.testStart('Guest Properties');
138 if not fSkip:
139 fRc = self.testGuestProperties(oSession, oTxsSession, oTestVm) and fRc;
140 reporter.testDone(fSkip);
141
142 reporter.testStart('Guest Control');
143 if not fSkip:
144 (fRc2, oTxsSession) = self.aoSubTstDrvs[0].testIt(oTestVm, oSession, oTxsSession);
145 fRc = fRc2 and fRc;
146 reporter.testDone(fSkip);
147
148 ## @todo Save an restore test.
149
150 ## @todo Reset tests.
151
152 ## @todo Final test: Uninstallation.
153
154 # Cleanup.
155 self.removeTask(oTxsSession);
156 #self.terminateVmBySession(oSession)
157 return fRc;
158
159 def testInstallAdditions(self, oSession, oTxsSession, oTestVm):
160 """
161 Tests installing the guest additions
162 """
163 if oTestVm.isWindows():
164 fRc = self.testWindowsInstallAdditions(oSession, oTxsSession, oTestVm);
165 else:
166 reporter.error('Guest Additions installation not implemented for %s yet! (%s)' % \
167 (oTestVm.sKind, oTestVm.sVmName));
168 fRc = False;
169
170 #
171 # Verify installation of Guest Additions using commmon bits.
172 #
173 if fRc is True:
174 #
175 # Wait for the GAs to come up.
176 #
177
178 ## @todo need to signed up for a OnAdditionsStateChanged and wait runlevel to
179 # at least reach Userland.
180
181 #
182 # Check if the additions are operational.
183 #
184 try: oGuest = oSession.o.console.guest;
185 except:
186 reporter.errorXcpt('Getting IGuest failed.');
187 return (False, oTxsSession);
188
189 # Check the additionsVersion attribute. It must not be empty.
190 reporter.testStart('IGuest::additionsVersion');
191 fRc = self.testIGuest_additionsVersion(oGuest);
192 reporter.testDone();
193
194 reporter.testStart('IGuest::additionsRunLevel');
195 self.testIGuest_additionsRunLevel(oGuest, oTestVm);
196 reporter.testDone();
197
198 ## @todo test IAdditionsFacilities.
199
200 return (fRc, oTxsSession);
201
202 def testWindowsInstallAdditions(self, oSession, oTxsSession, oTestVm):
203 """
204 Installs the Windows guest additions using the test execution service.
205 Since this involves rebooting the guest, we will have to create a new TXS session.
206 """
207 asLogFile = [];
208
209 # Delete relevant log files.
210 if oTestVm.sKind in ('WindowsNT4',):
211 sWinDir = 'C:/WinNT/';
212 else:
213 sWinDir = 'C:/Windows/';
214 asLogFile = [sWinDir+'setupapi.log', sWinDir+'setupact.log', sWinDir+'setuperr.log'];
215
216 for sFile in asLogFile:
217 self.txsRmFile(oSession, oTxsSession, sFile);
218
219 # Install the public signing key.
220 if oTestVm.sKind not in ('WindowsNT4', 'Windows2000', 'WindowsXP', 'Windows2003'):
221 ## TODO
222 pass;
223
224 #
225 # The actual install.
226 # Enable installing the optional auto-logon modules (VBoxGINA/VBoxCredProv) + (Direct)3D support.
227 # Also tell the installer to produce the appropriate log files.
228 #
229 fRc = self.txsRunTest(oTxsSession, 'VBoxWindowsAdditions.exe', 5 * 60 * 1000, \
230 '${CDROM}/VBoxWindowsAdditions.exe', ('${CDROM}/VBoxWindowsAdditions.exe', '/S', '/l', '/with_autologon'));
231 # For testing the installation (D)3D stuff ('/with_d3d') we need to boot up in safe mode.
232
233 #
234 # Reboot the VM and reconnect the TXS session.
235 #
236 if fRc is True:
237 (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 3 * 60000);
238
239 # Add the Windows Guest Additions installer files to the files we want to download
240 # from the guest.
241 sGuestAddsDir = 'C:/Program Files/Oracle/VirtualBox Guest Additions/';
242 asLogFile.append(sGuestAddsDir + 'install.log');
243 # Note: There won't be a install_ui.log because of the silent installation.
244 asLogFile.append(sGuestAddsDir + 'install_drivers.log');
245 asLogFile.append('C:/Windows/setupapi.log');
246 asLogFile.append('C:/Windows/setupapi.dev.log');
247
248 #
249 # Download log files.
250 # Ignore errors as all files above might not be present (or in different locations)
251 # on different Windows guests.
252 #
253 self.txsDownloadFiles(oSession, oTxsSession, asLogFile, fIgnoreErrors = True);
254
255 return (fRc, oTxsSession);
256
257 def testIGuest_additionsVersion(self, oGuest):
258 """
259 Returns False if no version string could be obtained, otherwise True
260 even though errors are logged.
261 """
262 try:
263 sVer = oGuest.additionsVersion;
264 except:
265 reporter.errorXcpt('Getting the additions version failed.');
266 return False;
267 reporter.log('IGuest::additionsVersion="%s"' % (sVer,));
268
269 if sVer.strip() == '':
270 reporter.error('IGuest::additionsVersion is empty.');
271 return False;
272
273 if sVer != sVer.strip():
274 reporter.error('IGuest::additionsVersion is contains spaces: "%s".' % (sVer,));
275
276 asBits = sVer.split('.');
277 if len(asBits) < 3:
278 reporter.error('IGuest::additionsVersion does not contain at least tree dot separated fields: "%s" (%d).'
279 % (sVer, len(asBits)));
280
281 ## @todo verify the format.
282 return True;
283
284 def testIGuest_additionsRunLevel(self, oGuest, oTestVm):
285 """
286 Do run level tests.
287 """
288 if oTestVm.isLoggedOntoDesktop():
289 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Desktop;
290 else:
291 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
292
293 ## @todo Insert wait for the desired run level.
294 try:
295 iLevel = oGuest.additionsRunLevel;
296 except:
297 reporter.errorXcpt('Getting the additions run level failed.');
298 return False;
299 reporter.log('IGuest::additionsRunLevel=%s' % (iLevel,));
300
301 if iLevel != eExpectedRunLevel:
302 reporter.error('Expected runlevel %d, found %d instead' % (eExpectedRunLevel, iLevel));
303 return True;
304
305
306 def testGuestProperties(self, oSession, oTxsSession, oTestVm):
307 """
308 Test guest properties.
309 """
310 _ = oSession; _ = oTxsSession; _ = oTestVm;
311 return True;
312
313if __name__ == '__main__':
314 sys.exit(tdAddBasic1().main(sys.argv));
315
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