VirtualBox

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

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

Validation Kit/tdAddBasic1: Attempt to make TXS' updating mechanism work with using the combined VISO (GA + VaKit). Follow-up fix to r138600.

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