VirtualBox

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

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

Validation Kit/testdriver: Moved more path handling code to the testdriver base class to unify path handling more.

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