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