VirtualBox

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

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

Validation Kit/tdAddBasic1.py: Some more ugly code for udev monitoring.

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 27.5 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdAddBasic1.py 84428 2020-05-20 19:15:45Z 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: 84428 $"
31
32# Standard Python imports.
33import os;
34import sys;
35import uuid;
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;
52from tdAddSharedFolders1 import SubTstDrvAddSharedFolders1;
53
54
55
56class 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
87class 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
200 if oTestVm.isLinux():
201 reporter.testStart('Enabling udev logging ...');
202 oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = False,
203 cMsCdWait = 5 * 60 * 1000);
204 oTxsSession.syncExec("/bin/sed", ("/bin/sed", "-i", "'s/.*udev_log.*/udev_log=\"debug\"/'", "/etc/udev/udev.conf"),
205 fIgnoreErrors = True);
206 reporter.testDone();
207
208 reporter.testStart('Enabling udev monitoring ...');
209 sUdevMonitorServiceContent = \
210 '[Unit]\n' \
211 'Description=udev Monitoring\n' \
212 'DefaultDependencies=no\n' \
213 'Wants=systemd-udevd.service\n' \
214 'After=systemd-udevd-control.socket systemd-udevd-kernel.socket\n' \
215 'Before=sysinit.target systemd-udev-trigger.service\n' \
216 '[Service]\n' \
217 'Type=simple\n' \
218 'ExecStart=/usr/bin/sh -c "/usr/sbin/udevadm monitor --udev --env > /tmp/udev_monitor.log\n' \
219 '[Install]\n' \
220 'WantedBy=sysinit.target';
221 sUdevMonitorServiceFile = '/etc/systemd/system/systemd-udev-monitor.service';
222 oTxsSession.syncUploadString(sUdevMonitorServiceContent, sUdevMonitorServiceFile, 0o644);
223 oTxsSession.syncExec("/bin/systemctl", ("/bin/systemctl", "enable", "systemd-udev-monitor.service"),
224 fIgnoreErrors = True);
225 reporter.testDone();
226
227 reporter.testStart('Waiting for TXS + CD (%s)' % (self.sFileCdWait,));
228 if oTestVm.isLinux():
229 (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oTestVm.sVmName, fCdWait = True,
230 cMsCdWait = 5 * 60 * 1000,
231 sFileCdWait = self.sFileCdWait);
232 else:
233 oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = True,
234 cMsCdWait = 5 * 60 * 1000,
235 sFileCdWait = self.sFileCdWait);
236 reporter.testDone();
237
238 if oTestVm.isLinux():
239 asLogFiles = [ '/tmp/udev_monitor.log' ];
240 self.txsDownloadFiles(oSession, oTxsSession, asLogFiles, fIgnoreErrors = True);
241
242 if oSession is not None:
243 self.addTask(oTxsSession);
244 # Do the testing.
245 fSkip = 'install' not in self.asTests;
246 reporter.testStart('Install');
247 if not fSkip:
248 fRc, oTxsSession = self.testInstallAdditions(oSession, oTxsSession, oTestVm);
249 reporter.testDone(fSkip);
250
251 if not fSkip \
252 and not fRc:
253 reporter.log('Skipping following tests as Guest Additions were not installed successfully');
254 else:
255 fSkip = 'guestprops' not in self.asTests;
256 reporter.testStart('Guest Properties');
257 if not fSkip:
258 fRc = self.testGuestProperties(oSession, oTxsSession, oTestVm) and fRc;
259 reporter.testDone(fSkip);
260
261 fSkip = 'guestcontrol' not in self.asTests;
262 reporter.testStart('Guest Control');
263 if not fSkip:
264 fRc, oTxsSession = self.aoSubTstDrvs[0].testIt(oTestVm, oSession, oTxsSession);
265 reporter.testDone(fSkip);
266
267 fSkip = 'sharedfolders' not in self.asTests and self.fpApiVer >= 6.0;
268 reporter.testStart('Shared Folders');
269 if not fSkip:
270 fRc, oTxsSession = self.aoSubTstDrvs[1].testIt(oTestVm, oSession, oTxsSession);
271 reporter.testDone(fSkip or fRc is None);
272
273 ## @todo Save and restore test.
274
275 ## @todo Reset tests.
276
277 ## @todo Final test: Uninstallation.
278
279 # Cleanup.
280 self.removeTask(oTxsSession);
281 self.terminateVmBySession(oSession)
282 return fRc;
283
284 def waitForGuestAdditionsRunLevel(self, oSession, oGuest, cMsTimeout, eRunLevel):
285 """
286 Waits for the Guest Additions to reach a specific run level.
287
288 Returns success status.
289 """
290 # No need to wait as we already reached the run level?
291 eRunLevelCur = oGuest.additionsRunLevel;
292 if eRunLevelCur == eRunLevel:
293 reporter.log('Already reached run level %s' % eRunLevel);
294 return True;
295
296 reporter.log('Waiting for Guest Additions to reach run level %s with %dms (current: %s) ...' %
297 (eRunLevel, cMsTimeout, eRunLevelCur));
298
299 oConsoleCallbacks = oSession.registerDerivedEventHandler(tdAddBasicConsoleCallbacks, \
300 {'oTstDrv':self, 'oGuest':oGuest, });
301 fRc = False;
302 if oConsoleCallbacks is not None:
303 tsStart = base.timestampMilli();
304 while base.timestampMilli() - tsStart < cMsTimeout:
305 self.sleep(1); # Do some busy waiting.
306 if self.fGAStatusCallbackFired:
307 reporter.log('Reached new run level %s after %dms' %
308 (self.eGAStatusCallbackRunlevel, base.timestampMilli() - tsStart));
309 if eRunLevel == self.eGAStatusCallbackRunlevel:
310 fRc = True;
311 break;
312 self.fGAStatusCallbackFired = False;
313 if fRc:
314 reporter.log('Final Guest Additions run level reached after %dms' % (base.timestampMilli() - tsStart));
315 else:
316 reporter.error('Guest Additions run level not reached');
317
318 # cleanup.
319 oConsoleCallbacks.unregister();
320 else:
321 reporter.error('Registering derived event handler failed');
322
323 if not fRc:
324 reporter.log('Waiting for Guest Additions to reach run level %s failed' % (eRunLevel));
325 return fRc;
326
327 def testInstallAdditions(self, oSession, oTxsSession, oTestVm):
328 """
329 Tests installing the guest additions
330 """
331 if oTestVm.isWindows():
332 (fRc, oTxsSession) = self.testWindowsInstallAdditions(oSession, oTxsSession, oTestVm);
333 elif oTestVm.isLinux():
334 (fRc, oTxsSession) = self.testLinuxInstallAdditions(oSession, oTxsSession, oTestVm);
335 else:
336 reporter.error('Guest Additions installation not implemented for %s yet! (%s)' %
337 (oTestVm.sKind, oTestVm.sVmName,));
338 fRc = False;
339
340 #
341 # Verify installation of Guest Additions using commmon bits.
342 #
343 if fRc:
344 #
345 # Check if the additions are operational.
346 #
347 try: oGuest = oSession.o.console.guest;
348 except:
349 reporter.errorXcpt('Getting IGuest failed.');
350 return (False, oTxsSession);
351
352 # Wait for the GAs to come up.
353 reporter.testStart('IGuest::additionsRunLevel');
354 fRc = self.testIGuest_additionsRunLevel(oSession, oTestVm, oGuest);
355 reporter.testDone();
356
357 # Check the additionsVersion attribute. It must not be empty.
358 reporter.testStart('IGuest::additionsVersion');
359 fRc = self.testIGuest_additionsVersion(oGuest) and fRc;
360 reporter.testDone();
361
362 # Check Guest Additions facilities
363 reporter.testStart('IGuest::getFacilityStatus');
364 fRc = self.testIGuest_getFacilityStatus(oTestVm, oGuest) and fRc;
365 reporter.testDone();
366
367 # Do a bit of diagnosis on error.
368 if not fRc:
369 if oTestVm.isLinux():
370 reporter.log('Boot log:');
371 oTxsSession.syncExec('/bin/journalctl', ('/bin/journalctl', '-b'), fIgnoreErrors = True);
372 reporter.log('Loaded processes:');
373 oTxsSession.syncExec('/bin/ps', ('/bin/ps', '-a', '-u', '-x'), fIgnoreErrors = True);
374 reporter.log('Kernel messages:');
375 oTxsSession.syncExec('/bin/dmesg', ('/bin/dmesg'), fIgnoreErrors = True);
376 reporter.log('Loaded modules:');
377 oTxsSession.syncExec('/sbin/lsmod', ('/sbin/lsmod'), fIgnoreErrors = True);
378
379 return (fRc, oTxsSession);
380
381 def testWindowsInstallAdditions(self, oSession, oTxsSession, oTestVm):
382 """
383 Installs the Windows guest additions using the test execution service.
384 Since this involves rebooting the guest, we will have to create a new TXS session.
385 """
386
387 #
388 # Install the public signing key.
389 #
390 if oTestVm.sKind not in ('WindowsNT4', 'Windows2000', 'WindowsXP', 'Windows2003'):
391 fRc = self.txsRunTest(oTxsSession, 'VBoxCertUtil.exe', 1 * 60 * 1000, '${CDROM}/cert/VBoxCertUtil.exe',
392 ('${CDROM}/cert/VBoxCertUtil.exe', 'add-trusted-publisher', '${CDROM}/cert/vbox-sha1.cer'),
393 fCheckSessionStatus = True);
394 if not fRc:
395 reporter.error('Error installing SHA1 certificate');
396 else:
397 fRc = self.txsRunTest(oTxsSession, 'VBoxCertUtil.exe', 1 * 60 * 1000, '${CDROM}/cert/VBoxCertUtil.exe',
398 ('${CDROM}/cert/VBoxCertUtil.exe', 'add-trusted-publisher',
399 '${CDROM}/cert/vbox-sha256.cer'), fCheckSessionStatus = True);
400 if not fRc:
401 reporter.error('Error installing SHA256 certificate');
402
403 #
404 # Delete relevant log files.
405 #
406 # Note! On some guests the files in question still can be locked by the OS, so ignore
407 # deletion errors from the guest side (e.g. sharing violations) and just continue.
408 #
409 asLogFiles = [];
410 fHaveSetupApiDevLog = False;
411 if oTestVm.sKind in ('WindowsNT4',):
412 sWinDir = 'C:/WinNT/';
413 else:
414 sWinDir = 'C:/Windows/';
415 asLogFiles = [sWinDir + 'setupapi.log', sWinDir + 'setupact.log', sWinDir + 'setuperr.log'];
416
417 # Apply The SetupAPI logging level so that we also get the (most verbose) setupapi.dev.log file.
418 ## @todo !!! HACK ALERT !!! Add the value directly into the testing source image. Later.
419 fHaveSetupApiDevLog = self.txsRunTest(oTxsSession, 'Enabling setupapi.dev.log', 30 * 1000,
420 'c:\\Windows\\System32\\reg.exe',
421 ('c:\\Windows\\System32\\reg.exe', 'add',
422 '"HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Setup"',
423 '/v', 'LogLevel', '/t', 'REG_DWORD', '/d', '0xFF'),
424 fCheckSessionStatus = True);
425
426 for sFile in asLogFiles:
427 self.txsRmFile(oSession, oTxsSession, sFile, 10 * 1000, fIgnoreErrors = True);
428
429 #
430 # The actual install.
431 # Enable installing the optional auto-logon modules (VBoxGINA/VBoxCredProv).
432 # Also tell the installer to produce the appropriate log files.
433 #
434 fRc = self.txsRunTest(oTxsSession, 'VBoxWindowsAdditions.exe', 5 * 60 * 1000, '${CDROM}/VBoxWindowsAdditions.exe',
435 ('${CDROM}/VBoxWindowsAdditions.exe', '/S', '/l', '/with_autologon'), fCheckSessionStatus = True);
436
437 # Add the Windows Guest Additions installer files to the files we want to download
438 # from the guest.
439 sGuestAddsDir = 'C:/Program Files/Oracle/VirtualBox Guest Additions/';
440 asLogFiles.append(sGuestAddsDir + 'install.log');
441 # Note: There won't be a install_ui.log because of the silent installation.
442 asLogFiles.append(sGuestAddsDir + 'install_drivers.log');
443 asLogFiles.append('C:/Windows/setupapi.log');
444
445 # Note: setupapi.dev.log only is available since Windows 2000.
446 if fHaveSetupApiDevLog:
447 asLogFiles.append('C:/Windows/setupapi.dev.log');
448
449 #
450 # Download log files.
451 # Ignore errors as all files above might not be present (or in different locations)
452 # on different Windows guests.
453 #
454 self.txsDownloadFiles(oSession, oTxsSession, asLogFiles, fIgnoreErrors = True);
455
456 #
457 # Reboot the VM and reconnect the TXS session.
458 #
459 if fRc:
460 reporter.testStart('Rebooting guest w/ updated Guest Additions active');
461 (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
462 if fRc:
463 pass;
464 else:
465 reporter.testFailure('Rebooting and reconnecting to TXS service failed');
466 reporter.testDone();
467 else:
468 reporter.error('Error installing Windows Guest Additions (installer returned with exit code <> 0)')
469
470 return (fRc, oTxsSession);
471
472 def getAdditionsInstallerResult(self, oTxsSession):
473 """
474 Extracts the Guest Additions installer exit code from a run before.
475 Assumes that nothing else has been run on the same TXS session in the meantime.
476 """
477 iRc = 0;
478 (_, sOpcode, abPayload) = oTxsSession.getLastReply();
479 if sOpcode.startswith('PROC NOK '): # Extract process rc
480 iRc = abPayload[0]; # ASSUMES 8-bit rc for now.
481 ## @todo Parse more statuses here.
482 return iRc;
483
484 def testLinuxInstallAdditions(self, oSession, oTxsSession, oTestVm):
485 _ = oSession;
486 _ = oTestVm;
487
488 fRc = False;
489
490 #
491 # The actual install.
492 # Also tell the installer to produce the appropriate log files.
493 #
494 # Make sure to add "--nox11" to the makeself wrapper in order to not getting any blocking
495 # xterm window spawned.
496 fRc = self.txsRunTest(oTxsSession, 'VBoxLinuxAdditions.run', 30 * 60 * 1000,
497 '/bin/sh', ('/bin/sh', '${CDROM}/VBoxLinuxAdditions.run', '--nox11'));
498 if not fRc:
499 iRc = self.getAdditionsInstallerResult(oTxsSession);
500 # Check for rc == 0 just for completeness.
501 if iRc in (0, 2): # Can happen if the GA installer has detected older VBox kernel modules running and needs a reboot.
502 reporter.log('Guest has old(er) VBox kernel modules still running; requires a reboot');
503 fRc = True;
504
505 if not fRc:
506 reporter.error('Installing Linux Additions failed (isSuccess=%s, lastReply=%s, see log file for details)'
507 % (oTxsSession.isSuccess(), oTxsSession.getLastReply()));
508
509 #
510 # Download log files.
511 # Ignore errors as all files above might not be present for whatever reason.
512 #
513 asLogFile = [];
514 asLogFile.append('/var/log/vboxadd-install.log');
515 self.txsDownloadFiles(oSession, oTxsSession, asLogFile, fIgnoreErrors = True);
516
517 # Do the final reboot to get the just installed Guest Additions up and running.
518 if fRc:
519 reporter.testStart('Rebooting guest w/ updated Guest Additions active');
520 (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
521 if fRc:
522 pass
523 else:
524 reporter.testFailure('Rebooting and reconnecting to TXS service failed');
525 reporter.testDone();
526
527 return (fRc, oTxsSession);
528
529 def testIGuest_additionsRunLevel(self, oSession, oTestVm, oGuest):
530 """
531 Do run level tests.
532 """
533 if oTestVm.isWindows():
534 if oTestVm.isLoggedOntoDesktop():
535 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Desktop;
536 else:
537 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
538 else:
539 ## @todo VBoxClient does not have facility statuses implemented yet.
540 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
541
542 return self.waitForGuestAdditionsRunLevel(oSession, oGuest, 5 * 60 * 1000, eExpectedRunLevel);
543
544 def testIGuest_additionsVersion(self, oGuest):
545 """
546 Returns False if no version string could be obtained, otherwise True
547 even though errors are logged.
548 """
549 try:
550 sVer = oGuest.additionsVersion;
551 except:
552 reporter.errorXcpt('Getting the additions version failed.');
553 return False;
554 reporter.log('IGuest::additionsVersion="%s"' % (sVer,));
555
556 if sVer.strip() == '':
557 reporter.error('IGuest::additionsVersion is empty.');
558 return False;
559
560 if sVer != sVer.strip():
561 reporter.error('IGuest::additionsVersion is contains spaces: "%s".' % (sVer,));
562
563 asBits = sVer.split('.');
564 if len(asBits) < 3:
565 reporter.error('IGuest::additionsVersion does not contain at least tree dot separated fields: "%s" (%d).'
566 % (sVer, len(asBits)));
567
568 ## @todo verify the format.
569 return True;
570
571 def checkFacilityStatus(self, oGuest, eFacilityType, sDesc, fMustSucceed = True):
572 """
573 Prints the current status of a Guest Additions facility.
574
575 Return success status.
576 """
577
578 fRc = True;
579
580 try:
581 eStatus, _ = oGuest.getFacilityStatus(eFacilityType);
582 reporter.log3('%s -> %s' % (sDesc, eStatus,));
583 except:
584 if fMustSucceed:
585 reporter.errorXcpt('Getting facility status for %s failed' % (eFacilityType,));
586 fRc = False;
587 else:
588 if eStatus == vboxcon.AdditionsFacilityStatus_Inactive:
589 sStatus = "INACTIVE";
590 elif eStatus == vboxcon.AdditionsFacilityStatus_Paused:
591 sStatus = "PAUSED";
592 elif eStatus == vboxcon.AdditionsFacilityStatus_PreInit:
593 sStatus = "PREINIT";
594 elif eStatus == vboxcon.AdditionsFacilityStatus_Init:
595 sStatus = "INIT";
596 elif eStatus == vboxcon.AdditionsFacilityStatus_Active:
597 sStatus = "ACTIVE";
598 elif eStatus == vboxcon.AdditionsFacilityStatus_Terminating:
599 sStatus = "TERMINATING";
600 fRc = not fMustSucceed;
601 elif eStatus == vboxcon.AdditionsFacilityStatus_Terminated:
602 sStatus = "TERMINATED";
603 fRc = not fMustSucceed;
604 elif eStatus == vboxcon.AdditionsFacilityStatus_Failed:
605 sStatus = "FAILED";
606 fRc = not fMustSucceed;
607 else:
608 sStatus = "UNKNOWN";
609 fRc = not fMustSucceed;
610
611 reporter.log('Guest Additions facility "%s": %s' % (sDesc, sStatus));
612 if fMustSucceed \
613 and not fRc:
614 reporter.error('Guest Additions facility "%s" did not report expected status (is "%s")' % (sDesc, sStatus));
615
616 return fRc;
617
618 def testIGuest_getFacilityStatus(self, oTestVm, oGuest):
619 """
620 Checks Guest Additions facilities for their status.
621
622 Returns success status.
623 """
624
625 reporter.testStart('Status VBoxGuest Driver');
626 fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxGuestDriver, "VBoxGuest Driver");
627 reporter.testDone();
628
629 reporter.testStart('Status VBoxService');
630 fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxService, "VBoxService") and fRc;
631 reporter.testDone();
632
633 if oTestVm.isWindows():
634 if oTestVm.isLoggedOntoDesktop():
635 ## @todo VBoxClient does not have facility statuses implemented yet.
636 reporter.testStart('Status VBoxTray / VBoxClient');
637 fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxTrayClient,
638 "VBoxTray / VBoxClient") and fRc;
639 reporter.testDone();
640 ## @todo Add more.
641
642 return fRc;
643
644 def testGuestProperties(self, oSession, oTxsSession, oTestVm):
645 """
646 Test guest properties.
647 """
648 _ = oSession; _ = oTxsSession; _ = oTestVm;
649 return True;
650
651if __name__ == '__main__':
652 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