VirtualBox

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

Last change on this file since 98833 was 98833, checked in by vboxsync, 21 months ago

ValidationKit: tdAddBasic1: Add --no-reboot-after-install option for Additions which do not require guest reboot after installation, bugref:10359.

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