VirtualBox

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

Last change on this file since 94127 was 94127, checked in by vboxsync, 3 years ago

ValKit/tests: pylint 2.9.6 adjustments (mostly about using 'with' statements).

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