1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: tdAddBasic1.py 84970 2020-06-26 14:54:02Z 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: 84970 $"
|
---|
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 tests for VBox < 6.1 for now.
|
---|
178 | fVersionIgnored = self.fpApiVer <= 6.1;
|
---|
179 |
|
---|
180 | if fVersionIgnored:
|
---|
181 | reporter.log('Skipping tests because VBox version %s is ignored' % (self.fpApiVer,));
|
---|
182 | else:
|
---|
183 | reporter.testStart('Waiting for TXS');
|
---|
184 | if oTestVm.isWindows():
|
---|
185 | self.sFileCdWait = ('%s/VBoxWindowsAdditions.exe' % (self.sGstPathGaPrefix,));
|
---|
186 | elif oTestVm.isLinux():
|
---|
187 | self.sFileCdWait = ('%s/VBoxLinuxAdditions.run' % (self.sGstPathGaPrefix,));
|
---|
188 |
|
---|
189 | oSession, oTxsSession = self.startVmAndConnectToTxsViaTcp(oTestVm.sVmName, fCdWait = True,
|
---|
190 | cMsCdWait = 5 * 60 * 1000,
|
---|
191 | sFileCdWait = self.sFileCdWait);
|
---|
192 | reporter.testDone();
|
---|
193 |
|
---|
194 | # Certain Linux guests don't behave accordingly so that detecting the CD isn't working properly.
|
---|
195 | # So reboot those guests in the hope that it works finally.
|
---|
196 | ### @todo Needs investigation; probably only udev or something is broken there (?).
|
---|
197 | if oTestVm.isLinux():
|
---|
198 | reporter.testStart('Rebooting and reconnecting to TXS');
|
---|
199 | fRc, oTxsSession = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, fCdWait = True,
|
---|
200 | cMsCdWait = 5 * 60 * 1000,
|
---|
201 | sFileCdWait = self.sFileCdWait);
|
---|
202 | reporter.testDone();
|
---|
203 |
|
---|
204 | if oSession is not None:
|
---|
205 | self.addTask(oTxsSession);
|
---|
206 | # Do the testing.
|
---|
207 | fSkip = 'install' not in self.asTests;
|
---|
208 | reporter.testStart('Install');
|
---|
209 | if not fSkip:
|
---|
210 | fRc, oTxsSession = self.testInstallAdditions(oSession, oTxsSession, oTestVm);
|
---|
211 | reporter.testDone(fSkip);
|
---|
212 |
|
---|
213 | if not fSkip \
|
---|
214 | and not fRc:
|
---|
215 | reporter.log('Skipping following tests as Guest Additions were not installed successfully');
|
---|
216 | else:
|
---|
217 | fSkip = 'guestprops' not in self.asTests;
|
---|
218 | reporter.testStart('Guest Properties');
|
---|
219 | if not fSkip:
|
---|
220 | fRc = self.testGuestProperties(oSession, oTxsSession, oTestVm) and fRc;
|
---|
221 | reporter.testDone(fSkip);
|
---|
222 |
|
---|
223 | fSkip = 'guestcontrol' not in self.asTests;
|
---|
224 | reporter.testStart('Guest Control');
|
---|
225 | if not fSkip:
|
---|
226 | fRc, oTxsSession = self.aoSubTstDrvs[0].testIt(oTestVm, oSession, oTxsSession);
|
---|
227 | reporter.testDone(fSkip);
|
---|
228 |
|
---|
229 | fSkip = 'sharedfolders' not in self.asTests;
|
---|
230 | reporter.testStart('Shared Folders');
|
---|
231 | if not fSkip:
|
---|
232 | fRc, oTxsSession = self.aoSubTstDrvs[1].testIt(oTestVm, oSession, oTxsSession);
|
---|
233 | reporter.testDone(fSkip or fRc is None);
|
---|
234 |
|
---|
235 | ## @todo Save and restore test.
|
---|
236 |
|
---|
237 | ## @todo Reset tests.
|
---|
238 |
|
---|
239 | ## @todo Final test: Uninstallation.
|
---|
240 |
|
---|
241 | # Cleanup.
|
---|
242 | self.removeTask(oTxsSession);
|
---|
243 | self.terminateVmBySession(oSession);
|
---|
244 |
|
---|
245 | return fRc;
|
---|
246 |
|
---|
247 | def testInstallAdditions(self, oSession, oTxsSession, oTestVm):
|
---|
248 | """
|
---|
249 | Tests installing the guest additions
|
---|
250 | """
|
---|
251 | if oTestVm.isWindows():
|
---|
252 | (fRc, oTxsSession) = self.testWindowsInstallAdditions(oSession, oTxsSession, oTestVm);
|
---|
253 | elif oTestVm.isLinux():
|
---|
254 | (fRc, oTxsSession) = self.testLinuxInstallAdditions(oSession, oTxsSession, oTestVm);
|
---|
255 | else:
|
---|
256 | reporter.error('Guest Additions installation not implemented for %s yet! (%s)' %
|
---|
257 | (oTestVm.sKind, oTestVm.sVmName,));
|
---|
258 | fRc = False;
|
---|
259 |
|
---|
260 | #
|
---|
261 | # Verify installation of Guest Additions using commmon bits.
|
---|
262 | #
|
---|
263 | if fRc:
|
---|
264 | #
|
---|
265 | # Check if the additions are operational.
|
---|
266 | #
|
---|
267 | try: oGuest = oSession.o.console.guest;
|
---|
268 | except:
|
---|
269 | reporter.errorXcpt('Getting IGuest failed.');
|
---|
270 | return (False, oTxsSession);
|
---|
271 |
|
---|
272 | # Wait for the GAs to come up.
|
---|
273 | reporter.testStart('IGuest::additionsRunLevel');
|
---|
274 | fRc = self.testIGuest_additionsRunLevel(oSession, oTestVm, oGuest);
|
---|
275 | reporter.testDone();
|
---|
276 |
|
---|
277 | # Check the additionsVersion attribute. It must not be empty.
|
---|
278 | reporter.testStart('IGuest::additionsVersion');
|
---|
279 | fRc = self.testIGuest_additionsVersion(oGuest) and fRc;
|
---|
280 | reporter.testDone();
|
---|
281 |
|
---|
282 | # Check Guest Additions facilities
|
---|
283 | reporter.testStart('IGuest::getFacilityStatus');
|
---|
284 | fRc = self.testIGuest_getFacilityStatus(oTestVm, oGuest) and fRc;
|
---|
285 | reporter.testDone();
|
---|
286 |
|
---|
287 | # Do a bit of diagnosis on error.
|
---|
288 | if not fRc:
|
---|
289 | if oTestVm.isLinux():
|
---|
290 | reporter.log('Boot log:');
|
---|
291 | sCmdJournalCtl = oTestVm.pathJoin(self.getGuestSystemDir(oTestVm), 'journalctl');
|
---|
292 | oTxsSession.syncExec(sCmdJournalCtl, (sCmdJournalCtl, '-b'), fIgnoreErrors = True);
|
---|
293 | reporter.log('Loaded processes:');
|
---|
294 | sCmdPs = oTestVm.pathJoin(self.getGuestSystemDir(oTestVm), 'ps');
|
---|
295 | oTxsSession.syncExec(sCmdPs, (sCmdPs, '-a', '-u', '-x'), fIgnoreErrors = True);
|
---|
296 | reporter.log('Kernel messages:');
|
---|
297 | sCmdDmesg = oTestVm.pathJoin(self.getGuestSystemDir(oTestVm), 'dmesg');
|
---|
298 | oTxsSession.syncExec(sCmdDmesg, (sCmdDmesg), fIgnoreErrors = True);
|
---|
299 | reporter.log('Loaded modules:');
|
---|
300 | sCmdLsMod = oTestVm.pathJoin(self.getGuestSystemAdminDir(oTestVm), 'lsmod');
|
---|
301 | oTxsSession.syncExec(sCmdLsMod, (sCmdLsMod), fIgnoreErrors = True);
|
---|
302 | elif oTestVm.isWindows() or oTestVm.isOS2():
|
---|
303 | sShell = self.getGuestSystemShell(oTestVm);
|
---|
304 | sShellOpt = '/C' if oTestVm.isWindows() or oTestVm.isOS2() else '-c';
|
---|
305 | reporter.log('Loaded processes:');
|
---|
306 | oTxsSession.syncExec(sShell, (sShell, sShellOpt, "tasklist.exe", "/FO", "CSV"), fIgnoreErrors = True);
|
---|
307 | reporter.log('Listing autostart entries:');
|
---|
308 | oTxsSession.syncExec(sShell, (sShell, sShellOpt, "wmic.exe", "startup", "get"), fIgnoreErrors = True);
|
---|
309 | reporter.log('Listing autostart entries:');
|
---|
310 | oTxsSession.syncExec(sShell, (sShell, sShellOpt, "dir",
|
---|
311 | oTestVm.pathJoin(self.getGuestSystemDir(oTestVm), 'VBox*')),
|
---|
312 | fIgnoreErrors = True);
|
---|
313 | reporter.log('Downloading logs ...');
|
---|
314 | self.txsDownloadFiles(oSession, oTxsSession,
|
---|
315 | [ ( self.getGuestVBoxTrayClientLogFile(oTestVm),
|
---|
316 | 'ga-vboxtrayclient-%s.log' % (oTestVm.sVmName,),),
|
---|
317 | ( "C:\\Documents and Settings\\All Users\\Application Data\\Microsoft\\Dr Watson\\drwtsn32.log",
|
---|
318 | 'ga-drwatson-%s.log' % (oTestVm.sVmName,), ),
|
---|
319 | ],
|
---|
320 | fIgnoreErrors = True);
|
---|
321 |
|
---|
322 | return (fRc, oTxsSession);
|
---|
323 |
|
---|
324 | def getGuestVBoxTrayClientLogFile(self, oTestVm):
|
---|
325 | """ Gets the path on the guest for the (release) log file of VBoxTray / VBoxClient. """
|
---|
326 | if oTestVm.isWindows():
|
---|
327 | return oTestVm.pathJoin(self.getGuestTempDir(oTestVm), 'VBoxTray.log');
|
---|
328 |
|
---|
329 | return oTestVm.pathJoin(self.getGuestTempDir(oTestVm), 'VBoxClient.log');
|
---|
330 |
|
---|
331 | def setGuestEnvVar(self, oSession, oTxsSession, oTestVm, sName, sValue):
|
---|
332 | """ Sets a system-wide environment variable on the guest. Only supports Windows guests so far. """
|
---|
333 | _ = oSession;
|
---|
334 | if oTestVm.isWindows():
|
---|
335 | sPathRegExe = oTestVm.pathJoin(self.getGuestSystemDir(oTestVm), 'reg.exe');
|
---|
336 | self.txsRunTest(oTxsSession, ('Set env var \"%s\"' % (sName,)),
|
---|
337 | 30 * 1000, sPathRegExe,
|
---|
338 | (sPathRegExe, 'add',
|
---|
339 | '"HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"', '/v',
|
---|
340 | sName, '/t', 'REG_EXPAND_SZ', '/d', sValue, '/f'));
|
---|
341 |
|
---|
342 | def testWindowsInstallAdditions(self, oSession, oTxsSession, oTestVm):
|
---|
343 | """
|
---|
344 | Installs the Windows guest additions using the test execution service.
|
---|
345 | Since this involves rebooting the guest, we will have to create a new TXS session.
|
---|
346 | """
|
---|
347 |
|
---|
348 | # Set system-wide env vars to enable release logging on some applications.
|
---|
349 | self.setGuestEnvVar(oSession, oTxsSession, oTestVm, 'VBOXTRAY_RELEASE_LOG', 'all.e.l.l2.l3.f');
|
---|
350 | self.setGuestEnvVar(oSession, oTxsSession, oTestVm, 'VBOXTRAY_RELEASE_LOG_FLAGS', 'time thread group append');
|
---|
351 | self.setGuestEnvVar(oSession, oTxsSession, oTestVm, 'VBOXTRAY_RELEASE_LOG_DEST',
|
---|
352 | ('file=%s' % (self.getGuestVBoxTrayClientLogFile(oTestVm),)));
|
---|
353 |
|
---|
354 | #
|
---|
355 | # Install the public signing key.
|
---|
356 | #
|
---|
357 | if oTestVm.sKind not in ('WindowsNT4', 'Windows2000', 'WindowsXP', 'Windows2003'):
|
---|
358 | fRc = self.txsRunTest(oTxsSession, 'VBoxCertUtil.exe', 1 * 60 * 1000,
|
---|
359 | '${CDROM}/%s/cert/VBoxCertUtil.exe' % self.sGstPathGaPrefix,
|
---|
360 | ('${CDROM}/%s/cert/VBoxCertUtil.exe' % self.sGstPathGaPrefix, 'add-trusted-publisher',
|
---|
361 | '${CDROM}/%s/cert/vbox-sha1.cer' % self.sGstPathGaPrefix),
|
---|
362 | fCheckSessionStatus = True);
|
---|
363 | if not fRc:
|
---|
364 | reporter.error('Error installing SHA1 certificate');
|
---|
365 | else:
|
---|
366 | fRc = self.txsRunTest(oTxsSession, 'VBoxCertUtil.exe', 1 * 60 * 1000,
|
---|
367 | '${CDROM}/%s/cert/VBoxCertUtil.exe' % self.sGstPathGaPrefix,
|
---|
368 | ('${CDROM}/%s/cert/VBoxCertUtil.exe' % self.sGstPathGaPrefix, 'add-trusted-publisher',
|
---|
369 | '${CDROM}/%s/cert/vbox-sha256.cer' % self.sGstPathGaPrefix), fCheckSessionStatus = True);
|
---|
370 | if not fRc:
|
---|
371 | reporter.error('Error installing SHA256 certificate');
|
---|
372 |
|
---|
373 | #
|
---|
374 | # Delete relevant log files.
|
---|
375 | #
|
---|
376 | # Note! On some guests the files in question still can be locked by the OS, so ignore
|
---|
377 | # deletion errors from the guest side (e.g. sharing violations) and just continue.
|
---|
378 | #
|
---|
379 | sWinDir = self.getGuestWinDir(oTestVm);
|
---|
380 | aasLogFiles = [
|
---|
381 | ( oTestVm.pathJoin(sWinDir, 'setupapi.log'), 'ga-setupapi-%s.log' % (oTestVm.sVmName,), ),
|
---|
382 | ( oTestVm.pathJoin(sWinDir, 'setupact.log'), 'ga-setupact-%s.log' % (oTestVm.sVmName,), ),
|
---|
383 | ( oTestVm.pathJoin(sWinDir, 'setuperr.log'), 'ga-setuperr-%s.log' % (oTestVm.sVmName,), ),
|
---|
384 | ];
|
---|
385 |
|
---|
386 | # Apply The SetupAPI logging level so that we also get the (most verbose) setupapi.dev.log file.
|
---|
387 | ## @todo !!! HACK ALERT !!! Add the value directly into the testing source image. Later.
|
---|
388 | sRegExe = oTestVm.pathJoin(self.getGuestSystemDir(oTestVm), 'reg.exe');
|
---|
389 | fHaveSetupApiDevLog = self.txsRunTest(oTxsSession, 'Enabling setupapi.dev.log', 30 * 1000,
|
---|
390 | sRegExe,
|
---|
391 | (sRegExe, 'add',
|
---|
392 | '"HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Setup"',
|
---|
393 | '/v', 'LogLevel', '/t', 'REG_DWORD', '/d', '0xFF'),
|
---|
394 | fCheckSessionStatus = True);
|
---|
395 |
|
---|
396 | for sGstFile, _ in aasLogFiles:
|
---|
397 | self.txsRmFile(oSession, oTxsSession, sGstFile, 10 * 1000, fIgnoreErrors = True);
|
---|
398 |
|
---|
399 | #
|
---|
400 | # The actual install.
|
---|
401 | # Enable installing the optional auto-logon modules (VBoxGINA/VBoxCredProv).
|
---|
402 | # Also tell the installer to produce the appropriate log files.
|
---|
403 | #
|
---|
404 | fRc = self.txsRunTest(oTxsSession, 'VBoxWindowsAdditions.exe', 5 * 60 * 1000,
|
---|
405 | '${CDROM}/%s/VBoxWindowsAdditions.exe' % self.sGstPathGaPrefix,
|
---|
406 | ('${CDROM}/%s/VBoxWindowsAdditions.exe' % self.sGstPathGaPrefix, '/S', '/l', '/with_autologon'),
|
---|
407 | fCheckSessionStatus = True);
|
---|
408 |
|
---|
409 | # Add the Windows Guest Additions installer files to the files we want to download
|
---|
410 | # from the guest. Note: There won't be a install_ui.log because of the silent installation.
|
---|
411 | sGuestAddsDir = 'C:\\Program Files\\Oracle\\VirtualBox Guest Additions\\';
|
---|
412 | aasLogFiles.append((sGuestAddsDir + 'install.log', 'ga-install-%s.log' % (oTestVm.sVmName,),));
|
---|
413 | aasLogFiles.append((sGuestAddsDir + 'install_drivers.log', 'ga-install_drivers-%s.log' % (oTestVm.sVmName,),));
|
---|
414 | aasLogFiles.append(('C:\\Windows\\setupapi.log', 'ga-setupapi-%s.log' % (oTestVm.sVmName,),));
|
---|
415 |
|
---|
416 | # Note: setupapi.dev.log only is available since Windows 2000.
|
---|
417 | if fHaveSetupApiDevLog:
|
---|
418 | aasLogFiles.append(('C:\\Windows\\setupapi.dev.log', 'ga-setupapi.dev-%s.log' % (oTestVm.sVmName,),));
|
---|
419 |
|
---|
420 | #
|
---|
421 | # Download log files.
|
---|
422 | # Ignore errors as all files above might not be present (or in different locations)
|
---|
423 | # on different Windows guests.
|
---|
424 | #
|
---|
425 | self.txsDownloadFiles(oSession, oTxsSession, aasLogFiles, fIgnoreErrors = True);
|
---|
426 |
|
---|
427 | #
|
---|
428 | # Reboot the VM and reconnect the TXS session.
|
---|
429 | #
|
---|
430 | if fRc:
|
---|
431 | reporter.testStart('Rebooting guest w/ updated Guest Additions active');
|
---|
432 | (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
|
---|
433 | if fRc:
|
---|
434 | pass;
|
---|
435 | else:
|
---|
436 | reporter.testFailure('Rebooting and reconnecting to TXS service failed');
|
---|
437 | reporter.testDone();
|
---|
438 | else:
|
---|
439 | reporter.error('Error installing Windows Guest Additions (installer returned with exit code <> 0)')
|
---|
440 |
|
---|
441 | return (fRc, oTxsSession);
|
---|
442 |
|
---|
443 | def getAdditionsInstallerResult(self, oTxsSession):
|
---|
444 | """
|
---|
445 | Extracts the Guest Additions installer exit code from a run before.
|
---|
446 | Assumes that nothing else has been run on the same TXS session in the meantime.
|
---|
447 | """
|
---|
448 | iRc = 0;
|
---|
449 | (_, sOpcode, abPayload) = oTxsSession.getLastReply();
|
---|
450 | if sOpcode.startswith('PROC NOK '): # Extract process rc
|
---|
451 | iRc = abPayload[0]; # ASSUMES 8-bit rc for now.
|
---|
452 | ## @todo Parse more statuses here.
|
---|
453 | return iRc;
|
---|
454 |
|
---|
455 | def testLinuxInstallAdditions(self, oSession, oTxsSession, oTestVm):
|
---|
456 | #
|
---|
457 | # The actual install.
|
---|
458 | # Also tell the installer to produce the appropriate log files.
|
---|
459 | #
|
---|
460 | # Make sure to add "--nox11" to the makeself wrapper in order to not getting any blocking
|
---|
461 | # xterm window spawned.
|
---|
462 | fRc = self.txsRunTest(oTxsSession, 'VBoxLinuxAdditions.run', 30 * 60 * 1000,
|
---|
463 | self.getGuestSystemShell(oTestVm),
|
---|
464 | (self.getGuestSystemShell(oTestVm),
|
---|
465 | '${CDROM}/%s/VBoxLinuxAdditions.run' % self.sGstPathGaPrefix, '--nox11'));
|
---|
466 | if not fRc:
|
---|
467 | iRc = self.getAdditionsInstallerResult(oTxsSession);
|
---|
468 | # Check for rc == 0 just for completeness.
|
---|
469 | if iRc in (0, 2): # Can happen if the GA installer has detected older VBox kernel modules running and needs a reboot.
|
---|
470 | reporter.log('Guest has old(er) VBox kernel modules still running; requires a reboot');
|
---|
471 | fRc = True;
|
---|
472 |
|
---|
473 | if not fRc:
|
---|
474 | reporter.error('Installing Linux Additions failed (isSuccess=%s, lastReply=%s, see log file for details)'
|
---|
475 | % (oTxsSession.isSuccess(), oTxsSession.getLastReply()));
|
---|
476 |
|
---|
477 | #
|
---|
478 | # Download log files.
|
---|
479 | # Ignore errors as all files above might not be present for whatever reason.
|
---|
480 | #
|
---|
481 | self.txsDownloadFiles(oSession, oTxsSession,
|
---|
482 | [('/var/log/vboxadd-install.log', 'vboxadd-install-%s.log' % oTestVm.sVmName), ],
|
---|
483 | fIgnoreErrors = True);
|
---|
484 |
|
---|
485 | # Do the final reboot to get the just installed Guest Additions up and running.
|
---|
486 | if fRc:
|
---|
487 | reporter.testStart('Rebooting guest w/ updated Guest Additions active');
|
---|
488 | (fRc, oTxsSession) = self.txsRebootAndReconnectViaTcp(oSession, oTxsSession, cMsTimeout = 15 * 60 * 1000);
|
---|
489 | if fRc:
|
---|
490 | pass
|
---|
491 | else:
|
---|
492 | reporter.testFailure('Rebooting and reconnecting to TXS service failed');
|
---|
493 | reporter.testDone();
|
---|
494 |
|
---|
495 | return (fRc, oTxsSession);
|
---|
496 |
|
---|
497 | def testIGuest_additionsRunLevel(self, oSession, oTestVm, oGuest):
|
---|
498 | """
|
---|
499 | Do run level tests.
|
---|
500 | """
|
---|
501 |
|
---|
502 | _ = oGuest;
|
---|
503 |
|
---|
504 | if oTestVm.isWindows():
|
---|
505 | if oTestVm.isLoggedOntoDesktop():
|
---|
506 | eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Desktop;
|
---|
507 | else:
|
---|
508 | eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
|
---|
509 | else:
|
---|
510 | ## @todo VBoxClient does not have facility statuses implemented yet.
|
---|
511 | eExpectedRunLevel = vboxcon.AdditionsRunLevelType_Userland;
|
---|
512 |
|
---|
513 | return self.waitForGAs(oSession, aenmWaitForRunLevels = [ eExpectedRunLevel ]);
|
---|
514 |
|
---|
515 | def testIGuest_additionsVersion(self, oGuest):
|
---|
516 | """
|
---|
517 | Returns False if no version string could be obtained, otherwise True
|
---|
518 | even though errors are logged.
|
---|
519 | """
|
---|
520 | try:
|
---|
521 | sVer = oGuest.additionsVersion;
|
---|
522 | except:
|
---|
523 | reporter.errorXcpt('Getting the additions version failed.');
|
---|
524 | return False;
|
---|
525 | reporter.log('IGuest::additionsVersion="%s"' % (sVer,));
|
---|
526 |
|
---|
527 | if sVer.strip() == '':
|
---|
528 | reporter.error('IGuest::additionsVersion is empty.');
|
---|
529 | return False;
|
---|
530 |
|
---|
531 | if sVer != sVer.strip():
|
---|
532 | reporter.error('IGuest::additionsVersion is contains spaces: "%s".' % (sVer,));
|
---|
533 |
|
---|
534 | asBits = sVer.split('.');
|
---|
535 | if len(asBits) < 3:
|
---|
536 | reporter.error('IGuest::additionsVersion does not contain at least tree dot separated fields: "%s" (%d).'
|
---|
537 | % (sVer, len(asBits)));
|
---|
538 |
|
---|
539 | ## @todo verify the format.
|
---|
540 | return True;
|
---|
541 |
|
---|
542 | def checkFacilityStatus(self, oGuest, eFacilityType, sDesc, fMustSucceed = True):
|
---|
543 | """
|
---|
544 | Prints the current status of a Guest Additions facility.
|
---|
545 |
|
---|
546 | Return success status.
|
---|
547 | """
|
---|
548 |
|
---|
549 | fRc = True;
|
---|
550 |
|
---|
551 | try:
|
---|
552 | eStatus, tsLastUpdatedMs = oGuest.getFacilityStatus(eFacilityType);
|
---|
553 | except:
|
---|
554 | if fMustSucceed:
|
---|
555 | reporter.errorXcpt('Getting facility status for "%s" failed' % (sDesc,));
|
---|
556 | fRc = False;
|
---|
557 | else:
|
---|
558 | if eStatus == vboxcon.AdditionsFacilityStatus_Inactive:
|
---|
559 | sStatus = "INACTIVE";
|
---|
560 | elif eStatus == vboxcon.AdditionsFacilityStatus_Paused:
|
---|
561 | sStatus = "PAUSED";
|
---|
562 | elif eStatus == vboxcon.AdditionsFacilityStatus_PreInit:
|
---|
563 | sStatus = "PREINIT";
|
---|
564 | elif eStatus == vboxcon.AdditionsFacilityStatus_Init:
|
---|
565 | sStatus = "INIT";
|
---|
566 | elif eStatus == vboxcon.AdditionsFacilityStatus_Active:
|
---|
567 | sStatus = "ACTIVE";
|
---|
568 | elif eStatus == vboxcon.AdditionsFacilityStatus_Terminating:
|
---|
569 | sStatus = "TERMINATING";
|
---|
570 | fRc = not fMustSucceed;
|
---|
571 | elif eStatus == vboxcon.AdditionsFacilityStatus_Terminated:
|
---|
572 | sStatus = "TERMINATED";
|
---|
573 | fRc = not fMustSucceed;
|
---|
574 | elif eStatus == vboxcon.AdditionsFacilityStatus_Failed:
|
---|
575 | sStatus = "FAILED";
|
---|
576 | fRc = not fMustSucceed;
|
---|
577 | elif eStatus == vboxcon.AdditionsFacilityStatus_Unknown:
|
---|
578 | sStatus = "UNKNOWN";
|
---|
579 | fRc = not fMustSucceed;
|
---|
580 | else:
|
---|
581 | sStatus = "???";
|
---|
582 | fRc = not fMustSucceed;
|
---|
583 |
|
---|
584 | reporter.log('Guest Additions facility "%s": %s (last updated: %sms)' % (sDesc, sStatus, str(tsLastUpdatedMs)));
|
---|
585 | if fMustSucceed \
|
---|
586 | and not fRc:
|
---|
587 | reporter.error('Guest Additions facility "%s" did not report expected status (is "%s")' % (sDesc, sStatus));
|
---|
588 |
|
---|
589 | return fRc;
|
---|
590 |
|
---|
591 | def testIGuest_getFacilityStatus(self, oTestVm, oGuest):
|
---|
592 | """
|
---|
593 | Checks Guest Additions facilities for their status.
|
---|
594 |
|
---|
595 | Returns success status.
|
---|
596 | """
|
---|
597 |
|
---|
598 | reporter.testStart('Status VBoxGuest Driver');
|
---|
599 | fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxGuestDriver, "VBoxGuest Driver");
|
---|
600 | reporter.testDone();
|
---|
601 |
|
---|
602 | reporter.testStart('Status VBoxService');
|
---|
603 | fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxService, "VBoxService") and fRc;
|
---|
604 | reporter.testDone();
|
---|
605 |
|
---|
606 | if oTestVm.isWindows():
|
---|
607 | if oTestVm.isLoggedOntoDesktop():
|
---|
608 | ## @todo VBoxClient does not have facility statuses implemented yet.
|
---|
609 | reporter.testStart('Status VBoxTray / VBoxClient');
|
---|
610 | fRc = self.checkFacilityStatus(oGuest, vboxcon.AdditionsFacilityType_VBoxTrayClient,
|
---|
611 | "VBoxTray / VBoxClient") and fRc;
|
---|
612 | reporter.testDone();
|
---|
613 | ## @todo Add more.
|
---|
614 |
|
---|
615 | return fRc;
|
---|
616 |
|
---|
617 | def testGuestProperties(self, oSession, oTxsSession, oTestVm):
|
---|
618 | """
|
---|
619 | Test guest properties.
|
---|
620 | """
|
---|
621 | _ = oSession; _ = oTxsSession; _ = oTestVm;
|
---|
622 | return True;
|
---|
623 |
|
---|
624 | if __name__ == '__main__':
|
---|
625 | sys.exit(tdAddBasic1().main(sys.argv));
|
---|