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