1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdAddBasic1.py 84226 2020-05-09 17:39:15Z vboxsync $
|
---|
4 |
|
---|
5 | """
|
---|
6 | VirtualBox Validation Kit - Additions Basics #1.
|
---|
7 | """
|
---|
8 |
|
---|
9 | __copyright__ = \
|
---|
10 | """
|
---|
11 | Copyright (C) 2010-2020 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: 84226 $"
|
---|
31 |
|
---|
32 | # Standard Python imports.
|
---|
33 | import os;
|
---|
34 | import sys;
|
---|
35 | import uuid;
|
---|
36 |
|
---|
37 | # Only the main script needs to modify the path.
|
---|
38 | try: __file__
|
---|
39 | except: __file__ = sys.argv[0];
|
---|
40 | g_ksValidationKitDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
|
---|
41 | sys.path.append(g_ksValidationKitDir);
|
---|
42 |
|
---|
43 | # Validation Kit imports.
|
---|
44 | from testdriver import reporter;
|
---|
45 | from testdriver import base;
|
---|
46 | from testdriver import vbox;
|
---|
47 | from testdriver import vboxcon;
|
---|
48 |
|
---|
49 | # Sub-test driver imports.
|
---|
50 | sys.path.append(os.path.dirname(os.path.abspath(__file__))); # For sub-test drivers.
|
---|
51 | from tdAddGuestCtrl import SubTstDrvAddGuestCtrl;
|
---|
52 | from tdAddSharedFolders1 import SubTstDrvAddSharedFolders1;
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 | class tdAddBasicConsoleCallbacks(vbox.ConsoleEventHandlerBase):
|
---|
57 | """
|
---|
58 | For catching the Guest Additions change state events.
|
---|
59 | """
|
---|
60 | def __init__(self, dArgs):
|
---|
61 | oTstDrv = dArgs['oTstDrv'];
|
---|
62 | oVBoxMgr = dArgs['oVBoxMgr']; _ = oVBoxMgr;
|
---|
63 | oGuest = dArgs['oGuest'];
|
---|
64 |
|
---|
65 | vbox.ConsoleEventHandlerBase.__init__(self, dArgs, 'tdAddBasic1');
|
---|
66 | self.oTstDrv = oTstDrv;
|
---|
67 | self.oGuest = oGuest;
|
---|
68 |
|
---|
69 | def handleEvent(self, oEvt):
|
---|
70 | try:
|
---|
71 | oEvtBase = self.oVBoxMgr.queryInterface(oEvt, 'IEvent');
|
---|
72 | eType = oEvtBase.type;
|
---|
73 | except:
|
---|
74 | reporter.logXcpt();
|
---|
75 | return None;
|
---|
76 | if eType == vboxcon.VBoxEventType_OnAdditionsStateChanged:
|
---|
77 | return self.onAdditionsStateChanged();
|
---|
78 | return None;
|
---|
79 |
|
---|
80 | def onAdditionsStateChanged(self):
|
---|
81 | reporter.log('onAdditionsStateChange');
|
---|
82 | self.oTstDrv.fGAStatusCallbackFired = True;
|
---|
83 | self.oTstDrv.eGAStatusCallbackRunlevel = self.oGuest.additionsRunLevel;
|
---|
84 | self.oVBoxMgr.interruptWaitEvents();
|
---|
85 | return None;
|
---|
86 |
|
---|
87 | class tdAddBasic1(vbox.TestDriver): # pylint: disable=too-many-instance-attributes
|
---|
88 | """
|
---|
89 | Additions Basics #1.
|
---|
90 | """
|
---|
91 | ## @todo
|
---|
92 | # - More of the settings stuff can be and need to be generalized!
|
---|
93 | #
|
---|
94 |
|
---|
95 | def __init__(self):
|
---|
96 | vbox.TestDriver.__init__(self);
|
---|
97 | self.oTestVmSet = self.oTestVmManager.getSmokeVmSet('nat');
|
---|
98 | self.asTestsDef = ['install', 'guestprops', 'stdguestprops', 'guestcontrol', 'sharedfolders'];
|
---|
99 | self.asTests = self.asTestsDef;
|
---|
100 | self.asRsrcs = None
|
---|
101 | # The file we're going to use as a beacon to wait if the Guest Additions CD-ROM is ready.
|
---|
102 | self.sFileCdWait = '';
|
---|
103 |
|
---|
104 | self.addSubTestDriver(SubTstDrvAddGuestCtrl(self));
|
---|
105 | self.addSubTestDriver(SubTstDrvAddSharedFolders1(self));
|
---|
106 |
|
---|
107 | self.fGAStatusCallbackFired = False;
|
---|
108 | self.eGAStatusCallbackRunlevel = 0;
|
---|
109 |
|
---|
110 | #
|
---|
111 | # Overridden methods.
|
---|
112 | #
|
---|
113 | def showUsage(self):
|
---|
114 | rc = vbox.TestDriver.showUsage(self);
|
---|
115 | reporter.log('');
|
---|
116 | reporter.log('tdAddBasic1 Options:');
|
---|
117 | reporter.log(' --tests <s1[:s2[:]]>');
|
---|
118 | reporter.log(' Default: %s (all)' % (':'.join(self.asTestsDef)));
|
---|
119 | reporter.log(' --quick');
|
---|
120 | reporter.log(' Same as --virt-modes hwvirt --cpu-counts 1.');
|
---|
121 | return rc;
|
---|
122 |
|
---|
123 | def parseOption(self, asArgs, iArg): # pylint: disable=too-many-branches,too-many-statements
|
---|
124 | if asArgs[iArg] == '--tests':
|
---|
125 | iArg += 1;
|
---|
126 | if iArg >= len(asArgs): raise base.InvalidOption('The "--tests" takes a colon separated list of tests');
|
---|
127 | self.asTests = asArgs[iArg].split(':');
|
---|
128 | for s in self.asTests:
|
---|
129 | if s not in self.asTestsDef:
|
---|
130 | raise base.InvalidOption('The "--tests" value "%s" is not valid; valid values are: %s'
|
---|
131 | % (s, ' '.join(self.asTestsDef),));
|
---|
132 |
|
---|
133 | elif asArgs[iArg] == '--quick':
|
---|
134 | self.parseOption(['--virt-modes', 'hwvirt'], 0);
|
---|
135 | self.parseOption(['--cpu-counts', '1'], 0);
|
---|
136 |
|
---|
137 | else:
|
---|
138 | return vbox.TestDriver.parseOption(self, asArgs, iArg);
|
---|
139 | return iArg + 1;
|
---|
140 |
|
---|
141 | def getResourceSet(self):
|
---|
142 | if self.asRsrcs is None:
|
---|
143 | self.asRsrcs = []
|
---|
144 | for oSubTstDrv in self.aoSubTstDrvs:
|
---|
145 | self.asRsrcs.extend(oSubTstDrv.asRsrcs)
|
---|
146 | self.asRsrcs.extend(self.oTestVmSet.getResourceSet())
|
---|
147 | return self.asRsrcs
|
---|
148 |
|
---|
149 | def actionConfig(self):
|
---|
150 | if not self.importVBoxApi(): # So we can use the constant below.
|
---|
151 | return False;
|
---|
152 |
|
---|
153 | eNic0AttachType = vboxcon.NetworkAttachmentType_NAT;
|
---|
154 | sGaIso = self.getGuestAdditionsIso();
|
---|
155 |
|
---|
156 | # On 6.0 we merge the GAs with the ValidationKit so we can get at FsPerf.
|
---|
157 | # Note! Not possible to do a dboule import as both images an '/OS2' dir.
|
---|
158 | # So, using same dir as with unattended VISOs for the valkit.
|
---|
159 | if self.fpApiVer >= 6.0 and 'sharedfolders' in self.asTests:
|
---|
160 | sGaViso = os.path.join(self.sScratchPath, 'AdditionsAndValKit.viso');
|
---|
161 | ## @todo encode as bash cmd line:
|
---|
162 | sVisoContent = '--iprt-iso-maker-file-marker-bourne-sh %s ' \
|
---|
163 | '--import-iso \'%s\' ' \
|
---|
164 | '--push-iso \'%s\' ' \
|
---|
165 | '/vboxvalidationkit=/ ' \
|
---|
166 | '--pop ' \
|
---|
167 | % (uuid.uuid4(), sGaIso, self.sVBoxValidationKitIso);
|
---|
168 | reporter.log2('Using VISO combining GAs and ValKit "%s": %s' % (sGaViso, sVisoContent));
|
---|
169 | oGaViso = open(sGaViso, 'w');
|
---|
170 | oGaViso.write(sVisoContent);
|
---|
171 | oGaViso.close();
|
---|
172 | sGaIso = sGaViso;
|
---|
173 |
|
---|
174 | return self.oTestVmSet.actionConfig(self, eNic0AttachType = eNic0AttachType, sDvdImage = sGaIso);
|
---|
175 |
|
---|
176 | def actionExecute(self):
|
---|
177 | return self.oTestVmSet.actionExecute(self, self.testOneCfg);
|
---|
178 |
|
---|
179 |
|
---|
180 | #
|
---|
181 | # Test execution helpers.
|
---|
182 | #
|
---|
183 |
|
---|
184 | def testOneCfg(self, oVM, oTestVm):
|
---|
185 | """
|
---|
186 | Runs the specified VM thru the tests.
|
---|
187 |
|
---|
188 | Returns a success indicator on the general test execution. This is not
|
---|
189 | the actual test result.
|
---|
190 | """
|
---|
191 | fRc = False;
|
---|
192 |
|
---|
193 | if oTestVm.isWindows():
|
---|
194 | self.sFileCdWait = 'VBoxWindowsAdditions.exe';
|
---|
195 | elif oTestVm.isLinux():
|
---|
196 | self.sFileCdWait = 'VBoxLinuxAdditions.run';
|
---|
197 |
|
---|
198 | self.logVmInfo(oVM);
|
---|
199 | oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = True,
|
---|
200 | cMsCdWait = 5 * 60 * 1000,
|
---|
201 | sFileCdWait = self.sFileCdWait);
|
---|
202 | if oSession is not None:
|
---|
203 | self.addTask(oTxsSession);
|
---|
204 | # Do the testing.
|
---|
205 | fSkip = 'install' not in self.asTests;
|
---|
206 | reporter.testStart('Install');
|
---|
207 | if not fSkip:
|
---|
208 | fRc, oTxsSession = self.testInstallAdditions(oSession, oTxsSession, oTestVm);
|
---|
209 | reporter.testDone(fSkip);
|
---|
210 |
|
---|
211 | if not fSkip \
|
---|
212 | and not fRc:
|
---|
213 | reporter.log('Skipping following tests as Guest Additions were not installed successfully');
|
---|
214 | else:
|
---|
215 | fSkip = 'guestprops' not in self.asTests;
|
---|
216 | reporter.testStart('Guest Properties');
|
---|
217 | if not fSkip:
|
---|
218 | fRc = self.testGuestProperties(oSession, oTxsSession, oTestVm) and fRc;
|
---|
219 | reporter.testDone(fSkip);
|
---|
220 |
|
---|
221 | fSkip = 'guestcontrol' not in self.asTests;
|
---|
222 | reporter.testStart('Guest Control');
|
---|
223 | if not fSkip:
|
---|
224 | fRc, oTxsSession = self.aoSubTstDrvs[0].testIt(oTestVm, oSession, oTxsSession);
|
---|
225 | reporter.testDone(fSkip);
|
---|
226 |
|
---|
227 | fSkip = 'sharedfolders' not in self.asTests and self.fpApiVer >= 6.0;
|
---|
228 | reporter.testStart('Shared Folders');
|
---|
229 | if not fSkip:
|
---|
230 | fRc, oTxsSession = self.aoSubTstDrvs[1].testIt(oTestVm, oSession, oTxsSession);
|
---|
231 | reporter.testDone(fSkip or fRc is None);
|
---|
232 |
|
---|
233 | ## @todo Save and restore test.
|
---|
234 |
|
---|
235 | ## @todo Reset tests.
|
---|
236 |
|
---|
237 | ## @todo Final test: Uninstallation.
|
---|
238 |
|
---|
239 | # Cleanup.
|
---|
240 | self.removeTask(oTxsSession);
|
---|
241 | self.terminateVmBySession(oSession)
|
---|
242 | return fRc;
|
---|
243 |
|
---|
244 | def waitForGuestAdditionsRunLevel(self, oSession, oGuest, cMsTimeout, eRunLevel):
|
---|
245 | """
|
---|
246 | Waits for the Guest Additions to reach a specific run level.
|
---|
247 |
|
---|
248 | Returns success status.
|
---|
249 | """
|
---|
250 | # No need to wait as we already reached the run level?
|
---|
251 | eRunLevelCur = oGuest.additionsRunLevel;
|
---|
252 | if eRunLevelCur == eRunLevel:
|
---|
253 | reporter.log('Already reached run level %s' % eRunLevel);
|
---|
254 | return True;
|
---|
255 |
|
---|
256 | reporter.log('Waiting for Guest Additions to reach run level %s with %dms (current: %s) ...' %
|
---|
257 | (eRunLevel, cMsTimeout, eRunLevelCur));
|
---|
258 |
|
---|
259 | oConsoleCallbacks = oSession.registerDerivedEventHandler(tdAddBasicConsoleCallbacks, \
|
---|
260 | {'oTstDrv':self, 'oGuest':oGuest, });
|
---|
261 | fRc = False;
|
---|
262 | if oConsoleCallbacks is not None:
|
---|
263 | tsStart = base.timestampMilli();
|
---|
264 | while base.timestampMilli() - tsStart < cMsTimeout:
|
---|
265 | self.sleep(1); # Do some busy waiting.
|
---|
266 | if self.fGAStatusCallbackFired:
|
---|
267 | reporter.log('Reached new run level %s after %dms' %
|
---|
268 | (self.eGAStatusCallbackRunlevel, base.timestampMilli() - tsStart));
|
---|
269 | if eRunLevel == self.eGAStatusCallbackRunlevel:
|
---|
270 | fRc = True;
|
---|
271 | break;
|
---|
272 | self.fGAStatusCallbackFired = False;
|
---|
273 | if fRc:
|
---|
274 | reporter.log('Final Guest Additions run level reached after %dms' % (base.timestampMilli() - tsStart));
|
---|
275 | else:
|
---|
276 | reporter.error('Guest Additions run level not reached');
|
---|
277 |
|
---|
278 | # cleanup.
|
---|
279 | oConsoleCallbacks.unregister();
|
---|
280 | else:
|
---|
281 | reporter.error('Registering derived event handler failed');
|
---|
282 |
|
---|
283 | if not fRc:
|
---|
284 | reporter.log('Waiting for Guest Additions to reach run level %s failed' % (eRunLevel));
|
---|
285 | return fRc;
|
---|
286 |
|
---|
287 | def testInstallAdditions(self, oSession, oTxsSession, oTestVm):
|
---|
288 | """
|
---|
289 | Tests installing the guest additions
|
---|
290 | """
|
---|
291 | if oTestVm.isWindows():
|
---|
292 | (fRc, oTxsSession) = self.testWindowsInstallAdditions(oSession, oTxsSession, oTestVm);
|
---|
293 | elif oTestVm.isLinux():
|
---|
294 | (fRc, oTxsSession) = self.testLinuxInstallAdditions(oSession, oTxsSession, oTestVm);
|
---|
295 | else:
|
---|
296 | reporter.error('Guest Additions installation not implemented for %s yet! (%s)' %
|
---|
297 | (oTestVm.sKind, oTestVm.sVmName,));
|
---|
298 | fRc = False;
|
---|
299 |
|
---|
300 | #
|
---|
301 | # Verify installation of Guest Additions using commmon bits.
|
---|
302 | #
|
---|
303 | if fRc:
|
---|
304 | #
|
---|
305 | # Check if the additions are operational.
|
---|
306 | #
|
---|
307 | try: oGuest = oSession.o.console.guest;
|
---|
308 | except:
|
---|
309 | reporter.errorXcpt('Getting IGuest failed.');
|
---|
310 | return (False, oTxsSession);
|
---|
311 |
|
---|
312 | # Wait for the GAs to come up.
|
---|
313 | reporter.testStart('IGuest::additionsRunLevel');
|
---|
314 | fRc = self.testIGuest_additionsRunLevel(oSession, oTestVm, oGuest);
|
---|
315 | reporter.testDone();
|
---|
316 |
|
---|
317 | # Check the additionsVersion attribute. It must not be empty.
|
---|
318 | reporter.testStart('IGuest::additionsVersion');
|
---|
319 | fRc = self.testIGuest_additionsVersion(oGuest) and fRc;
|
---|
320 | reporter.testDone();
|
---|
321 |
|
---|
322 | # Check Guest Additions facilities
|
---|
323 | reporter.testStart('IGuest::getFacilityStatus');
|
---|
324 | fRc = self.testIGuest_getFacilityStatus(oTestVm, oGuest) and fRc;
|
---|
325 | reporter.testDone();
|
---|
326 |
|
---|
327 | # Do a bit of diagnosis on error.
|
---|
328 | if not fRc:
|
---|
329 | if oTestVm.isLinux():
|
---|
330 | reporter.log('Boot log:');
|
---|
331 | oTxsSession.syncExec('/bin/journalctl', ('/bin/journalctl', '-b'), fIgnoreErrors = True);
|
---|
332 | reporter.log('Loaded processes:');
|
---|
333 | oTxsSession.syncExec('/bin/ps', ('/bin/ps', '-a', '-u', '-x'), fIgnoreErrors = True);
|
---|
334 | reporter.log('Kernel messages:');
|
---|
335 | oTxsSession.syncExec('/bin/dmesg', ('/bin/dmesg'), fIgnoreErrors = True);
|
---|
336 | reporter.log('Loaded modules:');
|
---|
337 | oTxsSession.syncExec('/sbin/lsmod', ('/sbin/lsmod'), fIgnoreErrors = True);
|
---|
338 |
|
---|
339 | return (fRc, oTxsSession);
|
---|
340 |
|
---|
341 | def testWindowsInstallAdditions(self, oSession, oTxsSession, oTestVm):
|
---|
342 | """
|
---|
343 | Installs the Windows guest additions using the test execution service.
|
---|
344 | Since this involves rebooting the guest, we will have to create a new TXS session.
|
---|
345 | """
|
---|
346 |
|
---|
347 | #
|
---|
348 | # Install the public signing key.
|
---|
349 | #
|
---|
350 | if oTestVm.sKind not in ('WindowsNT4', 'Windows2000', 'WindowsXP', 'Windows2003'):
|
---|
351 | fRc = self.txsRunTest(oTxsSession, 'VBoxCertUtil.exe', 1 * 60 * 1000, '${CDROM}/cert/VBoxCertUtil.exe',
|
---|
352 | ('${CDROM}/cert/VBoxCertUtil.exe', 'add-trusted-publisher', '${CDROM}/cert/vbox-sha1.cer'),
|
---|
353 | fCheckSessionStatus = True);
|
---|
354 | if not fRc:
|
---|
355 | reporter.error('Error installing SHA1 certificate');
|
---|
356 | else:
|
---|
357 | fRc = self.txsRunTest(oTxsSession, 'VBoxCertUtil.exe', 1 * 60 * 1000, '${CDROM}/cert/VBoxCertUtil.exe',
|
---|
358 | ('${CDROM}/cert/VBoxCertUtil.exe', 'add-trusted-publisher',
|
---|
359 | '${CDROM}/cert/vbox-sha256.cer'), fCheckSessionStatus = True);
|
---|
360 | if not fRc:
|
---|
361 | reporter.error('Error installing SHA256 certificate');
|
---|
362 |
|
---|
363 | #
|
---|
364 | # Delete relevant log files.
|
---|
365 | #
|
---|
366 | # Note! On some guests the files in question still can be locked by the OS, so ignore
|
---|
367 | # deletion errors from the guest side (e.g. sharing violations) and just continue.
|
---|
368 | #
|
---|
369 | asLogFiles = [];
|
---|
370 | fHaveSetupApiDevLog = False;
|
---|
371 | if oTestVm.sKind in ('WindowsNT4',):
|
---|
372 | sWinDir = 'C:/WinNT/';
|
---|
373 | else:
|
---|
374 | sWinDir = 'C:/Windows/';
|
---|
375 | asLogFiles = [sWinDir + 'setupapi.log', sWinDir + 'setupact.log', sWinDir + 'setuperr.log'];
|
---|
376 |
|
---|
377 | # Apply The SetupAPI logging level so that we also get the (most verbose) setupapi.dev.log file.
|
---|
378 | ## @todo !!! HACK ALERT !!! Add the value directly into the testing source image. Later.
|
---|
379 | fHaveSetupApiDevLog = self.txsRunTest(oTxsSession, 'Enabling setupapi.dev.log', 30 * 1000,
|
---|
380 | 'c:\\Windows\\System32\\reg.exe',
|
---|
381 | ('c:\\Windows\\System32\\reg.exe', 'add',
|
---|
382 | '"HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Setup"',
|
---|
383 | '/v', 'LogLevel', '/t', 'REG_DWORD', '/d', '0xFF'),
|
---|
384 | fCheckSessionStatus = True);
|
---|
385 |
|
---|
386 | for sFile in asLogFiles:
|
---|
387 | self.txsRmFile(oSession, oTxsSession, sFile, 10 * 1000, fIgnoreErrors = True);
|
---|
388 |
|
---|
389 | #
|
---|
390 | # The actual install.
|
---|
391 | # Enable installing the optional auto-logon modules (VBoxGINA/VBoxCredProv).
|
---|
392 | # Also tell the installer to produce the appropriate log files.
|
---|
393 | #
|
---|
394 | fRc = self.txsRunTest(oTxsSession, 'VBoxWindowsAdditions.exe', 5 * 60 * 1000, '${CDROM}/VBoxWindowsAdditions.exe',
|
---|
395 | ('${CDROM}/VBoxWindowsAdditions.exe', '/S', '/l', '/with_autologon'), fCheckSessionStatus = True);
|
---|
396 |
|
---|
397 | # Add the Windows Guest Additions installer files to the files we want to download
|
---|
398 | # from the guest.
|
---|
399 | sGuestAddsDir = 'C:/Program Files/Oracle/VirtualBox Guest Additions/';
|
---|
400 | asLogFiles.append(sGuestAddsDir + 'install.log');
|
---|
401 | # Note: There won't be a install_ui.log because of the silent installation.
|
---|
402 | asLogFiles.append(sGuestAddsDir + 'install_drivers.log');
|
---|
403 | asLogFiles.append('C:/Windows/setupapi.log');
|
---|
404 |
|
---|
405 | # Note: setupapi.dev.log only is available since Windows 2000.
|
---|
406 | if fHaveSetupApiDevLog:
|
---|
407 | asLogFiles.append('C:/Windows/setupapi.dev.log');
|
---|
408 |
|
---|
409 | #
|
---|
410 | # Download log files.
|
---|
411 | # Ignore errors as all files above might not be present (or in different locations)
|
---|
412 | # on different Windows guests.
|
---|
413 | #
|
---|
414 | self.txsDownloadFiles(oSession, oTxsSession, asLogFiles, fIgnoreErrors = True);
|
---|
415 |
|
---|
416 | #
|
---|
417 | # Reboot the VM and reconnect the TXS session.
|
---|
418 | #
|
---|
419 | if fRc:
|
---|
420 | reporter.testStart('Rebooting guest w/ updated Guest Additions active');
|
---|
421 | (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
|
---|
422 | if fRc:
|
---|
423 | pass;
|
---|
424 | else:
|
---|
425 | reporter.testFailure('Rebooting and reconnecting to TXS service failed');
|
---|
426 | reporter.testDone();
|
---|
427 | else:
|
---|
428 | reporter.error('Error installing Windows Guest Additions (installer returned with exit code <> 0)')
|
---|
429 |
|
---|
430 | return (fRc, oTxsSession);
|
---|
431 |
|
---|
432 | def getAdditionsInstallerResult(self, oTxsSession):
|
---|
433 | """
|
---|
434 | Extracts the Guest Additions installer exit code from a run before.
|
---|
435 | Assumes that nothing else has been run on the same TXS session in the meantime.
|
---|
436 | """
|
---|
437 | iRc = 0;
|
---|
438 | (_, sOpcode, abPayload) = oTxsSession.getLastReply();
|
---|
439 | if sOpcode.startswith('PROC NOK '): # Extract process rc
|
---|
440 | iRc = abPayload[0]; # ASSUMES 8-bit rc for now.
|
---|
441 | ## @todo Parse more statuses here.
|
---|
442 | return iRc;
|
---|
443 |
|
---|
444 | def testLinuxInstallAdditions(self, oSession, oTxsSession, oTestVm):
|
---|
445 | _ = oSession;
|
---|
446 | _ = oTestVm;
|
---|
447 |
|
---|
448 | fRc = False;
|
---|
449 |
|
---|
450 | #
|
---|
451 | # The actual install.
|
---|
452 | # Also tell the installer to produce the appropriate log files.
|
---|
453 | #
|
---|
454 | # Make sure to add "--nox11" to the makeself wrapper in order to not getting any blocking
|
---|
455 | # xterm window spawned.
|
---|
456 | fRc = self.txsRunTest(oTxsSession, 'VBoxLinuxAdditions.run', 30 * 60 * 1000,
|
---|
457 | '/bin/sh', ('/bin/sh', '${CDROM}/VBoxLinuxAdditions.run', '--nox11'));
|
---|
458 | if not fRc:
|
---|
459 | iRc = self.getAdditionsInstallerResult(oTxsSession);
|
---|
460 | # Check for rc == 0 just for completeness.
|
---|
461 | if iRc in (0, 2): # Can happen if the GA installer has detected older VBox kernel modules running and needs a reboot.
|
---|
462 | reporter.log('Guest has old(er) VBox kernel modules still running; requires a reboot');
|
---|
463 | fRc = True;
|
---|
464 |
|
---|
465 | if not fRc:
|
---|
466 | reporter.error('Installing Linux Additions failed (isSuccess=%s, lastReply=%s, see log file for details)'
|
---|
467 | % (oTxsSession.isSuccess(), oTxsSession.getLastReply()));
|
---|
468 |
|
---|
469 | #
|
---|
470 | # Download log files.
|
---|
471 | # Ignore errors as all files above might not be present for whatever reason.
|
---|
472 | #
|
---|
473 | asLogFile = [];
|
---|
474 | asLogFile.append('/var/log/vboxadd-install.log');
|
---|
475 | self.txsDownloadFiles(oSession, oTxsSession, asLogFile, fIgnoreErrors = True);
|
---|
476 |
|
---|
477 | # Do the final reboot to get the just installed Guest Additions up and running.
|
---|
478 | if fRc:
|
---|
479 | reporter.testStart('Rebooting guest w/ updated Guest Additions active');
|
---|
480 | (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
|
---|
481 | if fRc:
|
---|
482 | pass
|
---|
483 | else:
|
---|
484 | reporter.testFailure('Rebooting and reconnecting to TXS service failed');
|
---|
485 | reporter.testDone();
|
---|
486 |
|
---|
487 | return (fRc, oTxsSession);
|
---|
488 |
|
---|
489 | def testIGuest_additionsRunLevel(self, oSession, oTestVm, oGuest):
|
---|
490 | """
|
---|
491 | Do run level tests.
|
---|
492 | """
|
---|
493 | if oTestVm.isWindows():
|
---|
494 | if oTestVm.isLoggedOntoDesktop():
|
---|
495 | eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Desktop;
|
---|
496 | else:
|
---|
497 | eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
|
---|
498 | else:
|
---|
499 | ## @todo VBoxClient does not have facility statuses implemented yet.
|
---|
500 | eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
|
---|
501 |
|
---|
502 | return self.waitForGuestAdditionsRunLevel(oSession, oGuest, 60 * 1000, eExpectedRunLevel);
|
---|
503 |
|
---|
504 | def testIGuest_additionsVersion(self, oGuest):
|
---|
505 | """
|
---|
506 | Returns False if no version string could be obtained, otherwise True
|
---|
507 | even though errors are logged.
|
---|
508 | """
|
---|
509 | try:
|
---|
510 | sVer = oGuest.additionsVersion;
|
---|
511 | except:
|
---|
512 | reporter.errorXcpt('Getting the additions version failed.');
|
---|
513 | return False;
|
---|
514 | reporter.log('IGuest::additionsVersion="%s"' % (sVer,));
|
---|
515 |
|
---|
516 | if sVer.strip() == '':
|
---|
517 | reporter.error('IGuest::additionsVersion is empty.');
|
---|
518 | return False;
|
---|
519 |
|
---|
520 | if sVer != sVer.strip():
|
---|
521 | reporter.error('IGuest::additionsVersion is contains spaces: "%s".' % (sVer,));
|
---|
522 |
|
---|
523 | asBits = sVer.split('.');
|
---|
524 | if len(asBits) < 3:
|
---|
525 | reporter.error('IGuest::additionsVersion does not contain at least tree dot separated fields: "%s" (%d).'
|
---|
526 | % (sVer, len(asBits)));
|
---|
527 |
|
---|
528 | ## @todo verify the format.
|
---|
529 | return True;
|
---|
530 |
|
---|
531 | def checkFacilityStatus(self, oGuest, eFacilityType, sDesc, fMustSucceed = True):
|
---|
532 | """
|
---|
533 | Prints the current status of a Guest Additions facility.
|
---|
534 |
|
---|
535 | Return success status.
|
---|
536 | """
|
---|
537 |
|
---|
538 | fRc = True;
|
---|
539 |
|
---|
540 | try:
|
---|
541 | eStatus, _ = oGuest.getFacilityStatus(eFacilityType);
|
---|
542 | reporter.log3('%s -> %s' % (sDesc, eStatus,));
|
---|
543 | except:
|
---|
544 | if fMustSucceed:
|
---|
545 | reporter.errorXcpt('Getting facility status for %s failed' % (eFacilityType,));
|
---|
546 | fRc = False;
|
---|
547 | else:
|
---|
548 | if eStatus == vboxcon.AdditionsFacilityStatus_Inactive:
|
---|
549 | sStatus = "INACTIVE";
|
---|
550 | elif eStatus == vboxcon.AdditionsFacilityStatus_Paused:
|
---|
551 | sStatus = "PAUSED";
|
---|
552 | elif eStatus == vboxcon.AdditionsFacilityStatus_PreInit:
|
---|
553 | sStatus = "PREINIT";
|
---|
554 | elif eStatus == vboxcon.AdditionsFacilityStatus_Init:
|
---|
555 | sStatus = "INIT";
|
---|
556 | elif eStatus == vboxcon.AdditionsFacilityStatus_Active:
|
---|
557 | sStatus = "ACTIVE";
|
---|
558 | elif eStatus == vboxcon.AdditionsFacilityStatus_Terminating:
|
---|
559 | sStatus = "TERMINATING";
|
---|
560 | fRc = not fMustSucceed;
|
---|
561 | elif eStatus == vboxcon.AdditionsFacilityStatus_Terminated:
|
---|
562 | sStatus = "TERMINATED";
|
---|
563 | fRc = not fMustSucceed;
|
---|
564 | elif eStatus == vboxcon.AdditionsFacilityStatus_Failed:
|
---|
565 | sStatus = "FAILED";
|
---|
566 | fRc = not fMustSucceed;
|
---|
567 | else:
|
---|
568 | sStatus = "UNKNOWN";
|
---|
569 | fRc = not fMustSucceed;
|
---|
570 |
|
---|
571 | reporter.log('Guest Additions facility "%s": %s' % (sDesc, sStatus));
|
---|
572 | if fMustSucceed \
|
---|
573 | and not fRc:
|
---|
574 | reporter.error('Guest Additions facility "%s" did not report expected status (is "%s")' % (sDesc, sStatus));
|
---|
575 |
|
---|
576 | return fRc;
|
---|
577 |
|
---|
578 | def testIGuest_getFacilityStatus(self, oTestVm, oGuest):
|
---|
579 | """
|
---|
580 | Checks Guest Additions facilities for their status.
|
---|
581 |
|
---|
582 | Returns success status.
|
---|
583 | """
|
---|
584 |
|
---|
585 | reporter.testStart('Status VBoxGuest Driver');
|
---|
586 | fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxGuestDriver, "VBoxGuest Driver");
|
---|
587 | reporter.testDone();
|
---|
588 |
|
---|
589 | reporter.testStart('Status VBoxService');
|
---|
590 | fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxService, "VBoxService") and fRc;
|
---|
591 | reporter.testDone();
|
---|
592 |
|
---|
593 | if oTestVm.isWindows():
|
---|
594 | if oTestVm.isLoggedOntoDesktop():
|
---|
595 | ## @todo VBoxClient does not have facility statuses implemented yet.
|
---|
596 | reporter.testStart('Status VBoxTray / VBoxClient');
|
---|
597 | fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxTrayClient,
|
---|
598 | "VBoxTray / VBoxClient") and fRc;
|
---|
599 | reporter.testDone();
|
---|
600 | ## @todo Add more.
|
---|
601 |
|
---|
602 | return fRc;
|
---|
603 |
|
---|
604 | def testGuestProperties(self, oSession, oTxsSession, oTestVm):
|
---|
605 | """
|
---|
606 | Test guest properties.
|
---|
607 | """
|
---|
608 | _ = oSession; _ = oTxsSession; _ = oTestVm;
|
---|
609 | return True;
|
---|
610 |
|
---|
611 | if __name__ == '__main__':
|
---|
612 | sys.exit(tdAddBasic1().main(sys.argv));
|
---|