VirtualBox

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

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

Validation Kit/tdAddGuestCtrl.py: Trying to fix the GA runlevel tests.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 25.8 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdAddBasic1.py 84668 2020-06-03 15:43:31Z 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: 84668 $"
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
314 return (fRc, oTxsSession);
315
316 def testWindowsInstallAdditions(self, oSession, oTxsSession, oTestVm):
317 """
318 Installs the Windows guest additions using the test execution service.
319 Since this involves rebooting the guest, we will have to create a new TXS session.
320 """
321
322 #
323 # Install the public signing key.
324 #
325 if oTestVm.sKind not in ('WindowsNT4', 'Windows2000', 'WindowsXP', 'Windows2003'):
326 fRc = self.txsRunTest(oTxsSession, 'VBoxCertUtil.exe', 1 * 60 * 1000, '${CDROM}/cert/VBoxCertUtil.exe',
327 ('${CDROM}/cert/VBoxCertUtil.exe', 'add-trusted-publisher', '${CDROM}/cert/vbox-sha1.cer'),
328 fCheckSessionStatus = True);
329 if not fRc:
330 reporter.error('Error installing SHA1 certificate');
331 else:
332 fRc = self.txsRunTest(oTxsSession, 'VBoxCertUtil.exe', 1 * 60 * 1000, '${CDROM}/cert/VBoxCertUtil.exe',
333 ('${CDROM}/cert/VBoxCertUtil.exe', 'add-trusted-publisher',
334 '${CDROM}/cert/vbox-sha256.cer'), fCheckSessionStatus = True);
335 if not fRc:
336 reporter.error('Error installing SHA256 certificate');
337
338 #
339 # Delete relevant log files.
340 #
341 # Note! On some guests the files in question still can be locked by the OS, so ignore
342 # deletion errors from the guest side (e.g. sharing violations) and just continue.
343 #
344 sWinDir = self.getGuestWinDir(oTestVm);
345 aasLogFiles = [
346 ( oTestVm.pathJoin(sWinDir, 'setupapi.log'), 'ga-setupapi-%s.log' % (oTestVm.sVmName,), ),
347 ( oTestVm.pathJoin(sWinDir, 'setupact.log'), 'ga-setupact-%s.log' % (oTestVm.sVmName,), ),
348 ( oTestVm.pathJoin(sWinDir, 'setuperr.log'), 'ga-setuperr-%s.log' % (oTestVm.sVmName,), ),
349 ];
350
351 # Apply The SetupAPI logging level so that we also get the (most verbose) setupapi.dev.log file.
352 ## @todo !!! HACK ALERT !!! Add the value directly into the testing source image. Later.
353 sRegExe = oTestVm.pathJoin(self.getGuestSystemDir(oTestVm), 'reg.exe');
354 fHaveSetupApiDevLog = self.txsRunTest(oTxsSession, 'Enabling setupapi.dev.log', 30 * 1000,
355 sRegExe,
356 (sRegExe, 'add',
357 '"HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Setup"',
358 '/v', 'LogLevel', '/t', 'REG_DWORD', '/d', '0xFF'),
359 fCheckSessionStatus = True);
360
361 for sGstFile, _ in aasLogFiles:
362 self.txsRmFile(oSession, oTxsSession, sGstFile, 10 * 1000, fIgnoreErrors = True);
363
364 #
365 # The actual install.
366 # Enable installing the optional auto-logon modules (VBoxGINA/VBoxCredProv).
367 # Also tell the installer to produce the appropriate log files.
368 #
369 fRc = self.txsRunTest(oTxsSession, 'VBoxWindowsAdditions.exe', 5 * 60 * 1000, '${CDROM}/VBoxWindowsAdditions.exe',
370 ('${CDROM}/VBoxWindowsAdditions.exe', '/S', '/l', '/with_autologon'), fCheckSessionStatus = True);
371
372 # Add the Windows Guest Additions installer files to the files we want to download
373 # from the guest. Note: There won't be a install_ui.log because of the silent installation.
374 sGuestAddsDir = 'C:\\Program Files\\Oracle\\VirtualBox Guest Additions\\';
375 aasLogFiles.append((sGuestAddsDir + 'install.log', 'ga-install-%s.log' % (oTestVm.sVmName,),));
376 aasLogFiles.append((sGuestAddsDir + 'install_drivers.log', 'ga-install_drivers-%s.log' % (oTestVm.sVmName,),));
377 aasLogFiles.append(('C:\\Windows\\setupapi.log', 'ga-setupapi-%s.log' % (oTestVm.sVmName,),));
378
379 # Note: setupapi.dev.log only is available since Windows 2000.
380 if fHaveSetupApiDevLog:
381 aasLogFiles.append(('C:\\Windows\\setupapi.dev.log', 'ga-setupapi.dev-%s.log' % (oTestVm.sVmName,),));
382
383 #
384 # Download log files.
385 # Ignore errors as all files above might not be present (or in different locations)
386 # on different Windows guests.
387 #
388 self.txsDownloadFiles(oSession, oTxsSession, aasLogFiles, fIgnoreErrors = True);
389
390 #
391 # Reboot the VM and reconnect the TXS session.
392 #
393 if fRc:
394 reporter.testStart('Rebooting guest w/ updated Guest Additions active');
395 (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
396 if fRc:
397 pass;
398 else:
399 reporter.testFailure('Rebooting and reconnecting to TXS service failed');
400 reporter.testDone();
401 else:
402 reporter.error('Error installing Windows Guest Additions (installer returned with exit code <> 0)')
403
404 return (fRc, oTxsSession);
405
406 def getAdditionsInstallerResult(self, oTxsSession):
407 """
408 Extracts the Guest Additions installer exit code from a run before.
409 Assumes that nothing else has been run on the same TXS session in the meantime.
410 """
411 iRc = 0;
412 (_, sOpcode, abPayload) = oTxsSession.getLastReply();
413 if sOpcode.startswith('PROC NOK '): # Extract process rc
414 iRc = abPayload[0]; # ASSUMES 8-bit rc for now.
415 ## @todo Parse more statuses here.
416 return iRc;
417
418 def testLinuxInstallAdditions(self, oSession, oTxsSession, oTestVm):
419 #
420 # The actual install.
421 # Also tell the installer to produce the appropriate log files.
422 #
423 # Make sure to add "--nox11" to the makeself wrapper in order to not getting any blocking
424 # xterm window spawned.
425 fRc = self.txsRunTest(oTxsSession, 'VBoxLinuxAdditions.run', 30 * 60 * 1000,
426 self.getGuestSystemShell(oTestVm),
427 (self.getGuestSystemShell(oTestVm), '${CDROM}/VBoxLinuxAdditions.run', '--nox11'));
428 if not fRc:
429 iRc = self.getAdditionsInstallerResult(oTxsSession);
430 # Check for rc == 0 just for completeness.
431 if iRc in (0, 2): # Can happen if the GA installer has detected older VBox kernel modules running and needs a reboot.
432 reporter.log('Guest has old(er) VBox kernel modules still running; requires a reboot');
433 fRc = True;
434
435 if not fRc:
436 reporter.error('Installing Linux Additions failed (isSuccess=%s, lastReply=%s, see log file for details)'
437 % (oTxsSession.isSuccess(), oTxsSession.getLastReply()));
438
439 #
440 # Download log files.
441 # Ignore errors as all files above might not be present for whatever reason.
442 #
443 self.txsDownloadFiles(oSession, oTxsSession,
444 [('/var/log/vboxadd-install.log', 'vboxadd-install-%s.log' % oTestVm.sName), ],
445 fIgnoreErrors = True);
446
447 # Do the final reboot to get the just installed Guest Additions up and running.
448 if fRc:
449 reporter.testStart('Rebooting guest w/ updated Guest Additions active');
450 (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
451 if fRc:
452 pass
453 else:
454 reporter.testFailure('Rebooting and reconnecting to TXS service failed');
455 reporter.testDone();
456
457 return (fRc, oTxsSession);
458
459 def testIGuest_additionsRunLevel(self, oSession, oTestVm, oGuest):
460 """
461 Do run level tests.
462 """
463
464 _ = oGuest;
465
466 if oTestVm.isWindows():
467 if oTestVm.isLoggedOntoDesktop():
468 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Desktop;
469 else:
470 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
471 else:
472 ## @todo VBoxClient does not have facility statuses implemented yet.
473 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
474
475 return self.waitForGAs(oSession, aenmWaitForRunLevels = [ eExpectedRunLevel ]);
476
477 def testIGuest_additionsVersion(self, oGuest):
478 """
479 Returns False if no version string could be obtained, otherwise True
480 even though errors are logged.
481 """
482 try:
483 sVer = oGuest.additionsVersion;
484 except:
485 reporter.errorXcpt('Getting the additions version failed.');
486 return False;
487 reporter.log('IGuest::additionsVersion="%s"' % (sVer,));
488
489 if sVer.strip() == '':
490 reporter.error('IGuest::additionsVersion is empty.');
491 return False;
492
493 if sVer != sVer.strip():
494 reporter.error('IGuest::additionsVersion is contains spaces: "%s".' % (sVer,));
495
496 asBits = sVer.split('.');
497 if len(asBits) < 3:
498 reporter.error('IGuest::additionsVersion does not contain at least tree dot separated fields: "%s" (%d).'
499 % (sVer, len(asBits)));
500
501 ## @todo verify the format.
502 return True;
503
504 def checkFacilityStatus(self, oGuest, eFacilityType, sDesc, fMustSucceed = True):
505 """
506 Prints the current status of a Guest Additions facility.
507
508 Return success status.
509 """
510
511 fRc = True;
512
513 try:
514 eStatus, tsLastUpdatedMs = oGuest.getFacilityStatus(eFacilityType);
515 except:
516 if fMustSucceed:
517 reporter.errorXcpt('Getting facility status for "%s" failed' % (sDesc,));
518 fRc = False;
519 else:
520 if eStatus == vboxcon.AdditionsFacilityStatus_Inactive:
521 sStatus = "INACTIVE";
522 elif eStatus == vboxcon.AdditionsFacilityStatus_Paused:
523 sStatus = "PAUSED";
524 elif eStatus == vboxcon.AdditionsFacilityStatus_PreInit:
525 sStatus = "PREINIT";
526 elif eStatus == vboxcon.AdditionsFacilityStatus_Init:
527 sStatus = "INIT";
528 elif eStatus == vboxcon.AdditionsFacilityStatus_Active:
529 sStatus = "ACTIVE";
530 elif eStatus == vboxcon.AdditionsFacilityStatus_Terminating:
531 sStatus = "TERMINATING";
532 fRc = not fMustSucceed;
533 elif eStatus == vboxcon.AdditionsFacilityStatus_Terminated:
534 sStatus = "TERMINATED";
535 fRc = not fMustSucceed;
536 elif eStatus == vboxcon.AdditionsFacilityStatus_Failed:
537 sStatus = "FAILED";
538 fRc = not fMustSucceed;
539 elif eStatus == vboxcon.AdditionsFacilityStatus_Unknown:
540 sStatus = "UNKNOWN";
541 fRc = not fMustSucceed;
542 else:
543 sStatus = "???";
544 fRc = not fMustSucceed;
545
546 reporter.log('Guest Additions facility "%s": %s (last updated: %sms)' % (sDesc, sStatus, str(tsLastUpdatedMs)));
547 if fMustSucceed \
548 and not fRc:
549 reporter.error('Guest Additions facility "%s" did not report expected status (is "%s")' % (sDesc, sStatus));
550
551 return fRc;
552
553 def testIGuest_getFacilityStatus(self, oTestVm, oGuest):
554 """
555 Checks Guest Additions facilities for their status.
556
557 Returns success status.
558 """
559
560 reporter.testStart('Status VBoxGuest Driver');
561 fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxGuestDriver, "VBoxGuest Driver");
562 reporter.testDone();
563
564 reporter.testStart('Status VBoxService');
565 fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxService, "VBoxService") and fRc;
566 reporter.testDone();
567
568 if oTestVm.isWindows():
569 if oTestVm.isLoggedOntoDesktop():
570 ## @todo VBoxClient does not have facility statuses implemented yet.
571 reporter.testStart('Status VBoxTray / VBoxClient');
572 fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxTrayClient,
573 "VBoxTray / VBoxClient") and fRc;
574 reporter.testDone();
575 ## @todo Add more.
576
577 return fRc;
578
579 def testGuestProperties(self, oSession, oTxsSession, oTestVm):
580 """
581 Test guest properties.
582 """
583 _ = oSession; _ = oTxsSession; _ = oTestVm;
584 return True;
585
586if __name__ == '__main__':
587 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