VirtualBox

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

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

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette