VirtualBox

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

Last change on this file since 84817 was 84817, checked in by vboxsync, 5 years ago

Validation Kit/tdAddBasic1: To trigger a new build.

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