VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/tests/additions/tdAddBasic1.py@ 84684

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

Validation Kit/tdAddBasic1.py: Added more diagnostics to find out why VBoxTray sometimes simply doesn't appear to get started on certain Windows test boxes.

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