VirtualBox

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

Last change on this file since 97865 was 97673, checked in by vboxsync, 2 years ago

Validation Kit: Fixed lots of warnings, based on pylint 2.12.2.

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