- Timestamp:
- Jun 7, 2016 9:05:29 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 107892
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/batch/virtual_test_sheriff.py
r61551 r61553 40 40 import sys; 41 41 import os; 42 import hashlib; 43 import StringIO; 42 44 from optparse import OptionParser; 45 from PIL import Image; 43 46 44 47 # Add Test Manager's modules path … … 182 185 self.oSheriff.vprint('Error opening the "%s" log file: %s' % (oFile.sFile, oSizeOrError,)); 183 186 return sContent; 187 188 def getScreenshotSha256(self, oFile): 189 """ 190 Tries to read the given screenshot file, uncompress it, and do SHA-2 191 on the raw pixels. 192 Returns SHA-2 digest string on success, None on failure. 193 """ 194 (oFile, _, _) = self.oTestSet.openFile(oFile.sFile, 'rb'); 195 try: 196 abImageFile = oFile.read(); 197 except Exception as oXcpt: 198 self.oSheriff.vprint('Error reading the "%s" image file: %s' % (oFile.sFile, oXcpt,)) 199 else: 200 try: 201 oImage = Image.open(StringIO.StringIO(abImageFile)); 202 except Exception as oXcpt: 203 self.oSheriff.vprint('Error opening the "%s" image bytes using PIL.Image.open: %s' % (oFile.sFile, oXcpt,)) 204 else: 205 try: 206 oHash = hashlib.sha256(); 207 oHash.update(oImage.tostring()); 208 except Exception as oXcpt: 209 self.oSheriff.vprint('Error hashing the uncompressed image bytes for "%s": %s' % (oFile.sFile, oXcpt,)) 210 else: 211 return oHash.hexdigest(); 212 return None; 213 184 214 185 215 … … 377 407 ## @name Failure reasons we know. 378 408 ## @{ 409 ktReason_BSOD_Recovery = ( 'BSOD', 'Recovery' ); 379 410 ktReason_Guru_Generic = ( 'Guru Meditations', 'Generic Guru Meditation' ); 380 411 ktReason_Guru_VERR_IEM_INSTR_NOT_IMPLEMENTED = ( 'Guru Meditations', 'VERR_IEM_INSTR_NOT_IMPLEMENTED' ); … … 630 661 ]; 631 662 663 ## Mapping screenshot/failure SHA-256 hashes to failure reasons. 664 katSimpleScreenshotHashReasons = [ 665 # ( Whether to stop on hit, reason tuple, lowercased sha-256 of PIL.Image.tostring output ) 666 ( True, ktReason_BSOD_Recovery, '576f8e38d62b311cac7e3dc3436a0d0b9bd8cfd7fa9c43aafa95631520a45eac' ), 667 ]; 668 632 669 def investigateVMResult(self, oCaseFile, oFailedResult, sResultLog): 633 670 """ … … 699 736 _ = sInfoText; 700 737 738 # Continue with screen hashes. 739 if sScreenHash is not None: 740 for fStopOnHit, tReason, sHash in self.katSimpleScreenshotHashReasons: 741 if sScreenHash == sHash: 742 oCaseFile.noteReasonForId(tReason, oFailedResult.idTestResult); 743 if fStopOnHit: 744 return True; 745 fFoundSomething = True; 746 701 747 # 702 748 # Check for repeated reboots... … … 714 760 # appear in the order that terminateVmBySession uploads them). 715 761 # 716 sVMLog = None; 717 sKrnlLog = None; 718 sVgaText = None; 719 sInfoText = None; 762 sVMLog = None; 763 sScreenHash = None; 764 sKrnlLog = None; 765 sVgaText = None; 766 sInfoText = None; 720 767 for oFile in oFailedResult.aoFiles: 721 768 if oFile.sKind == TestResultFileData.ksKind_LogReleaseVm: … … 723 770 if investigateLogSet() is True: 724 771 return True; 725 sKrnlLog = None; 726 sVgaText = None; 727 sInfoText = None; 728 sVMLog = oCaseFile.getLogFile(oFile); 772 sKrnlLog = None; 773 sScreenHash = None; 774 sVgaText = None; 775 sInfoText = None; 776 sVMLog = oCaseFile.getLogFile(oFile); 729 777 elif oFile.sKind == TestResultFileData.ksKind_LogGuestKernel: 730 778 sKrnlLog = oCaseFile.getLogFile(oFile); … … 733 781 elif oFile.sKind == TestResultFileData.ksKind_InfoCollection: 734 782 sInfoText = oCaseFile.getLogFile(oFile); 783 elif oFile.sKind == TestResultFileData.ksKind_ScreenshotFailure: 784 sScreenHash = oCaseFile.getScreenshotSha256(oFile); 785 if sScreenHash is not None: 786 sScreenHash = sScreenHash.tolower(); 787 self.vprint('%s %s' % ( sScreenHash, oFile.sFile,)); 735 788 if sVMLog is not None and investigateLogSet() is True: 736 789 return True;
Note:
See TracChangeset
for help on using the changeset viewer.