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