VirtualBox

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

Last change on this file since 95818 was 95776, checked in by vboxsync, 2 years ago

Validation Kit/tdAddBasic1.py: Automatically install the legacy timestamp CA for Windows guests. bugref:8691

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 29.3 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# $Id: tdAddBasic1.py 95776 2022-07-21 12:31:34Z 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: 95776 $"
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 # Enable installing the optional auto-logon modules (VBoxGINA/VBoxCredProv).
407 # Also tell the installer to produce the appropriate log files.
408 sExe = '${CDROM}/%s/VBoxWindowsAdditions.exe' % self.sGstPathGaPrefix;
409 asArgs = [ sExe, '/S', '/l', '/with_autologon' ];
410
411 # As we don't have a console command line to parse for the Guest Additions installer (only a message box) and
412 # unknown / unsupported parameters get ignored with silent installs anyway, we safely can add the following parameter(s)
413 # even if older Guest Addition installers might not support those.
414 if self.fpApiVer >= 6.1:
415 asArgs.extend([ '/install_timestamp_ca' ]);
416
417 #
418 # Do the actual install.
419 #
420 fRc = self.txsRunTest(oTxsSession, 'VBoxWindowsAdditions.exe', 5 * 60 * 1000,
421 sExe, asArgs, fCheckSessionStatus = True);
422
423 # Add the Windows Guest Additions installer files to the files we want to download
424 # from the guest. Note: There won't be a install_ui.log because of the silent installation.
425 sGuestAddsDir = 'C:\\Program Files\\Oracle\\VirtualBox Guest Additions\\';
426 aasLogFiles.append((sGuestAddsDir + 'install.log', 'ga-install-%s.log' % (oTestVm.sVmName,),));
427 aasLogFiles.append((sGuestAddsDir + 'install_drivers.log', 'ga-install_drivers-%s.log' % (oTestVm.sVmName,),));
428 aasLogFiles.append(('C:\\Windows\\setupapi.log', 'ga-setupapi-%s.log' % (oTestVm.sVmName,),));
429
430 # Note: setupapi.dev.log only is available since Windows 2000.
431 if fHaveSetupApiDevLog:
432 aasLogFiles.append(('C:\\Windows\\setupapi.dev.log', 'ga-setupapi.dev-%s.log' % (oTestVm.sVmName,),));
433
434 #
435 # Download log files.
436 # Ignore errors as all files above might not be present (or in different locations)
437 # on different Windows guests.
438 #
439 self.txsDownloadFiles(oSession, oTxsSession, aasLogFiles, fIgnoreErrors = True);
440
441 #
442 # Reboot the VM and reconnect the TXS session.
443 #
444 if fRc:
445 reporter.testStart('Rebooting guest w/ updated Guest Additions active');
446 (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
447 if fRc:
448 pass;
449 else:
450 reporter.testFailure('Rebooting and reconnecting to TXS service failed');
451 reporter.testDone();
452 else:
453 reporter.error('Error installing Windows Guest Additions (installer returned with exit code <> 0)')
454
455 return (fRc, oTxsSession);
456
457 def getAdditionsInstallerResult(self, oTxsSession):
458 """
459 Extracts the Guest Additions installer exit code from a run before.
460 Assumes that nothing else has been run on the same TXS session in the meantime.
461 """
462 iRc = 0;
463 (_, sOpcode, abPayload) = oTxsSession.getLastReply();
464 if sOpcode.startswith('PROC NOK '): # Extract process rc
465 iRc = abPayload[0]; # ASSUMES 8-bit rc for now.
466 ## @todo Parse more statuses here.
467 return iRc;
468
469 def testLinuxInstallAdditions(self, oSession, oTxsSession, oTestVm):
470 #
471 # The actual install.
472 # Also tell the installer to produce the appropriate log files.
473 #
474 # Make sure to add "--nox11" to the makeself wrapper in order to not getting any blocking
475 # xterm window spawned.
476 fRc = self.txsRunTest(oTxsSession, 'VBoxLinuxAdditions.run', 30 * 60 * 1000,
477 self.getGuestSystemShell(oTestVm),
478 (self.getGuestSystemShell(oTestVm),
479 '${CDROM}/%s/VBoxLinuxAdditions.run' % self.sGstPathGaPrefix, '--nox11'));
480 if not fRc:
481 iRc = self.getAdditionsInstallerResult(oTxsSession);
482 # Check for rc == 0 just for completeness.
483 if iRc in (0, 2): # Can happen if the GA installer has detected older VBox kernel modules running and needs a reboot.
484 reporter.log('Guest has old(er) VBox kernel modules still running; requires a reboot');
485 fRc = True;
486
487 if not fRc:
488 reporter.error('Installing Linux Additions failed (isSuccess=%s, lastReply=%s, see log file for details)'
489 % (oTxsSession.isSuccess(), oTxsSession.getLastReply()));
490
491 #
492 # Download log files.
493 # Ignore errors as all files above might not be present for whatever reason.
494 #
495 self.txsDownloadFiles(oSession, oTxsSession,
496 [('/var/log/vboxadd-install.log', 'vboxadd-install-%s.log' % oTestVm.sVmName), ],
497 fIgnoreErrors = True);
498
499 # Do the final reboot to get the just installed Guest Additions up and running.
500 if fRc:
501 reporter.testStart('Rebooting guest w/ updated Guest Additions active');
502 (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
503 if fRc:
504 pass
505 else:
506 reporter.testFailure('Rebooting and reconnecting to TXS service failed');
507 reporter.testDone();
508
509 return (fRc, oTxsSession);
510
511 def testIGuest_additionsRunLevel(self, oSession, oTestVm, oGuest):
512 """
513 Do run level tests.
514 """
515
516 _ = oGuest;
517
518 if oTestVm.isWindows():
519 if oTestVm.isLoggedOntoDesktop():
520 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Desktop;
521 else:
522 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
523 else:
524 ## @todo VBoxClient does not have facility statuses implemented yet.
525 eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
526
527 return self.waitForGAs(oSession, aenmWaitForRunLevels = [ eExpectedRunLevel ]);
528
529 def testIGuest_additionsVersion(self, oGuest):
530 """
531 Returns False if no version string could be obtained, otherwise True
532 even though errors are logged.
533 """
534 try:
535 sVer = oGuest.additionsVersion;
536 except:
537 reporter.errorXcpt('Getting the additions version failed.');
538 return False;
539 reporter.log('IGuest::additionsVersion="%s"' % (sVer,));
540
541 if sVer.strip() == '':
542 reporter.error('IGuest::additionsVersion is empty.');
543 return False;
544
545 if sVer != sVer.strip():
546 reporter.error('IGuest::additionsVersion is contains spaces: "%s".' % (sVer,));
547
548 asBits = sVer.split('.');
549 if len(asBits) < 3:
550 reporter.error('IGuest::additionsVersion does not contain at least tree dot separated fields: "%s" (%d).'
551 % (sVer, len(asBits)));
552
553 ## @todo verify the format.
554 return True;
555
556 def checkFacilityStatus(self, oGuest, eFacilityType, sDesc, fMustSucceed = True):
557 """
558 Prints the current status of a Guest Additions facility.
559
560 Return success status.
561 """
562
563 fRc = True;
564
565 try:
566 eStatus, tsLastUpdatedMs = oGuest.getFacilityStatus(eFacilityType);
567 except:
568 if fMustSucceed:
569 reporter.errorXcpt('Getting facility status for "%s" failed' % (sDesc,));
570 fRc = False;
571 else:
572 if eStatus == vboxcon.AdditionsFacilityStatus_Inactive:
573 sStatus = "INACTIVE";
574 elif eStatus == vboxcon.AdditionsFacilityStatus_Paused:
575 sStatus = "PAUSED";
576 elif eStatus == vboxcon.AdditionsFacilityStatus_PreInit:
577 sStatus = "PREINIT";
578 elif eStatus == vboxcon.AdditionsFacilityStatus_Init:
579 sStatus = "INIT";
580 elif eStatus == vboxcon.AdditionsFacilityStatus_Active:
581 sStatus = "ACTIVE";
582 elif eStatus == vboxcon.AdditionsFacilityStatus_Terminating:
583 sStatus = "TERMINATING";
584 fRc = not fMustSucceed;
585 elif eStatus == vboxcon.AdditionsFacilityStatus_Terminated:
586 sStatus = "TERMINATED";
587 fRc = not fMustSucceed;
588 elif eStatus == vboxcon.AdditionsFacilityStatus_Failed:
589 sStatus = "FAILED";
590 fRc = not fMustSucceed;
591 elif eStatus == vboxcon.AdditionsFacilityStatus_Unknown:
592 sStatus = "UNKNOWN";
593 fRc = not fMustSucceed;
594 else:
595 sStatus = "???";
596 fRc = not fMustSucceed;
597
598 reporter.log('Guest Additions facility "%s": %s (last updated: %sms)' % (sDesc, sStatus, str(tsLastUpdatedMs)));
599 if fMustSucceed \
600 and not fRc:
601 reporter.error('Guest Additions facility "%s" did not report expected status (is "%s")' % (sDesc, sStatus));
602
603 return fRc;
604
605 def testIGuest_getFacilityStatus(self, oTestVm, oGuest):
606 """
607 Checks Guest Additions facilities for their status.
608
609 Returns success status.
610 """
611
612 reporter.testStart('Status VBoxGuest Driver');
613 fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxGuestDriver, "VBoxGuest Driver");
614 reporter.testDone();
615
616 reporter.testStart('Status VBoxService');
617 fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxService, "VBoxService") and fRc;
618 reporter.testDone();
619
620 if oTestVm.isWindows():
621 if oTestVm.isLoggedOntoDesktop():
622 ## @todo VBoxClient does not have facility statuses implemented yet.
623 reporter.testStart('Status VBoxTray / VBoxClient');
624 fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxTrayClient,
625 "VBoxTray / VBoxClient") and fRc;
626 reporter.testDone();
627 ## @todo Add more.
628
629 return fRc;
630
631 def testGuestProperties(self, oSession, oTxsSession, oTestVm):
632 """
633 Test guest properties.
634 """
635 _ = oSession; _ = oTxsSession; _ = oTestVm;
636 return True;
637
638if __name__ == '__main__':
639 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