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