1 | #!/usr/bin/env python
|
---|
2 | # -*- coding: utf-8 -*-
|
---|
3 | # $Id: virtual_test_sheriff.py 71088 2018-02-21 16:37:40Z vboxsync $
|
---|
4 | # pylint: disable=C0301
|
---|
5 |
|
---|
6 | """
|
---|
7 | Virtual Test Sheriff.
|
---|
8 |
|
---|
9 | Duties:
|
---|
10 | - Try to a assign failure reasons to recently failed tests.
|
---|
11 | - Reboot or disable bad test boxes.
|
---|
12 |
|
---|
13 | """
|
---|
14 |
|
---|
15 | from __future__ import print_function;
|
---|
16 |
|
---|
17 | __copyright__ = \
|
---|
18 | """
|
---|
19 | Copyright (C) 2012-2017 Oracle Corporation
|
---|
20 |
|
---|
21 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
22 | available from http://www.virtualbox.org. This file is free software;
|
---|
23 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
24 | General Public License (GPL) as published by the Free Software
|
---|
25 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
26 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
27 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
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) only, as it comes in the "COPYING.CDDL" file of the
|
---|
32 | VirtualBox OSE 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 | __version__ = "$Revision: 71088 $"
|
---|
39 |
|
---|
40 |
|
---|
41 | # Standard python imports
|
---|
42 | import sys;
|
---|
43 | import os;
|
---|
44 | import hashlib;
|
---|
45 | if sys.version_info[0] >= 3:
|
---|
46 | from io import StringIO as StringIO; # pylint: disable=import-error,no-name-in-module
|
---|
47 | else:
|
---|
48 | from StringIO import StringIO as StringIO; # pylint: disable=import-error,no-name-in-module
|
---|
49 | from optparse import OptionParser; # pylint: disable=deprecated-module
|
---|
50 | from PIL import Image; # pylint: disable=import-error
|
---|
51 |
|
---|
52 | # Add Test Manager's modules path
|
---|
53 | g_ksTestManagerDir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))));
|
---|
54 | sys.path.append(g_ksTestManagerDir);
|
---|
55 |
|
---|
56 | # Test Manager imports
|
---|
57 | from testmanager.core.db import TMDatabaseConnection;
|
---|
58 | from testmanager.core.build import BuildDataEx;
|
---|
59 | from testmanager.core.failurereason import FailureReasonLogic;
|
---|
60 | from testmanager.core.testbox import TestBoxLogic, TestBoxData;
|
---|
61 | from testmanager.core.testcase import TestCaseDataEx;
|
---|
62 | from testmanager.core.testgroup import TestGroupData;
|
---|
63 | from testmanager.core.testset import TestSetLogic, TestSetData;
|
---|
64 | from testmanager.core.testresults import TestResultLogic, TestResultFileData;
|
---|
65 | from testmanager.core.testresultfailures import TestResultFailureLogic, TestResultFailureData;
|
---|
66 | from testmanager.core.useraccount import UserAccountLogic;
|
---|
67 |
|
---|
68 | # Python 3 hacks:
|
---|
69 | if sys.version_info[0] >= 3:
|
---|
70 | xrange = range; # pylint: disable=redefined-builtin,invalid-name
|
---|
71 |
|
---|
72 |
|
---|
73 | class VirtualTestSheriffCaseFile(object):
|
---|
74 | """
|
---|
75 | A failure investigation case file.
|
---|
76 |
|
---|
77 | """
|
---|
78 |
|
---|
79 |
|
---|
80 | ## Max log file we'll read into memory. (256 MB)
|
---|
81 | kcbMaxLogRead = 0x10000000;
|
---|
82 |
|
---|
83 | def __init__(self, oSheriff, oTestSet, oTree, oBuild, oTestBox, oTestGroup, oTestCase):
|
---|
84 | self.oSheriff = oSheriff;
|
---|
85 | self.oTestSet = oTestSet; # TestSetData
|
---|
86 | self.oTree = oTree; # TestResultDataEx
|
---|
87 | self.oBuild = oBuild; # BuildDataEx
|
---|
88 | self.oTestBox = oTestBox; # TestBoxData
|
---|
89 | self.oTestGroup = oTestGroup; # TestGroupData
|
---|
90 | self.oTestCase = oTestCase; # TestCaseDataEx
|
---|
91 | self.sMainLog = ''; # The main log file. Empty string if not accessible.
|
---|
92 |
|
---|
93 | # Generate a case file name.
|
---|
94 | self.sName = '#%u: %s' % (self.oTestSet.idTestSet, self.oTestCase.sName,)
|
---|
95 | self.sLongName = '#%u: "%s" on "%s" running %s %s (%s), "%s" by %s, using %s %s %s r%u' \
|
---|
96 | % ( self.oTestSet.idTestSet,
|
---|
97 | self.oTestCase.sName,
|
---|
98 | self.oTestBox.sName,
|
---|
99 | self.oTestBox.sOs,
|
---|
100 | self.oTestBox.sOsVersion,
|
---|
101 | self.oTestBox.sCpuArch,
|
---|
102 | self.oTestBox.sCpuName,
|
---|
103 | self.oTestBox.sCpuVendor,
|
---|
104 | self.oBuild.oCat.sProduct,
|
---|
105 | self.oBuild.oCat.sBranch,
|
---|
106 | self.oBuild.oCat.sType,
|
---|
107 | self.oBuild.iRevision, );
|
---|
108 |
|
---|
109 | # Investigation notes.
|
---|
110 | self.tReason = None; # None or one of the ktReason_XXX constants.
|
---|
111 | self.dReasonForResultId = {}; # Reason assignments indexed by idTestResult.
|
---|
112 | self.dCommentForResultId = {}; # Comment assignments indexed by idTestResult.
|
---|
113 |
|
---|
114 | #
|
---|
115 | # Reason.
|
---|
116 | #
|
---|
117 |
|
---|
118 | def noteReason(self, tReason):
|
---|
119 | """ Notes down a possible reason. """
|
---|
120 | self.oSheriff.dprint(u'noteReason: %s -> %s' % (self.tReason, tReason,));
|
---|
121 | self.tReason = tReason;
|
---|
122 | return True;
|
---|
123 |
|
---|
124 | def noteReasonForId(self, tReason, idTestResult, sComment = None):
|
---|
125 | """ Notes down a possible reason for a specific test result. """
|
---|
126 | self.oSheriff.dprint(u'noteReasonForId: %u: %s -> %s%s'
|
---|
127 | % (idTestResult, self.dReasonForResultId.get(idTestResult, None), tReason,
|
---|
128 | (u' (%s)' % (sComment,)) if sComment is not None else ''));
|
---|
129 | self.dReasonForResultId[idTestResult] = tReason;
|
---|
130 | if sComment is not None:
|
---|
131 | self.dCommentForResultId[idTestResult] = sComment;
|
---|
132 | return True;
|
---|
133 |
|
---|
134 |
|
---|
135 | #
|
---|
136 | # Test classification.
|
---|
137 | #
|
---|
138 |
|
---|
139 | def isVBoxTest(self):
|
---|
140 | """ Test classification: VirtualBox (using the build) """
|
---|
141 | return self.oBuild.oCat.sProduct.lower() in [ 'virtualbox', 'vbox' ];
|
---|
142 |
|
---|
143 | def isVBoxUnitTest(self):
|
---|
144 | """ Test case classification: The unit test doing all our testcase/*.cpp stuff. """
|
---|
145 | return self.isVBoxTest() \
|
---|
146 | and (self.oTestCase.sName.lower() == 'unit tests' or self.oTestCase.sName.lower() == 'misc: unit tests');
|
---|
147 |
|
---|
148 | def isVBoxInstallTest(self):
|
---|
149 | """ Test case classification: VirtualBox Guest installation test. """
|
---|
150 | return self.isVBoxTest() \
|
---|
151 | and self.oTestCase.sName.lower().startswith('install:');
|
---|
152 |
|
---|
153 | def isVBoxUSBTest(self):
|
---|
154 | """ Test case classification: VirtualBox USB test. """
|
---|
155 | return self.isVBoxTest() \
|
---|
156 | and self.oTestCase.sName.lower().startswith('usb:');
|
---|
157 |
|
---|
158 | def isVBoxStorageTest(self):
|
---|
159 | """ Test case classification: VirtualBox Storage test. """
|
---|
160 | return self.isVBoxTest() \
|
---|
161 | and self.oTestCase.sName.lower().startswith('storage:');
|
---|
162 |
|
---|
163 | def isVBoxGAsTest(self):
|
---|
164 | """ Test case classification: VirtualBox Guest Additions test. """
|
---|
165 | return self.isVBoxTest() \
|
---|
166 | and self.oTestCase.sName.lower().startswith('ga\'s tests');
|
---|
167 |
|
---|
168 | def isVBoxAPITest(self):
|
---|
169 | """ Test case classification: VirtualBox API test. """
|
---|
170 | return self.isVBoxTest() \
|
---|
171 | and self.oTestCase.sName.lower().startswith('api:');
|
---|
172 |
|
---|
173 | def isVBoxBenchmarkTest(self):
|
---|
174 | """ Test case classification: VirtualBox Benchmark test. """
|
---|
175 | return self.isVBoxTest() \
|
---|
176 | and self.oTestCase.sName.lower().startswith('benchmark:');
|
---|
177 |
|
---|
178 | def isVBoxSmokeTest(self):
|
---|
179 | """ Test case classification: Smoke test. """
|
---|
180 | return self.isVBoxTest() \
|
---|
181 | and self.oTestCase.sName.lower().startswith('smoketest');
|
---|
182 |
|
---|
183 |
|
---|
184 | #
|
---|
185 | # Utility methods.
|
---|
186 | #
|
---|
187 |
|
---|
188 | def getMainLog(self):
|
---|
189 | """
|
---|
190 | Tries to read the main log file since this will be the first source of information.
|
---|
191 | """
|
---|
192 | if self.sMainLog:
|
---|
193 | return self.sMainLog;
|
---|
194 | (oFile, oSizeOrError, _) = self.oTestSet.openFile('main.log', 'rb');
|
---|
195 | if oFile is not None:
|
---|
196 | try:
|
---|
197 | self.sMainLog = oFile.read(min(self.kcbMaxLogRead, oSizeOrError)).decode('utf-8', 'replace');
|
---|
198 | except Exception as oXcpt:
|
---|
199 | self.oSheriff.vprint(u'Error reading main log file: %s' % (oXcpt,))
|
---|
200 | self.sMainLog = '';
|
---|
201 | else:
|
---|
202 | self.oSheriff.vprint(u'Error opening main log file: %s' % (oSizeOrError,));
|
---|
203 | return self.sMainLog;
|
---|
204 |
|
---|
205 | def getLogFile(self, oFile):
|
---|
206 | """
|
---|
207 | Tries to read the given file as a utf-8 log file.
|
---|
208 | oFile is a TestFileDataEx instance.
|
---|
209 | Returns empty string if problems opening or reading the file.
|
---|
210 | """
|
---|
211 | sContent = '';
|
---|
212 | (oFile, oSizeOrError, _) = self.oTestSet.openFile(oFile.sFile, 'rb');
|
---|
213 | if oFile is not None:
|
---|
214 | try:
|
---|
215 | sContent = oFile.read(min(self.kcbMaxLogRead, oSizeOrError)).decode('utf-8', 'replace');
|
---|
216 | except Exception as oXcpt:
|
---|
217 | self.oSheriff.vprint(u'Error reading the "%s" log file: %s' % (oFile.sFile, oXcpt,))
|
---|
218 | else:
|
---|
219 | self.oSheriff.vprint(u'Error opening the "%s" log file: %s' % (oFile.sFile, oSizeOrError,));
|
---|
220 | return sContent;
|
---|
221 |
|
---|
222 | def getScreenshotSha256(self, oFile):
|
---|
223 | """
|
---|
224 | Tries to read the given screenshot file, uncompress it, and do SHA-2
|
---|
225 | on the raw pixels.
|
---|
226 | Returns SHA-2 digest string on success, None on failure.
|
---|
227 | """
|
---|
228 | (oFile, _, _) = self.oTestSet.openFile(oFile.sFile, 'rb');
|
---|
229 | try:
|
---|
230 | abImageFile = oFile.read();
|
---|
231 | except Exception as oXcpt:
|
---|
232 | self.oSheriff.vprint(u'Error reading the "%s" image file: %s' % (oFile.sFile, oXcpt,))
|
---|
233 | else:
|
---|
234 | try:
|
---|
235 | oImage = Image.open(StringIO(abImageFile));
|
---|
236 | except Exception as oXcpt:
|
---|
237 | self.oSheriff.vprint(u'Error opening the "%s" image bytes using PIL.Image.open: %s' % (oFile.sFile, oXcpt,))
|
---|
238 | else:
|
---|
239 | try:
|
---|
240 | oHash = hashlib.sha256();
|
---|
241 | oHash.update(oImage.tostring());
|
---|
242 | except Exception as oXcpt:
|
---|
243 | self.oSheriff.vprint(u'Error hashing the uncompressed image bytes for "%s": %s' % (oFile.sFile, oXcpt,))
|
---|
244 | else:
|
---|
245 | return oHash.hexdigest();
|
---|
246 | return None;
|
---|
247 |
|
---|
248 |
|
---|
249 |
|
---|
250 | def isSingleTestFailure(self):
|
---|
251 | """
|
---|
252 | Figure out if this is a single test failing or if it's one of the
|
---|
253 | more complicated ones.
|
---|
254 | """
|
---|
255 | if self.oTree.cErrors == 1:
|
---|
256 | return True;
|
---|
257 | if self.oTree.deepCountErrorContributers() <= 1:
|
---|
258 | return True;
|
---|
259 | return False;
|
---|
260 |
|
---|
261 |
|
---|
262 |
|
---|
263 | class VirtualTestSheriff(object): # pylint: disable=R0903
|
---|
264 | """
|
---|
265 | Add build info into Test Manager database.
|
---|
266 | """
|
---|
267 |
|
---|
268 | ## The user account for the virtual sheriff.
|
---|
269 | ksLoginName = 'vsheriff';
|
---|
270 |
|
---|
271 | def __init__(self):
|
---|
272 | """
|
---|
273 | Parse command line.
|
---|
274 | """
|
---|
275 | self.oDb = None;
|
---|
276 | self.tsNow = None;
|
---|
277 | self.oTestResultLogic = None;
|
---|
278 | self.oTestSetLogic = None;
|
---|
279 | self.oFailureReasonLogic = None; # FailureReasonLogic;
|
---|
280 | self.oTestResultFailureLogic = None; # TestResultFailureLogic
|
---|
281 | self.oLogin = None;
|
---|
282 | self.uidSelf = -1;
|
---|
283 | self.oLogFile = None;
|
---|
284 | self.asBsodReasons = [];
|
---|
285 | self.asUnitTestReasons = [];
|
---|
286 |
|
---|
287 | oParser = OptionParser();
|
---|
288 | oParser.add_option('--start-hours-ago', dest = 'cStartHoursAgo', metavar = '<hours>', default = 0, type = 'int',
|
---|
289 | help = 'When to start specified as hours relative to current time. Defauls is right now.', );
|
---|
290 | oParser.add_option('--hours-period', dest = 'cHoursBack', metavar = '<period-in-hours>', default = 2, type = 'int',
|
---|
291 | help = 'Work period specified in hours. Defauls is 2 hours.');
|
---|
292 | oParser.add_option('--real-run-back', dest = 'fRealRun', action = 'store_true', default = False,
|
---|
293 | help = 'Whether to commit the findings to the database. Default is a dry run.');
|
---|
294 | oParser.add_option('-q', '--quiet', dest = 'fQuiet', action = 'store_true', default = False,
|
---|
295 | help = 'Quiet execution');
|
---|
296 | oParser.add_option('-l', '--log', dest = 'sLogFile', metavar = '<logfile>', default = None,
|
---|
297 | help = 'Where to log messages.');
|
---|
298 | oParser.add_option('--debug', dest = 'fDebug', action = 'store_true', default = False,
|
---|
299 | help = 'Enables debug mode.');
|
---|
300 |
|
---|
301 | (self.oConfig, _) = oParser.parse_args();
|
---|
302 |
|
---|
303 | if self.oConfig.sLogFile:
|
---|
304 | self.oLogFile = open(self.oConfig.sLogFile, "a");
|
---|
305 | self.oLogFile.write('VirtualTestSheriff: $Revision: 71088 $ \n');
|
---|
306 |
|
---|
307 |
|
---|
308 | def eprint(self, sText):
|
---|
309 | """
|
---|
310 | Prints error messages.
|
---|
311 | Returns 1 (for exit code usage.)
|
---|
312 | """
|
---|
313 | print('error: %s' % (sText,));
|
---|
314 | if self.oLogFile is not None:
|
---|
315 | self.oLogFile.write((u'error: %s\n' % (sText,)).encode('utf-8'));
|
---|
316 | return 1;
|
---|
317 |
|
---|
318 | def dprint(self, sText):
|
---|
319 | """
|
---|
320 | Prints debug info.
|
---|
321 | """
|
---|
322 | if self.oConfig.fDebug:
|
---|
323 | if not self.oConfig.fQuiet:
|
---|
324 | print('debug: %s' % (sText, ));
|
---|
325 | if self.oLogFile is not None:
|
---|
326 | self.oLogFile.write((u'debug: %s\n' % (sText,)).encode('utf-8'));
|
---|
327 | return 0;
|
---|
328 |
|
---|
329 | def vprint(self, sText):
|
---|
330 | """
|
---|
331 | Prints verbose info.
|
---|
332 | """
|
---|
333 | if not self.oConfig.fQuiet:
|
---|
334 | print('info: %s' % (sText,));
|
---|
335 | if self.oLogFile is not None:
|
---|
336 | self.oLogFile.write((u'info: %s\n' % (sText,)).encode('utf-8'));
|
---|
337 | return 0;
|
---|
338 |
|
---|
339 | def getFailureReason(self, tReason):
|
---|
340 | """ Gets the failure reason object for tReason. """
|
---|
341 | return self.oFailureReasonLogic.cachedLookupByNameAndCategory(tReason[1], tReason[0]);
|
---|
342 |
|
---|
343 | def selfCheck(self):
|
---|
344 | """ Does some self checks, looking up things we expect to be in the database and such. """
|
---|
345 | rcExit = 0;
|
---|
346 | for sAttr in dir(self.__class__):
|
---|
347 | if sAttr.startswith('ktReason_'):
|
---|
348 | tReason = getattr(self.__class__, sAttr);
|
---|
349 | oFailureReason = self.getFailureReason(tReason);
|
---|
350 | if oFailureReason is None:
|
---|
351 | rcExit = self.eprint(u'Failed to find failure reason "%s" in category "%s" in the database!'
|
---|
352 | % (tReason[1], tReason[0],));
|
---|
353 |
|
---|
354 | # Check the user account as well.
|
---|
355 | if self.oLogin is None:
|
---|
356 | oLogin = UserAccountLogic(self.oDb).tryFetchAccountByLoginName(VirtualTestSheriff.ksLoginName);
|
---|
357 | if oLogin is None:
|
---|
358 | rcExit = self.eprint(u'Cannot find my user account "%s"!' % (VirtualTestSheriff.ksLoginName,));
|
---|
359 | return rcExit;
|
---|
360 |
|
---|
361 |
|
---|
362 |
|
---|
363 | def badTestBoxManagement(self):
|
---|
364 | """
|
---|
365 | Looks for bad test boxes and first tries once to reboot them then disables them.
|
---|
366 | """
|
---|
367 | rcExit = 0;
|
---|
368 |
|
---|
369 | #
|
---|
370 | # We skip this entirely if we're running in the past and not in harmless debug mode.
|
---|
371 | #
|
---|
372 | if self.oConfig.cStartHoursAgo != 0 \
|
---|
373 | and (not self.oConfig.fDebug or self.oConfig.fRealRun):
|
---|
374 | return rcExit;
|
---|
375 | tsNow = self.tsNow if self.oConfig.fDebug else None;
|
---|
376 | cHoursBack = self.oConfig.cHoursBack if self.oConfig.fDebug else 2;
|
---|
377 | oTestBoxLogic = TestBoxLogic(self.oDb);
|
---|
378 |
|
---|
379 | #
|
---|
380 | # Generate a list of failures reasons we consider bad-testbox behavior.
|
---|
381 | #
|
---|
382 | aidFailureReasons = [
|
---|
383 | self.getFailureReason(self.ktReason_Host_DriverNotUnloading).idFailureReason,
|
---|
384 | self.getFailureReason(self.ktReason_Host_DriverNotCompilable).idFailureReason,
|
---|
385 | self.getFailureReason(self.ktReason_Host_InstallationFailed).idFailureReason,
|
---|
386 | ];
|
---|
387 |
|
---|
388 | #
|
---|
389 | # Get list of bad test boxes for given period and check them out individually.
|
---|
390 | #
|
---|
391 | aidBadTestBoxes = self.oTestSetLogic.fetchBadTestBoxIds(cHoursBack = cHoursBack, tsNow = tsNow,
|
---|
392 | aidFailureReasons = aidFailureReasons);
|
---|
393 | for idTestBox in aidBadTestBoxes:
|
---|
394 | # Skip if the testbox is already disabled or has a pending reboot command.
|
---|
395 | try:
|
---|
396 | oTestBox = TestBoxData().initFromDbWithId(self.oDb, idTestBox);
|
---|
397 | except Exception as oXcpt:
|
---|
398 | rcExit = self.eprint('Failed to get data for test box #%u in badTestBoxManagement: %s' % (idTestBox, oXcpt,));
|
---|
399 | continue;
|
---|
400 | if not oTestBox.fEnabled:
|
---|
401 | self.dprint(u'badTestBoxManagement: Skipping test box #%u (%s) as it has been disabled already.'
|
---|
402 | % ( idTestBox, oTestBox.sName, ));
|
---|
403 | continue;
|
---|
404 | if oTestBox.enmPendingCmd != TestBoxData.ksTestBoxCmd_None:
|
---|
405 | self.dprint(u'badTestBoxManagement: Skipping test box #%u (%s) as it has a command pending: %s'
|
---|
406 | % ( idTestBox, oTestBox.sName, oTestBox.enmPendingCmd));
|
---|
407 | continue;
|
---|
408 |
|
---|
409 | # Get the most recent testsets for this box (descending on tsDone) and see how bad it is.
|
---|
410 | aoSets = self.oTestSetLogic.fetchSetsForTestBox(idTestBox, cHoursBack = cHoursBack, tsNow = tsNow);
|
---|
411 | cOkay = 0;
|
---|
412 | cBad = 0;
|
---|
413 | iFirstOkay = len(aoSets);
|
---|
414 | for iSet, oSet in enumerate(aoSets):
|
---|
415 | if oSet.enmStatus == TestSetData.ksTestStatus_BadTestBox:
|
---|
416 | cBad += 1;
|
---|
417 | else:
|
---|
418 | # Check for bad failure reasons.
|
---|
419 | oFailure = None;
|
---|
420 | if oSet.enmStatus in TestSetData.kasBadTestStatuses:
|
---|
421 | oFailure = self.oTestResultFailureLogic.getById(oSet.idTestResult);
|
---|
422 | if oFailure is not None and oFailure.idFailureReason in aidFailureReasons:
|
---|
423 | cBad += 1;
|
---|
424 | else:
|
---|
425 | # This is an okay test result then.
|
---|
426 | ## @todo maybe check the elapsed time here, it could still be a bad run?
|
---|
427 | cOkay += 1;
|
---|
428 | if iFirstOkay > iSet:
|
---|
429 | iFirstOkay = iSet;
|
---|
430 | if iSet > 10:
|
---|
431 | break;
|
---|
432 |
|
---|
433 | # We react if there are two or more bad-testbox statuses at the head of the
|
---|
434 | # history and at least three in the last 10 results.
|
---|
435 | if iFirstOkay >= 2 and cBad > 2:
|
---|
436 | # Frank: For now don't reboot boxes automatically
|
---|
437 | if True or oTestBoxLogic.hasTestBoxRecentlyBeenRebooted(idTestBox, cHoursBack = cHoursBack, tsNow = tsNow):
|
---|
438 | self.vprint(u'Disabling testbox #%u (%s) - iFirstOkay=%u cBad=%u cOkay=%u'
|
---|
439 | % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay));
|
---|
440 | if self.oConfig.fRealRun is True:
|
---|
441 | try:
|
---|
442 | oTestBoxLogic.disableTestBox(idTestBox, self.uidSelf, fCommit = True,
|
---|
443 | sComment = 'Automatically disabled (iFirstOkay=%u cBad=%u cOkay=%u)'
|
---|
444 | % (iFirstOkay, cBad, cOkay),);
|
---|
445 | except Exception as oXcpt:
|
---|
446 | rcExit = self.eprint(u'Error disabling testbox #%u (%u): %s\n' % (idTestBox, oTestBox.sName, oXcpt,));
|
---|
447 | else:
|
---|
448 | self.vprint(u'Rebooting testbox #%u (%s) - iFirstOkay=%u cBad=%u cOkay=%u'
|
---|
449 | % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay));
|
---|
450 | if self.oConfig.fRealRun is True:
|
---|
451 | try:
|
---|
452 | oTestBoxLogic.rebootTestBox(idTestBox, self.uidSelf, fCommit = True,
|
---|
453 | sComment = 'Automatically rebooted (iFirstOkay=%u cBad=%u cOkay=%u)'
|
---|
454 | % (iFirstOkay, cBad, cOkay),);
|
---|
455 | except Exception as oXcpt:
|
---|
456 | rcExit = self.eprint(u'Error rebooting testbox #%u (%u): %s\n' % (idTestBox, oTestBox.sName, oXcpt,));
|
---|
457 | else:
|
---|
458 | self.dprint(u'badTestBoxManagement: #%u (%s) looks ok: iFirstOkay=%u cBad=%u cOkay=%u'
|
---|
459 | % ( idTestBox, oTestBox.sName, iFirstOkay, cBad, cOkay));
|
---|
460 | return rcExit;
|
---|
461 |
|
---|
462 |
|
---|
463 | ## @name Failure reasons we know.
|
---|
464 | ## @{
|
---|
465 | ktReason_BSOD_Recovery = ( 'BSOD', 'Recovery' );
|
---|
466 | ktReason_BSOD_Automatic_Repair = ( 'BSOD', 'Automatic Repair' );
|
---|
467 | ktReason_BSOD_0000007F = ( 'BSOD', '0x0000007F' );
|
---|
468 | ktReason_BSOD_000000D1 = ( 'BSOD', '0x000000D1' );
|
---|
469 | ktReason_BSOD_C0000225 = ( 'BSOD', '0xC0000225 (boot)' );
|
---|
470 | ktReason_Guru_Generic = ( 'Guru Meditations', 'Generic Guru Meditation' );
|
---|
471 | ktReason_Guru_VERR_IEM_INSTR_NOT_IMPLEMENTED = ( 'Guru Meditations', 'VERR_IEM_INSTR_NOT_IMPLEMENTED' );
|
---|
472 | ktReason_Guru_VERR_IEM_ASPECT_NOT_IMPLEMENTED = ( 'Guru Meditations', 'VERR_IEM_ASPECT_NOT_IMPLEMENTED' );
|
---|
473 | ktReason_Guru_VERR_TRPM_DONT_PANIC = ( 'Guru Meditations', 'VERR_TRPM_DONT_PANIC' );
|
---|
474 | ktReason_Guru_VERR_PGM_PHYS_PAGE_RESERVED = ( 'Guru Meditations', 'VERR_PGM_PHYS_PAGE_RESERVED' );
|
---|
475 | ktReason_Guru_VERR_VMX_INVALID_GUEST_STATE = ( 'Guru Meditations', 'VERR_VMX_INVALID_GUEST_STATE' );
|
---|
476 | ktReason_Guru_VINF_EM_TRIPLE_FAULT = ( 'Guru Meditations', 'VINF_EM_TRIPLE_FAULT' );
|
---|
477 | ktReason_Host_HostMemoryLow = ( 'Host', 'HostMemoryLow' );
|
---|
478 | ktReason_Host_DriverNotLoaded = ( 'Host', 'Driver not loaded' );
|
---|
479 | ktReason_Host_DriverNotUnloading = ( 'Host', 'Driver not unloading' );
|
---|
480 | ktReason_Host_DriverNotCompilable = ( 'Host', 'Driver not compilable' );
|
---|
481 | ktReason_Host_InstallationFailed = ( 'Host', 'Installation failed' );
|
---|
482 | ktReason_Host_NotSignedWithBuildCert = ( 'Host', 'Not signed with build cert' );
|
---|
483 | ktReason_Host_DoubleFreeHeap = ( 'Host', 'Double free or corruption' );
|
---|
484 | ktReason_Host_LeftoverService = ( 'Host', 'Leftover service' );
|
---|
485 | ktReason_Host_Reboot_OSX_Watchdog_Timeout = ( 'Host Reboot', 'OSX Watchdog Timeout' );
|
---|
486 | ktReason_Host_Modprobe_Failed = ( 'Host', 'Modprobe failed' );
|
---|
487 | ktReason_Host_Install_Hang = ( 'Host', 'Install hang' );
|
---|
488 | ktReason_Host_NetworkMisconfiguration = ( 'Host', 'Network misconfiguration' );
|
---|
489 | ktReason_Networking_Nonexistent_host_nic = ( 'Networking', 'Nonexistent host networking interface' );
|
---|
490 | ktReason_OSInstall_GRUB_hang = ( 'O/S Install', 'GRUB hang' );
|
---|
491 | ktReason_OSInstall_Sata_no_BM = ( 'O/S Install', 'SATA busmaster bit not set' );
|
---|
492 | ktReason_Panic_BootManagerC000000F = ( 'Panic', 'Hardware Changed' );
|
---|
493 | ktReason_BootManager_Image_corrupt = ( 'Unknown', 'BOOTMGR Image corrupt' );
|
---|
494 | ktReason_Panic_MP_BIOS_IO_APIC = ( 'Panic', 'MP-BIOS/IO-APIC' );
|
---|
495 | ktReason_Panic_HugeMemory = ( 'Panic', 'Huge memory assertion' );
|
---|
496 | ktReason_Panic_IOAPICDoesntWork = ( 'Panic', 'IO-APIC and timer does not work' );
|
---|
497 | ktReason_Panic_TxUnitHang = ( 'Panic', 'Tx Unit Hang' );
|
---|
498 | ktReason_XPCOM_Exit_Minus_11 = ( 'API / (XP)COM', 'exit -11' );
|
---|
499 | ktReason_XPCOM_VBoxSVC_Hang = ( 'API / (XP)COM', 'VBoxSVC hang' );
|
---|
500 | ktReason_XPCOM_VBoxSVC_Hang_Plus_Heap_Corruption = ( 'API / (XP)COM', 'VBoxSVC hang + heap corruption' );
|
---|
501 | ktReason_XPCOM_NS_ERROR_CALL_FAILED = ( 'API / (XP)COM', 'NS_ERROR_CALL_FAILED' );
|
---|
502 | ktReason_Unknown_Heap_Corruption = ( 'Unknown', 'Heap corruption' );
|
---|
503 | ktReason_Unknown_Reboot_Loop = ( 'Unknown', 'Reboot loop' );
|
---|
504 | ktReason_Unknown_File_Not_Found = ( 'Unknown', 'File not found' );
|
---|
505 | ktReason_Unknown_VM_Crash = ( 'Unknown', 'VM crash' );
|
---|
506 | ktReason_Unknown_HalReturnToFirmware = ( 'Unknown', 'HalReturnToFirmware' );
|
---|
507 | ktReason_VMM_kvm_lock_spinning = ( 'VMM', 'kvm_lock_spinning' );
|
---|
508 | ktReason_Ignore_Buggy_Test_Driver = ( 'Ignore', 'Buggy test driver' );
|
---|
509 | ktReason_Ignore_Stale_Files = ( 'Ignore', 'Stale files' );
|
---|
510 | ktReason_Buggy_Build_Broken_Build = ( 'Broken Build', 'Buggy build' );
|
---|
511 | ## @}
|
---|
512 |
|
---|
513 | ## BSOD category.
|
---|
514 | ksBsodCategory = 'BSOD';
|
---|
515 | ## Special reason indicating that the flesh and blood sheriff has work to do.
|
---|
516 | ksBsodAddNew = 'Add new BSOD';
|
---|
517 |
|
---|
518 | ## Unit test category.
|
---|
519 | ksUnitTestCategory = 'Unit';
|
---|
520 | ## Special reason indicating that the flesh and blood sheriff has work to do.
|
---|
521 | ksUnitTestAddNew = 'Add new';
|
---|
522 |
|
---|
523 | ## Used for indica that we shouldn't report anything for this test result ID and
|
---|
524 | ## consider promoting the previous error to test set level if it's the only one.
|
---|
525 | ktHarmless = ( 'Probably', 'Caused by previous error' );
|
---|
526 |
|
---|
527 |
|
---|
528 | def caseClosed(self, oCaseFile):
|
---|
529 | """
|
---|
530 | Reports the findings in the case and closes it.
|
---|
531 | """
|
---|
532 | #
|
---|
533 | # Log it and create a dReasonForReasultId we can use below.
|
---|
534 | #
|
---|
535 | dCommentForResultId = oCaseFile.dCommentForResultId;
|
---|
536 | if oCaseFile.dReasonForResultId:
|
---|
537 | # Must weed out ktHarmless.
|
---|
538 | dReasonForResultId = {};
|
---|
539 | for idKey, tReason in oCaseFile.dReasonForResultId.items():
|
---|
540 | if tReason is not self.ktHarmless:
|
---|
541 | dReasonForResultId[idKey] = tReason;
|
---|
542 | if not dReasonForResultId:
|
---|
543 | self.vprint(u'TODO: Closing %s without a real reason, only %s.'
|
---|
544 | % (oCaseFile.sName, oCaseFile.dReasonForResultId));
|
---|
545 | return False;
|
---|
546 |
|
---|
547 | # Try promote to single reason.
|
---|
548 | atValues = dReasonForResultId.values();
|
---|
549 | fSingleReason = True;
|
---|
550 | if len(dReasonForResultId) == 1 and dReasonForResultId.keys()[0] != oCaseFile.oTestSet.idTestResult:
|
---|
551 | self.dprint(u'Promoting single reason to whole set: %s' % (atValues[0],));
|
---|
552 | elif len(dReasonForResultId) > 1 and len(atValues) == atValues.count(atValues[0]):
|
---|
553 | self.dprint(u'Merged %d reasons to a single one: %s' % (len(atValues), atValues[0]));
|
---|
554 | else:
|
---|
555 | fSingleReason = False;
|
---|
556 | if fSingleReason:
|
---|
557 | dReasonForResultId = { oCaseFile.oTestSet.idTestResult: atValues[0], };
|
---|
558 | if dCommentForResultId:
|
---|
559 | dCommentForResultId = { oCaseFile.oTestSet.idTestResult: dCommentForResultId.values()[0], };
|
---|
560 | elif oCaseFile.tReason is not None:
|
---|
561 | dReasonForResultId = { oCaseFile.oTestSet.idTestResult: oCaseFile.tReason, };
|
---|
562 | else:
|
---|
563 | self.vprint(u'Closing %s without a reason - this should not happen!' % (oCaseFile.sName,));
|
---|
564 | return False;
|
---|
565 |
|
---|
566 | self.vprint(u'Closing %s with following reason%s: %s'
|
---|
567 | % ( oCaseFile.sName, 's' if dReasonForResultId > 0 else '', dReasonForResultId, ));
|
---|
568 |
|
---|
569 | #
|
---|
570 | # Add the test failure reason record(s).
|
---|
571 | #
|
---|
572 | for idTestResult, tReason in dReasonForResultId.items():
|
---|
573 | oFailureReason = self.getFailureReason(tReason);
|
---|
574 | if oFailureReason is not None:
|
---|
575 | sComment = 'Set by $Revision: 71088 $' # Handy for reverting later.
|
---|
576 | if idTestResult in dCommentForResultId:
|
---|
577 | sComment += ': ' + dCommentForResultId[idTestResult];
|
---|
578 |
|
---|
579 | oAdd = TestResultFailureData();
|
---|
580 | oAdd.initFromValues(idTestResult = idTestResult,
|
---|
581 | idFailureReason = oFailureReason.idFailureReason,
|
---|
582 | uidAuthor = self.uidSelf,
|
---|
583 | idTestSet = oCaseFile.oTestSet.idTestSet,
|
---|
584 | sComment = sComment,);
|
---|
585 | if self.oConfig.fRealRun:
|
---|
586 | try:
|
---|
587 | self.oTestResultFailureLogic.addEntry(oAdd, self.uidSelf, fCommit = True);
|
---|
588 | except Exception as oXcpt:
|
---|
589 | self.eprint(u'caseClosed: Exception "%s" while adding reason %s for %s'
|
---|
590 | % (oXcpt, oAdd, oCaseFile.sLongName,));
|
---|
591 | else:
|
---|
592 | self.eprint(u'caseClosed: Cannot locate failure reason: %s / %s' % ( tReason[0], tReason[1],));
|
---|
593 | return True;
|
---|
594 |
|
---|
595 | #
|
---|
596 | # Tools for assiting log parsing.
|
---|
597 | #
|
---|
598 |
|
---|
599 | @staticmethod
|
---|
600 | def matchFollowedByLines(sStr, off, asFollowingLines):
|
---|
601 | """ Worker for isThisFollowedByTheseLines. """
|
---|
602 |
|
---|
603 | # Advance off to the end of the line.
|
---|
604 | off = sStr.find('\n', off);
|
---|
605 | if off < 0:
|
---|
606 | return False;
|
---|
607 | off += 1;
|
---|
608 |
|
---|
609 | # Match each string with the subsequent lines.
|
---|
610 | for iLine, sLine in enumerate(asFollowingLines):
|
---|
611 | offEnd = sStr.find('\n', off);
|
---|
612 | if offEnd < 0:
|
---|
613 | return iLine + 1 == len(asFollowingLines) and sStr.find(sLine, off) < 0;
|
---|
614 | if sLine and sStr.find(sLine, off, offEnd) < 0:
|
---|
615 | return False;
|
---|
616 |
|
---|
617 | # next line.
|
---|
618 | off = offEnd + 1;
|
---|
619 |
|
---|
620 | return True;
|
---|
621 |
|
---|
622 | @staticmethod
|
---|
623 | def isThisFollowedByTheseLines(sStr, sFirst, asFollowingLines):
|
---|
624 | """
|
---|
625 | Looks for a line contining sFirst which is then followed by lines
|
---|
626 | with the strings in asFollowingLines. (No newline chars anywhere!)
|
---|
627 | Returns True / False.
|
---|
628 | """
|
---|
629 | off = sStr.find(sFirst, 0);
|
---|
630 | while off >= 0:
|
---|
631 | if VirtualTestSheriff.matchFollowedByLines(sStr, off, asFollowingLines):
|
---|
632 | return True;
|
---|
633 | off = sStr.find(sFirst, off + 1);
|
---|
634 | return False;
|
---|
635 |
|
---|
636 | @staticmethod
|
---|
637 | def findAndReturnRestOfLine(sHaystack, sNeedle):
|
---|
638 | """
|
---|
639 | Looks for sNeedle in sHaystack.
|
---|
640 | Returns The text following the needle up to the end of the line.
|
---|
641 | Returns None if not found.
|
---|
642 | """
|
---|
643 | if sHaystack is None:
|
---|
644 | return None;
|
---|
645 | off = sHaystack.find(sNeedle);
|
---|
646 | if off < 0:
|
---|
647 | return None;
|
---|
648 | off += len(sNeedle)
|
---|
649 | offEol = sHaystack.find('\n', off);
|
---|
650 | if offEol < 0:
|
---|
651 | offEol = len(sHaystack);
|
---|
652 | return sHaystack[off:offEol]
|
---|
653 |
|
---|
654 | @staticmethod
|
---|
655 | def findInAnyAndReturnRestOfLine(asHaystacks, sNeedle):
|
---|
656 | """
|
---|
657 | Looks for sNeedle in zeroe or more haystacks (asHaystack).
|
---|
658 | Returns The text following the first needed found up to the end of the line.
|
---|
659 | Returns None if not found.
|
---|
660 | """
|
---|
661 | for sHaystack in asHaystacks:
|
---|
662 | sRet = VirtualTestSheriff.findAndReturnRestOfLine(sHaystack, sNeedle);
|
---|
663 | if sRet is not None:
|
---|
664 | return sRet;
|
---|
665 | return None;
|
---|
666 |
|
---|
667 |
|
---|
668 | #
|
---|
669 | # The investigative units.
|
---|
670 | #
|
---|
671 |
|
---|
672 | katSimpleInstallUninstallMainLogReasons = [
|
---|
673 | # ( Whether to stop on hit, reason tuple, needle text. )
|
---|
674 | ( False, ktReason_Host_LeftoverService,
|
---|
675 | 'SERVICE_NAME: vbox' ),
|
---|
676 | ];
|
---|
677 |
|
---|
678 | kdatSimpleInstallUninstallMainLogReasonsPerOs = {
|
---|
679 | 'darwin': [
|
---|
680 | # ( Whether to stop on hit, reason tuple, needle text. )
|
---|
681 | ( True, ktReason_Host_DriverNotUnloading,
|
---|
682 | 'Can\'t remove kext org.virtualbox.kext.VBoxDrv; services failed to terminate - 0xe00002c7' ),
|
---|
683 | ],
|
---|
684 | 'linux': [
|
---|
685 | # ( Whether to stop on hit, reason tuple, needle text. )
|
---|
686 | ( True, ktReason_Host_DriverNotCompilable,
|
---|
687 | 'This system is not currently set up to build kernel modules' ),
|
---|
688 | ( True, ktReason_Host_DriverNotCompilable,
|
---|
689 | 'This system is currently not set up to build kernel modules' ),
|
---|
690 | ( True, ktReason_Host_InstallationFailed,
|
---|
691 | 'vboxdrv.sh: failed: Look at /var/log/vbox-install.log to find out what went wrong.' ),
|
---|
692 | ( True, ktReason_Host_DriverNotUnloading,
|
---|
693 | 'Cannot unload module vboxdrv'),
|
---|
694 | ],
|
---|
695 | };
|
---|
696 |
|
---|
697 |
|
---|
698 | def investigateInstallUninstallFailure(self, oCaseFile, oFailedResult, sResultLog, fInstall):
|
---|
699 | """
|
---|
700 | Investigates an install or uninstall failure.
|
---|
701 |
|
---|
702 | We lump the two together since the installation typically also performs
|
---|
703 | an uninstall first and will be seeing similar issues to the uninstall.
|
---|
704 | """
|
---|
705 |
|
---|
706 | if fInstall and oFailedResult.enmStatus == TestSetData.ksTestStatus_TimedOut:
|
---|
707 | oCaseFile.noteReasonForId(self.ktReason_Host_Install_Hang, oFailedResult.idTestResult)
|
---|
708 | return True;
|
---|
709 |
|
---|
710 | atSimple = self.katSimpleInstallUninstallMainLogReasons;
|
---|
711 | if oCaseFile.oTestBox.sOs in self.kdatSimpleInstallUninstallMainLogReasonsPerOs:
|
---|
712 | atSimple = self.kdatSimpleInstallUninstallMainLogReasonsPerOs[oCaseFile.oTestBox.sOs] + atSimple;
|
---|
713 |
|
---|
714 | fFoundSomething = False;
|
---|
715 | for fStopOnHit, tReason, sNeedle in atSimple:
|
---|
716 | if sResultLog.find(sNeedle) > 0:
|
---|
717 | oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult);
|
---|
718 | if fStopOnHit:
|
---|
719 | return True;
|
---|
720 | fFoundSomething = True;
|
---|
721 |
|
---|
722 | return fFoundSomething if fFoundSomething else None;
|
---|
723 |
|
---|
724 |
|
---|
725 | def investigateBadTestBox(self, oCaseFile):
|
---|
726 | """
|
---|
727 | Checks out bad-testbox statuses.
|
---|
728 | """
|
---|
729 | _ = oCaseFile;
|
---|
730 | return False;
|
---|
731 |
|
---|
732 |
|
---|
733 | def investigateVBoxUnitTest(self, oCaseFile):
|
---|
734 | """
|
---|
735 | Checks out a VBox unittest problem.
|
---|
736 | """
|
---|
737 |
|
---|
738 | #
|
---|
739 | # Process simple test case failures first, using their name as reason.
|
---|
740 | # We do the reason management just like for BSODs.
|
---|
741 | #
|
---|
742 | cRelevantOnes = 0;
|
---|
743 | sMainLog = oCaseFile.getMainLog();
|
---|
744 | aoFailedResults = oCaseFile.oTree.getListOfFailures();
|
---|
745 | for oFailedResult in aoFailedResults:
|
---|
746 | if oFailedResult is oCaseFile.oTree:
|
---|
747 | self.vprint('TODO: toplevel failure');
|
---|
748 | cRelevantOnes += 1
|
---|
749 |
|
---|
750 | elif oFailedResult.sName == 'Installing VirtualBox':
|
---|
751 | sResultLog = TestSetData.extractLogSectionElapsed(sMainLog, oFailedResult.tsCreated, oFailedResult.tsElapsed);
|
---|
752 | self.investigateInstallUninstallFailure(oCaseFile, oFailedResult, sResultLog, fInstall = True)
|
---|
753 | cRelevantOnes += 1
|
---|
754 |
|
---|
755 | elif oFailedResult.sName == 'Uninstalling VirtualBox':
|
---|
756 | sResultLog = TestSetData.extractLogSectionElapsed(sMainLog, oFailedResult.tsCreated, oFailedResult.tsElapsed);
|
---|
757 | self.investigateInstallUninstallFailure(oCaseFile, oFailedResult, sResultLog, fInstall = False)
|
---|
758 | cRelevantOnes += 1
|
---|
759 |
|
---|
760 | elif oFailedResult.oParent is not None:
|
---|
761 | # Get the 2nd level node because that's where we'll find the unit test name.
|
---|
762 | while oFailedResult.oParent.oParent is not None:
|
---|
763 | oFailedResult = oFailedResult.oParent;
|
---|
764 |
|
---|
765 | # Only report a failure once.
|
---|
766 | if oFailedResult.idTestResult not in oCaseFile.dReasonForResultId:
|
---|
767 | sKey = oFailedResult.sName;
|
---|
768 | if sKey.startswith('testcase/'):
|
---|
769 | sKey = sKey[9:];
|
---|
770 | if sKey in self.asUnitTestReasons:
|
---|
771 | tReason = ( self.ksUnitTestCategory, sKey );
|
---|
772 | oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult);
|
---|
773 | else:
|
---|
774 | self.dprint(u'Unit test failure "%s" not found in %s;' % (sKey, self.asUnitTestReasons));
|
---|
775 | tReason = ( self.ksUnitTestCategory, self.ksUnitTestAddNew );
|
---|
776 | oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult, sComment = sKey);
|
---|
777 | cRelevantOnes += 1
|
---|
778 | else:
|
---|
779 | self.vprint(u'Internal error: expected oParent to NOT be None for %s' % (oFailedResult,));
|
---|
780 |
|
---|
781 | #
|
---|
782 | # If we've caught all the relevant ones by now, report the result.
|
---|
783 | #
|
---|
784 | if len(oCaseFile.dReasonForResultId) >= cRelevantOnes:
|
---|
785 | return self.caseClosed(oCaseFile);
|
---|
786 | return False;
|
---|
787 |
|
---|
788 | def extractGuestCpuStack(self, sInfoText):
|
---|
789 | """
|
---|
790 | Extracts the guest CPU stacks from the input file.
|
---|
791 |
|
---|
792 | Returns a dictionary keyed by the CPU number, value being a list of
|
---|
793 | raw stack lines (no header).
|
---|
794 | Returns empty dictionary if no stacks where found.
|
---|
795 | """
|
---|
796 | dRet = {};
|
---|
797 | off = 0;
|
---|
798 | while True:
|
---|
799 | # Find the stack.
|
---|
800 | offStart = sInfoText.find('=== start guest stack VCPU ', off);
|
---|
801 | if offStart < 0:
|
---|
802 | break;
|
---|
803 | offEnd = sInfoText.find('=== end guest stack', offStart + 20);
|
---|
804 | if offEnd >= 0:
|
---|
805 | offEnd += 3;
|
---|
806 | else:
|
---|
807 | offEnd = sInfoText.find('=== start guest stack VCPU', offStart + 20);
|
---|
808 | if offEnd < 0:
|
---|
809 | offEnd = len(sInfoText);
|
---|
810 |
|
---|
811 | sStack = sInfoText[offStart : offEnd];
|
---|
812 | sStack = sStack.replace('\r',''); # paranoia
|
---|
813 | asLines = sStack.split('\n');
|
---|
814 |
|
---|
815 | # Figure the CPU.
|
---|
816 | asWords = asLines[0].split();
|
---|
817 | if len(asWords) < 6 or not asWords[5].isdigit():
|
---|
818 | break;
|
---|
819 | iCpu = int(asWords[5]);
|
---|
820 |
|
---|
821 | # Add it and advance.
|
---|
822 | dRet[iCpu] = [sLine.rstrip() for sLine in asLines[2:-1]]
|
---|
823 | off = offEnd;
|
---|
824 | return dRet;
|
---|
825 |
|
---|
826 | def investigateInfoKvmLockSpinning(self, oCaseFile, sInfoText, dLogs):
|
---|
827 | """ Investigates kvm_lock_spinning deadlocks """
|
---|
828 | #
|
---|
829 | # Extract the stacks. We need more than one CPU to create a deadlock.
|
---|
830 | #
|
---|
831 | dStacks = self.extractGuestCpuStack(sInfoText);
|
---|
832 | self.dprint('kvm_lock_spinning: found %s stacks' % (len(dStacks),));
|
---|
833 | if len(dStacks) >= 2:
|
---|
834 | #
|
---|
835 | # Examin each of the stacks. Each must have kvm_lock_spinning in
|
---|
836 | # one of the first three entries.
|
---|
837 | #
|
---|
838 | cHits = 0;
|
---|
839 | for iCpu in dStacks:
|
---|
840 | asBacktrace = dStacks[iCpu];
|
---|
841 | for iFrame in xrange(min(3, len(asBacktrace))):
|
---|
842 | if asBacktrace[iFrame].find('kvm_lock_spinning') >= 0:
|
---|
843 | cHits += 1;
|
---|
844 | break;
|
---|
845 | self.dprint('kvm_lock_spinning: %s/%s hits' % (cHits, len(dStacks),));
|
---|
846 | if cHits == len(dStacks):
|
---|
847 | return (True, self.ktReason_VMM_kvm_lock_spinning);
|
---|
848 |
|
---|
849 | _ = dLogs; _ = oCaseFile;
|
---|
850 | return (False, None);
|
---|
851 |
|
---|
852 | def investigateInfoHalReturnToFirmware(self, oCaseFile, sInfoText, dLogs):
|
---|
853 | """ Investigates HalReturnToFirmware hangs """
|
---|
854 | del oCaseFile
|
---|
855 | del sInfoText
|
---|
856 | del dLogs
|
---|
857 | # hope that's sufficient
|
---|
858 | return (True, self.ktReason_Unknown_HalReturnToFirmware);
|
---|
859 |
|
---|
860 | ## Things we search a main or VM log for to figure out why something went bust.
|
---|
861 | katSimpleMainAndVmLogReasons = [
|
---|
862 | # ( Whether to stop on hit, reason tuple, needle text. )
|
---|
863 | ( False, ktReason_Guru_Generic, 'GuruMeditation' ),
|
---|
864 | ( False, ktReason_Guru_Generic, 'Guru Meditation' ),
|
---|
865 | ( True, ktReason_Guru_VERR_IEM_INSTR_NOT_IMPLEMENTED, 'VERR_IEM_INSTR_NOT_IMPLEMENTED' ),
|
---|
866 | ( True, ktReason_Guru_VERR_IEM_ASPECT_NOT_IMPLEMENTED, 'VERR_IEM_ASPECT_NOT_IMPLEMENTED' ),
|
---|
867 | ( True, ktReason_Guru_VERR_TRPM_DONT_PANIC, 'VERR_TRPM_DONT_PANIC' ),
|
---|
868 | ( True, ktReason_Guru_VERR_PGM_PHYS_PAGE_RESERVED, 'VERR_PGM_PHYS_PAGE_RESERVED' ),
|
---|
869 | ( True, ktReason_Guru_VERR_VMX_INVALID_GUEST_STATE, 'VERR_VMX_INVALID_GUEST_STATE' ),
|
---|
870 | ( True, ktReason_Guru_VINF_EM_TRIPLE_FAULT, 'VINF_EM_TRIPLE_FAULT' ),
|
---|
871 | ( True, ktReason_Networking_Nonexistent_host_nic,
|
---|
872 | 'rc=E_FAIL text="Nonexistent host networking interface, name \'eth0\' (VERR_INTERNAL_ERROR)"' ),
|
---|
873 | ( True, ktReason_Host_Reboot_OSX_Watchdog_Timeout, ': "OSX Watchdog Timeout: ' ),
|
---|
874 | ( False, ktReason_XPCOM_NS_ERROR_CALL_FAILED,
|
---|
875 | 'Exception: 0x800706be (Call to remote object failed (NS_ERROR_CALL_FAILED))' ),
|
---|
876 | ( True, ktReason_Host_HostMemoryLow, 'HostMemoryLow' ),
|
---|
877 | ( True, ktReason_Host_HostMemoryLow, 'Failed to procure handy pages; rc=VERR_NO_MEMORY' ),
|
---|
878 | ( True, ktReason_Unknown_File_Not_Found,
|
---|
879 | 'Error: failed to start machine. Error message: File not found. (VERR_FILE_NOT_FOUND)' ),
|
---|
880 | ( True, ktReason_Unknown_File_Not_Found, # lump it in with file-not-found for now.
|
---|
881 | 'Error: failed to start machine. Error message: Not supported. (VERR_NOT_SUPPORTED)' ),
|
---|
882 | ( False, ktReason_Unknown_VM_Crash, 'txsDoConnectViaTcp: Machine state: Aborted' ),
|
---|
883 | ( True, ktReason_Host_Modprobe_Failed, 'Kernel driver not installed' ),
|
---|
884 | ( True, ktReason_OSInstall_Sata_no_BM, 'PCHS=14128/14134/8224' ),
|
---|
885 | ( True, ktReason_Host_DoubleFreeHeap, 'double free or corruption' ),
|
---|
886 | ];
|
---|
887 |
|
---|
888 | ## Things we search a VBoxHardening.log file for to figure out why something went bust.
|
---|
889 | katSimpleVBoxHardeningLogReasons = [
|
---|
890 | # ( Whether to stop on hit, reason tuple, needle text. )
|
---|
891 | ( True, ktReason_Host_DriverNotLoaded, 'Error opening VBoxDrvStub: STATUS_OBJECT_NAME_NOT_FOUND' ),
|
---|
892 | ( True, ktReason_Host_NotSignedWithBuildCert, 'Not signed with the build certificate' ),
|
---|
893 | ];
|
---|
894 |
|
---|
895 | ## Things we search a kernel.log file for to figure out why something went bust.
|
---|
896 | katSimpleKernelLogReasons = [
|
---|
897 | # ( Whether to stop on hit, reason tuple, needle text. )
|
---|
898 | ( True, ktReason_Panic_HugeMemory, 'mm/huge_memory.c:1988' ),
|
---|
899 | ( True, ktReason_Panic_IOAPICDoesntWork, 'IO-APIC + timer doesn''t work' ),
|
---|
900 | ( True, ktReason_Panic_TxUnitHang, 'Detected Tx Unit Hang' ),
|
---|
901 | ];
|
---|
902 |
|
---|
903 | ## Things we search the _RIGHT_ _STRIPPED_ vgatext for.
|
---|
904 | katSimpleVgaTextReasons = [
|
---|
905 | # ( Whether to stop on hit, reason tuple, needle text. )
|
---|
906 | ( True, ktReason_Panic_MP_BIOS_IO_APIC,
|
---|
907 | "..MP-BIOS bug: 8254 timer not connected to IO-APIC\n\n" ),
|
---|
908 | ( True, ktReason_Panic_MP_BIOS_IO_APIC,
|
---|
909 | "..MP-BIOS bug: 8254 timer not connected to IO-APIC\n"
|
---|
910 | "...trying to set up timer (IRQ0) through the 8259A ... failed.\n"
|
---|
911 | "...trying to set up timer as Virtual Wire IRQ... failed.\n"
|
---|
912 | "...trying to set up timer as ExtINT IRQ... failed :(.\n"
|
---|
913 | "Kernel panic - not syncing: IO-APIC + timer doesn't work! Boot with apic=debug\n"
|
---|
914 | "and send a report. Then try booting with the 'noapic' option\n"
|
---|
915 | "\n" ),
|
---|
916 | ( True, ktReason_OSInstall_GRUB_hang,
|
---|
917 | "-----\nGRUB Loading stage2..\n\n\n\n" ),
|
---|
918 | ( True, ktReason_Panic_BootManagerC000000F,
|
---|
919 | "Windows failed to start. A recent hardware or software change might be the" ),
|
---|
920 | ( True, ktReason_BootManager_Image_corrupt,
|
---|
921 | "BOOTMGR image is corrupt. The system cannot boot." ),
|
---|
922 | ];
|
---|
923 |
|
---|
924 | ## Things we search for in the info.txt file. Require handlers for now.
|
---|
925 | katInfoTextHandlers = [
|
---|
926 | # ( Trigger text, handler method )
|
---|
927 | ( "kvm_lock_spinning", investigateInfoKvmLockSpinning ),
|
---|
928 | ( "HalReturnToFirmware", investigateInfoHalReturnToFirmware ),
|
---|
929 | ];
|
---|
930 |
|
---|
931 | ## Mapping screenshot/failure SHA-256 hashes to failure reasons.
|
---|
932 | katSimpleScreenshotHashReasons = [
|
---|
933 | # ( Whether to stop on hit, reason tuple, lowercased sha-256 of PIL.Image.tostring output )
|
---|
934 | ( True, ktReason_BSOD_Recovery, '576f8e38d62b311cac7e3dc3436a0d0b9bd8cfd7fa9c43aafa95631520a45eac' ),
|
---|
935 | ( True, ktReason_BSOD_Automatic_Repair, 'c6a72076cc619937a7a39cfe9915b36d94cee0d4e3ce5ce061485792dcee2749' ),
|
---|
936 | ( True, ktReason_BSOD_Automatic_Repair, '26c4d8a724ff2c5e1051f3d5b650dbda7b5fdee0aa3e3c6059797f7484a515df' ),
|
---|
937 | ( True, ktReason_BSOD_0000007F, '57e1880619e13042a87100e7a38c8974b85ce3866501be621bea0cc696bb2c63' ),
|
---|
938 | ( True, ktReason_BSOD_000000D1, '134621281f00a3f8aeeb7660064bffbf6187ed56d5852142328d0bcb18ef0ede' ),
|
---|
939 | ( True, ktReason_BSOD_000000D1, '279f11258150c9d2fef041eca65501f3141da8df39256d8f6377e897e3b45a93' ),
|
---|
940 | ( True, ktReason_BSOD_C0000225, 'bd13a144be9dcdfb16bc863ff4c8f02a86e263c174f2cd5ffd27ca5f3aa31789' ),
|
---|
941 | ( True, ktReason_BSOD_C0000225, '8348b465e7ee9e59dd4e785880c57fd8677de05d11ac21e786bfde935307b42f' ),
|
---|
942 | ( True, ktReason_BSOD_C0000225, '1316e1fc818a73348412788e6910b8c016f237d8b4e15b20caf4a866f7a7840e' ),
|
---|
943 | ( True, ktReason_BSOD_C0000225, '54e0acbff365ce20a85abbe42bcd53647b8b9e80c68e45b2cd30e86bf177a0b5' ),
|
---|
944 | ( True, ktReason_BSOD_C0000225, '50fec50b5199923fa48b3f3e782687cc381e1c8a788ebda14e6a355fbe3bb1b3' ),
|
---|
945 | ];
|
---|
946 |
|
---|
947 | def investigateVMResult(self, oCaseFile, oFailedResult, sResultLog):
|
---|
948 | """
|
---|
949 | Investigates a failed VM run.
|
---|
950 | """
|
---|
951 |
|
---|
952 | def investigateLogSet():
|
---|
953 | """
|
---|
954 | Investigates the current set of VM related logs.
|
---|
955 | """
|
---|
956 | self.dprint('investigateLogSet: lengths: result log %u, VM log %u, kernel log %u, vga text %u, info text %u'
|
---|
957 | % ( len(sResultLog if sResultLog else ''),
|
---|
958 | len(sVMLog if sVMLog else ''),
|
---|
959 | len(sKrnlLog if sKrnlLog else ''),
|
---|
960 | len(sVgaText if sVgaText else ''),
|
---|
961 | len(sInfoText if sInfoText else ''), ));
|
---|
962 |
|
---|
963 | #self.dprint(u'main.log<<<\n%s\n<<<\n' % (sResultLog,));
|
---|
964 | #self.dprint(u'vbox.log<<<\n%s\n<<<\n' % (sVMLog,));
|
---|
965 | #self.dprint(u'krnl.log<<<\n%s\n<<<\n' % (sKrnlLog,));
|
---|
966 | #self.dprint(u'vgatext.txt<<<\n%s\n<<<\n' % (sVgaText,));
|
---|
967 | #self.dprint(u'info.txt<<<\n%s\n<<<\n' % (sInfoText,));
|
---|
968 |
|
---|
969 | # TODO: more
|
---|
970 |
|
---|
971 | #
|
---|
972 | # Look for BSODs. Some stupid stupid inconsistencies in reason and log messages here, so don't try prettify this.
|
---|
973 | #
|
---|
974 | sDetails = self.findInAnyAndReturnRestOfLine([ sVMLog, sResultLog ],
|
---|
975 | 'GIM: HyperV: Guest indicates a fatal condition! P0=');
|
---|
976 | if sDetails is not None:
|
---|
977 | # P0=%#RX64 P1=%#RX64 P2=%#RX64 P3=%#RX64 P4=%#RX64 "
|
---|
978 | sKey = sDetails.split(' ', 1)[0];
|
---|
979 | try: sKey = '0x%08X' % (int(sKey, 16),);
|
---|
980 | except: pass;
|
---|
981 | if sKey in self.asBsodReasons:
|
---|
982 | tReason = ( self.ksBsodCategory, sKey );
|
---|
983 | elif sKey.lower() in self.asBsodReasons: # just in case.
|
---|
984 | tReason = ( self.ksBsodCategory, sKey.lower() );
|
---|
985 | else:
|
---|
986 | self.dprint(u'BSOD "%s" not found in %s;' % (sKey, self.asBsodReasons));
|
---|
987 | tReason = ( self.ksBsodCategory, self.ksBsodAddNew );
|
---|
988 | return oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult, sComment = sDetails.strip());
|
---|
989 |
|
---|
990 | #
|
---|
991 | # Look for linux panic.
|
---|
992 | #
|
---|
993 | if sKrnlLog is not None:
|
---|
994 | for fStopOnHit, tReason, sNeedle in self.katSimpleKernelLogReasons:
|
---|
995 | if sKrnlLog.find(sNeedle) > 0:
|
---|
996 | oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult);
|
---|
997 | if fStopOnHit:
|
---|
998 | return True;
|
---|
999 | fFoundSomething = True;
|
---|
1000 |
|
---|
1001 | #
|
---|
1002 | # Loop thru the simple stuff.
|
---|
1003 | #
|
---|
1004 | fFoundSomething = False;
|
---|
1005 | for fStopOnHit, tReason, sNeedle in self.katSimpleMainAndVmLogReasons:
|
---|
1006 | if sResultLog.find(sNeedle) > 0 or (sVMLog is not None and sVMLog.find(sNeedle) > 0):
|
---|
1007 | oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult);
|
---|
1008 | if fStopOnHit:
|
---|
1009 | return True;
|
---|
1010 | fFoundSomething = True;
|
---|
1011 |
|
---|
1012 | # Continue with vga text.
|
---|
1013 | if sVgaText:
|
---|
1014 | for fStopOnHit, tReason, sNeedle in self.katSimpleVgaTextReasons:
|
---|
1015 | if sVgaText.find(sNeedle) > 0:
|
---|
1016 | oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult);
|
---|
1017 | if fStopOnHit:
|
---|
1018 | return True;
|
---|
1019 | fFoundSomething = True;
|
---|
1020 | _ = sInfoText;
|
---|
1021 |
|
---|
1022 | # Continue with screen hashes.
|
---|
1023 | if sScreenHash is not None:
|
---|
1024 | for fStopOnHit, tReason, sHash in self.katSimpleScreenshotHashReasons:
|
---|
1025 | if sScreenHash == sHash:
|
---|
1026 | oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult);
|
---|
1027 | if fStopOnHit:
|
---|
1028 | return True;
|
---|
1029 | fFoundSomething = True;
|
---|
1030 |
|
---|
1031 | # Check VBoxHardening.log.
|
---|
1032 | if sNtHardLog is not None:
|
---|
1033 | for fStopOnHit, tReason, sNeedle in self.katSimpleVBoxHardeningLogReasons:
|
---|
1034 | if sNtHardLog.find(sNeedle) > 0:
|
---|
1035 | oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult);
|
---|
1036 | if fStopOnHit:
|
---|
1037 | return True;
|
---|
1038 | fFoundSomething = True;
|
---|
1039 |
|
---|
1040 | #
|
---|
1041 | # Complicated stuff.
|
---|
1042 | #
|
---|
1043 | dLogs = {
|
---|
1044 | 'sVMLog': sVMLog,
|
---|
1045 | 'sNtHardLog': sNtHardLog,
|
---|
1046 | 'sScreenHash': sScreenHash,
|
---|
1047 | 'sKrnlLog': sKrnlLog,
|
---|
1048 | 'sVgaText': sVgaText,
|
---|
1049 | 'sInfoText': sInfoText,
|
---|
1050 | };
|
---|
1051 |
|
---|
1052 | # info.txt.
|
---|
1053 | if sInfoText:
|
---|
1054 | for sNeedle, fnHandler in self.katInfoTextHandlers:
|
---|
1055 | if sInfoText.find(sNeedle) > 0:
|
---|
1056 | (fStop, tReason) = fnHandler(self, oCaseFile, sInfoText, dLogs);
|
---|
1057 | if tReason is not None:
|
---|
1058 | oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult);
|
---|
1059 | if fStop:
|
---|
1060 | return True;
|
---|
1061 | fFoundSomething = True;
|
---|
1062 |
|
---|
1063 | #
|
---|
1064 | # Check for repeated reboots...
|
---|
1065 | #
|
---|
1066 | if sVMLog is not None:
|
---|
1067 | cResets = sVMLog.count('Changing the VM state from \'RUNNING\' to \'RESETTING\'');
|
---|
1068 | if cResets > 10:
|
---|
1069 | return oCaseFile.noteReasonForId(self.ktReason_Unknown_Reboot_Loop, oFailedResult.idTestResult,
|
---|
1070 | sComment = 'Counted %s reboots' % (cResets,));
|
---|
1071 |
|
---|
1072 | return fFoundSomething;
|
---|
1073 |
|
---|
1074 | #
|
---|
1075 | # Check if we got any VM or/and kernel logs. Treat them as sets in
|
---|
1076 | # case we run multiple VMs here (this is of course ASSUMING they
|
---|
1077 | # appear in the order that terminateVmBySession uploads them).
|
---|
1078 | #
|
---|
1079 | cTimes = 0;
|
---|
1080 | sVMLog = None;
|
---|
1081 | sNtHardLog = None;
|
---|
1082 | sScreenHash = None;
|
---|
1083 | sKrnlLog = None;
|
---|
1084 | sVgaText = None;
|
---|
1085 | sInfoText = None;
|
---|
1086 | for oFile in oFailedResult.aoFiles:
|
---|
1087 | if oFile.sKind == TestResultFileData.ksKind_LogReleaseVm:
|
---|
1088 | if 'VBoxHardening.log' not in oFile.sFile:
|
---|
1089 | if sVMLog is not None:
|
---|
1090 | if investigateLogSet() is True:
|
---|
1091 | return True;
|
---|
1092 | cTimes += 1;
|
---|
1093 | sInfoText = None;
|
---|
1094 | sVgaText = None;
|
---|
1095 | sKrnlLog = None;
|
---|
1096 | sScreenHash = None;
|
---|
1097 | sNtHardLog = None;
|
---|
1098 | sVMLog = oCaseFile.getLogFile(oFile);
|
---|
1099 | else:
|
---|
1100 | sNtHardLog = oCaseFile.getLogFile(oFile);
|
---|
1101 | elif oFile.sKind == TestResultFileData.ksKind_LogGuestKernel:
|
---|
1102 | sKrnlLog = oCaseFile.getLogFile(oFile);
|
---|
1103 | elif oFile.sKind == TestResultFileData.ksKind_InfoVgaText:
|
---|
1104 | sVgaText = '\n'.join([sLine.rstrip() for sLine in oCaseFile.getLogFile(oFile).split('\n')]);
|
---|
1105 | elif oFile.sKind == TestResultFileData.ksKind_InfoCollection:
|
---|
1106 | sInfoText = oCaseFile.getLogFile(oFile);
|
---|
1107 | elif oFile.sKind == TestResultFileData.ksKind_ScreenshotFailure:
|
---|
1108 | sScreenHash = oCaseFile.getScreenshotSha256(oFile);
|
---|
1109 | if sScreenHash is not None:
|
---|
1110 | sScreenHash = sScreenHash.lower();
|
---|
1111 | self.vprint(u'%s %s' % ( sScreenHash, oFile.sFile,));
|
---|
1112 |
|
---|
1113 | if ( sVMLog is not None \
|
---|
1114 | or sNtHardLog is not None \
|
---|
1115 | or cTimes == 0) \
|
---|
1116 | and investigateLogSet() is True:
|
---|
1117 | return True;
|
---|
1118 |
|
---|
1119 | return None;
|
---|
1120 |
|
---|
1121 |
|
---|
1122 | def isResultFromVMRun(self, oFailedResult, sResultLog):
|
---|
1123 | """
|
---|
1124 | Checks if this result and corresponding log snippet looks like a VM run.
|
---|
1125 | """
|
---|
1126 |
|
---|
1127 | # Look for startVmEx/ startVmAndConnectToTxsViaTcp and similar output in the log.
|
---|
1128 | if sResultLog.find(' startVm') > 0:
|
---|
1129 | return True;
|
---|
1130 |
|
---|
1131 | # Any other indicators? No?
|
---|
1132 | _ = oFailedResult;
|
---|
1133 | return False;
|
---|
1134 |
|
---|
1135 | def investigateVBoxVMTest(self, oCaseFile, fSingleVM):
|
---|
1136 | """
|
---|
1137 | Checks out a VBox VM test.
|
---|
1138 |
|
---|
1139 | This is generic investigation of a test running one or more VMs, like
|
---|
1140 | for example a smoke test or a guest installation test.
|
---|
1141 |
|
---|
1142 | The fSingleVM parameter is a hint, which probably won't come in useful.
|
---|
1143 | """
|
---|
1144 | _ = fSingleVM;
|
---|
1145 |
|
---|
1146 | #
|
---|
1147 | # Get a list of test result failures we should be looking into and the main log.
|
---|
1148 | #
|
---|
1149 | aoFailedResults = oCaseFile.oTree.getListOfFailures();
|
---|
1150 | sMainLog = oCaseFile.getMainLog();
|
---|
1151 |
|
---|
1152 | #
|
---|
1153 | # There are a set of errors ending up on the top level result record.
|
---|
1154 | # Should deal with these first.
|
---|
1155 | #
|
---|
1156 | if len(aoFailedResults) == 1 and aoFailedResults[0] == oCaseFile.oTree:
|
---|
1157 | # Check if we've just got that XPCOM client smoke test shutdown issue. This will currently always
|
---|
1158 | # be reported on the top result because vboxinstall.py doesn't add an error for it. It is easy to
|
---|
1159 | # ignore other failures in the test if we're not a little bit careful here.
|
---|
1160 | if sMainLog.find('vboxinstaller: Exit code: -11 (') > 0:
|
---|
1161 | oCaseFile.noteReason(self.ktReason_XPCOM_Exit_Minus_11);
|
---|
1162 | return self.caseClosed(oCaseFile);
|
---|
1163 |
|
---|
1164 | # Hang after starting VBoxSVC (e.g. idTestSet=136307258)
|
---|
1165 | if self.isThisFollowedByTheseLines(sMainLog, 'oVBoxMgr=<vboxapi.VirtualBoxManager object at',
|
---|
1166 | (' Timeout: ', ' Attempting to abort child...',) ):
|
---|
1167 | if sMainLog.find('*** glibc detected *** /') > 0:
|
---|
1168 | oCaseFile.noteReason(self.ktReason_XPCOM_VBoxSVC_Hang_Plus_Heap_Corruption);
|
---|
1169 | else:
|
---|
1170 | oCaseFile.noteReason(self.ktReason_XPCOM_VBoxSVC_Hang);
|
---|
1171 | return self.caseClosed(oCaseFile);
|
---|
1172 |
|
---|
1173 | # Look for heap corruption without visible hang.
|
---|
1174 | if sMainLog.find('*** glibc detected *** /') > 0 \
|
---|
1175 | or sMainLog.find("-1073740940") > 0: # STATUS_HEAP_CORRUPTION / 0xc0000374
|
---|
1176 | oCaseFile.noteReason(self.ktReason_Unknown_Heap_Corruption);
|
---|
1177 | return self.caseClosed(oCaseFile);
|
---|
1178 |
|
---|
1179 | # Out of memory w/ timeout.
|
---|
1180 | if sMainLog.find('sErrId=HostMemoryLow') > 0:
|
---|
1181 | oCaseFile.noteReason(self.ktReason_Host_HostMemoryLow);
|
---|
1182 | return self.caseClosed(oCaseFile);
|
---|
1183 |
|
---|
1184 | # Stale files like vts_rm.exe (windows).
|
---|
1185 | offEnd = sMainLog.rfind('*** The test driver exits successfully. ***');
|
---|
1186 | if offEnd > 0 and sMainLog.find('[Error 145] The directory is not empty: ', offEnd) > 0:
|
---|
1187 | oCaseFile.noteReason(self.ktReason_Ignore_Stale_Files);
|
---|
1188 | return self.caseClosed(oCaseFile);
|
---|
1189 |
|
---|
1190 | #
|
---|
1191 | # XPCOM screwup
|
---|
1192 | #
|
---|
1193 | if sMainLog.find('AttributeError: \'NoneType\' object has no attribute \'addObserver\'') > 0:
|
---|
1194 | oCaseFile.noteReason(self.ktReason_Buggy_Build_Broken_Build);
|
---|
1195 | return self.caseClosed(oCaseFile);
|
---|
1196 |
|
---|
1197 | #
|
---|
1198 | # Go thru each failed result.
|
---|
1199 | #
|
---|
1200 | for oFailedResult in aoFailedResults:
|
---|
1201 | self.dprint(u'Looking at test result #%u - %s' % (oFailedResult.idTestResult, oFailedResult.getFullName(),));
|
---|
1202 | sResultLog = TestSetData.extractLogSectionElapsed(sMainLog, oFailedResult.tsCreated, oFailedResult.tsElapsed);
|
---|
1203 | if oFailedResult.sName == 'Installing VirtualBox':
|
---|
1204 | self.investigateInstallUninstallFailure(oCaseFile, oFailedResult, sResultLog, fInstall = True)
|
---|
1205 |
|
---|
1206 | elif oFailedResult.sName == 'Uninstalling VirtualBox':
|
---|
1207 | self.investigateInstallUninstallFailure(oCaseFile, oFailedResult, sResultLog, fInstall = False)
|
---|
1208 |
|
---|
1209 | elif self.isResultFromVMRun(oFailedResult, sResultLog):
|
---|
1210 | self.investigateVMResult(oCaseFile, oFailedResult, sResultLog);
|
---|
1211 |
|
---|
1212 | elif sResultLog.find('most likely not unique') > 0:
|
---|
1213 | oCaseFile.noteReasonForId(self.ktReason_Host_NetworkMisconfiguration, oFailedResult.idTestResult)
|
---|
1214 | elif sResultLog.find('Exception: 0x800706be (Call to remote object failed (NS_ERROR_CALL_FAILED))') > 0:
|
---|
1215 | oCaseFile.noteReasonForId(self.ktReason_XPCOM_NS_ERROR_CALL_FAILED, oFailedResult.idTestResult);
|
---|
1216 |
|
---|
1217 | elif sResultLog.find('The machine is not mutable (state is ') > 0:
|
---|
1218 | self.vprint('Ignoring "machine not mutable" error as it is probably due to an earlier problem');
|
---|
1219 | oCaseFile.noteReasonForId(self.ktHarmless, oFailedResult.idTestResult);
|
---|
1220 |
|
---|
1221 | elif sResultLog.find('** error: no action was specified') > 0 \
|
---|
1222 | or sResultLog.find('(len(self._asXml, asText))') > 0:
|
---|
1223 | oCaseFile.noteReasonForId(self.ktReason_Ignore_Buggy_Test_Driver, oFailedResult.idTestResult);
|
---|
1224 |
|
---|
1225 | else:
|
---|
1226 | self.vprint(u'TODO: Cannot place idTestResult=%u - %s' % (oFailedResult.idTestResult, oFailedResult.sName,));
|
---|
1227 | self.dprint(u'%s + %s <<\n%s\n<<' % (oFailedResult.tsCreated, oFailedResult.tsElapsed, sResultLog,));
|
---|
1228 |
|
---|
1229 | #
|
---|
1230 | # Report home and close the case if we got them all, otherwise log it.
|
---|
1231 | #
|
---|
1232 | if len(oCaseFile.dReasonForResultId) >= len(aoFailedResults):
|
---|
1233 | return self.caseClosed(oCaseFile);
|
---|
1234 |
|
---|
1235 | if oCaseFile.dReasonForResultId:
|
---|
1236 | self.vprint(u'TODO: Got %u out of %u - close, but no cigar. :-/'
|
---|
1237 | % (len(oCaseFile.dReasonForResultId), len(aoFailedResults)));
|
---|
1238 | else:
|
---|
1239 | self.vprint(u'XXX: Could not figure out anything at all! :-(');
|
---|
1240 | return False;
|
---|
1241 |
|
---|
1242 |
|
---|
1243 | def reasoningFailures(self):
|
---|
1244 | """
|
---|
1245 | Guess the reason for failures.
|
---|
1246 | """
|
---|
1247 | #
|
---|
1248 | # Get a list of failed test sets without any assigned failure reason.
|
---|
1249 | #
|
---|
1250 | cGot = 0;
|
---|
1251 | aoTestSets = self.oTestSetLogic.fetchFailedSetsWithoutReason(cHoursBack = self.oConfig.cHoursBack, tsNow = self.tsNow);
|
---|
1252 | for oTestSet in aoTestSets:
|
---|
1253 | self.dprint(u'');
|
---|
1254 | self.dprint(u'reasoningFailures: Checking out test set #%u, status %s' % ( oTestSet.idTestSet, oTestSet.enmStatus,))
|
---|
1255 |
|
---|
1256 | #
|
---|
1257 | # Open a case file and assign it to the right investigator.
|
---|
1258 | #
|
---|
1259 | (oTree, _ ) = self.oTestResultLogic.fetchResultTree(oTestSet.idTestSet);
|
---|
1260 | oBuild = BuildDataEx().initFromDbWithId( self.oDb, oTestSet.idBuild, oTestSet.tsCreated);
|
---|
1261 | oTestBox = TestBoxData().initFromDbWithGenId( self.oDb, oTestSet.idGenTestBox);
|
---|
1262 | oTestGroup = TestGroupData().initFromDbWithId( self.oDb, oTestSet.idTestGroup, oTestSet.tsCreated);
|
---|
1263 | oTestCase = TestCaseDataEx().initFromDbWithGenId( self.oDb, oTestSet.idGenTestCase, oTestSet.tsConfig);
|
---|
1264 |
|
---|
1265 | oCaseFile = VirtualTestSheriffCaseFile(self, oTestSet, oTree, oBuild, oTestBox, oTestGroup, oTestCase);
|
---|
1266 |
|
---|
1267 | if oTestSet.enmStatus == TestSetData.ksTestStatus_BadTestBox:
|
---|
1268 | self.dprint(u'investigateBadTestBox is taking over %s.' % (oCaseFile.sLongName,));
|
---|
1269 | fRc = self.investigateBadTestBox(oCaseFile);
|
---|
1270 |
|
---|
1271 | elif oCaseFile.isVBoxUnitTest():
|
---|
1272 | self.dprint(u'investigateVBoxUnitTest is taking over %s.' % (oCaseFile.sLongName,));
|
---|
1273 | fRc = self.investigateVBoxUnitTest(oCaseFile);
|
---|
1274 |
|
---|
1275 | elif oCaseFile.isVBoxInstallTest():
|
---|
1276 | self.dprint(u'investigateVBoxVMTest is taking over %s.' % (oCaseFile.sLongName,));
|
---|
1277 | fRc = self.investigateVBoxVMTest(oCaseFile, fSingleVM = True);
|
---|
1278 |
|
---|
1279 | elif oCaseFile.isVBoxUSBTest():
|
---|
1280 | self.dprint(u'investigateVBoxVMTest is taking over %s.' % (oCaseFile.sLongName,));
|
---|
1281 | fRc = self.investigateVBoxVMTest(oCaseFile, fSingleVM = True);
|
---|
1282 |
|
---|
1283 | elif oCaseFile.isVBoxStorageTest():
|
---|
1284 | self.dprint(u'investigateVBoxVMTest is taking over %s.' % (oCaseFile.sLongName,));
|
---|
1285 | fRc = self.investigateVBoxVMTest(oCaseFile, fSingleVM = True);
|
---|
1286 |
|
---|
1287 | elif oCaseFile.isVBoxGAsTest():
|
---|
1288 | self.dprint(u'investigateVBoxVMTest is taking over %s.' % (oCaseFile.sLongName,));
|
---|
1289 | fRc = self.investigateVBoxVMTest(oCaseFile, fSingleVM = True);
|
---|
1290 |
|
---|
1291 | elif oCaseFile.isVBoxAPITest():
|
---|
1292 | self.dprint(u'investigateVBoxVMTest is taking over %s.' % (oCaseFile.sLongName,));
|
---|
1293 | fRc = self.investigateVBoxVMTest(oCaseFile, fSingleVM = True);
|
---|
1294 |
|
---|
1295 | elif oCaseFile.isVBoxBenchmarkTest():
|
---|
1296 | self.dprint(u'investigateVBoxVMTest is taking over %s.' % (oCaseFile.sLongName,));
|
---|
1297 | fRc = self.investigateVBoxVMTest(oCaseFile, fSingleVM = False);
|
---|
1298 |
|
---|
1299 | elif oCaseFile.isVBoxSmokeTest():
|
---|
1300 | self.dprint(u'investigateVBoxVMTest is taking over %s.' % (oCaseFile.sLongName,));
|
---|
1301 | fRc = self.investigateVBoxVMTest(oCaseFile, fSingleVM = False);
|
---|
1302 |
|
---|
1303 | else:
|
---|
1304 | self.vprint(u'reasoningFailures: Unable to classify test set: %s' % (oCaseFile.sLongName,));
|
---|
1305 | fRc = False;
|
---|
1306 | cGot += fRc is True;
|
---|
1307 |
|
---|
1308 | self.vprint(u'reasoningFailures: Got %u out of %u' % (cGot, len(aoTestSets), ));
|
---|
1309 | return 0;
|
---|
1310 |
|
---|
1311 |
|
---|
1312 | def main(self):
|
---|
1313 | """
|
---|
1314 | The 'main' function.
|
---|
1315 | Return exit code (0, 1, etc).
|
---|
1316 | """
|
---|
1317 | # Database stuff.
|
---|
1318 | self.oDb = TMDatabaseConnection()
|
---|
1319 | self.oTestResultLogic = TestResultLogic(self.oDb);
|
---|
1320 | self.oTestSetLogic = TestSetLogic(self.oDb);
|
---|
1321 | self.oFailureReasonLogic = FailureReasonLogic(self.oDb);
|
---|
1322 | self.oTestResultFailureLogic = TestResultFailureLogic(self.oDb);
|
---|
1323 | self.asBsodReasons = self.oFailureReasonLogic.fetchForSheriffByNamedCategory(self.ksBsodCategory);
|
---|
1324 | self.asUnitTestReasons = self.oFailureReasonLogic.fetchForSheriffByNamedCategory(self.ksUnitTestCategory);
|
---|
1325 |
|
---|
1326 | # Get a fix on our 'now' before we do anything..
|
---|
1327 | self.oDb.execute('SELECT CURRENT_TIMESTAMP - interval \'%s hours\'', (self.oConfig.cStartHoursAgo,));
|
---|
1328 | self.tsNow = self.oDb.fetchOne();
|
---|
1329 |
|
---|
1330 | # If we're suppost to commit anything we need to get our user ID.
|
---|
1331 | rcExit = 0;
|
---|
1332 | if self.oConfig.fRealRun:
|
---|
1333 | self.oLogin = UserAccountLogic(self.oDb).tryFetchAccountByLoginName(VirtualTestSheriff.ksLoginName);
|
---|
1334 | if self.oLogin is None:
|
---|
1335 | rcExit = self.eprint('Cannot find my user account "%s"!' % (VirtualTestSheriff.ksLoginName,));
|
---|
1336 | else:
|
---|
1337 | self.uidSelf = self.oLogin.uid;
|
---|
1338 |
|
---|
1339 | #
|
---|
1340 | # Do the stuff.
|
---|
1341 | #
|
---|
1342 | if rcExit == 0:
|
---|
1343 | rcExit = self.selfCheck();
|
---|
1344 | if rcExit == 0:
|
---|
1345 | rcExit = self.badTestBoxManagement();
|
---|
1346 | rcExit2 = self.reasoningFailures();
|
---|
1347 | if rcExit == 0:
|
---|
1348 | rcExit = rcExit2;
|
---|
1349 | # Redo the bad testbox management after failure reasons have been assigned (got timing issues).
|
---|
1350 | if rcExit == 0:
|
---|
1351 | rcExit = self.badTestBoxManagement();
|
---|
1352 |
|
---|
1353 | # Cleanup.
|
---|
1354 | self.oFailureReasonLogic = None;
|
---|
1355 | self.oTestResultFailureLogic = None;
|
---|
1356 | self.oTestSetLogic = None;
|
---|
1357 | self.oTestResultLogic = None;
|
---|
1358 | self.oDb.close();
|
---|
1359 | self.oDb = None;
|
---|
1360 | if self.oLogFile is not None:
|
---|
1361 | self.oLogFile.close();
|
---|
1362 | self.oLogFile = None;
|
---|
1363 | return rcExit;
|
---|
1364 |
|
---|
1365 | if __name__ == '__main__':
|
---|
1366 | sys.exit(VirtualTestSheriff().main());
|
---|
1367 |
|
---|