- Timestamp:
- May 31, 2016 9:08:04 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 107617
- Location:
- trunk/src/VBox/ValidationKit/testdriver
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/reporter.py
r61189 r61323 168 168 """ 169 169 _ = oSrcFile; _ = sSrcFilename; _ = sAltName; _ = sDescription; _ = sKind; _ = sCaller; _ = sTsPrf; 170 return True; 171 172 def addLogString(self, sLog, sLogName, sAltName, sDescription, sKind, sCaller, sTsPrf): 173 """ 174 Adds the file to the report. 175 Returns True on success, False on failure. 176 """ 177 _ = sLog; _ = sLogName; _ = sAltName; _ = sDescription; _ = sKind; _ = sCaller; _ = sTsPrf; 170 178 return True; 171 179 … … 465 473 return fRc; 466 474 475 def addLogString(self, sLog, sLogName, sAltName, sDescription, sKind, sCaller, sTsPrf): 476 # Figure the destination filename. 477 iOtherFile = self.iOtherFile; 478 self.iOtherFile += 1; 479 sDstFilename = os.path.join(self.sLogDir, 'other-%d-%s.log' \ 480 % (iOtherFile, os.path.splitext(os.path.basename(sLogName))[0])); 481 self.log(0, '** Other log file: %s - %s (%s)' % (sDstFilename, sDescription, sLogName), sCaller, sTsPrf); 482 483 # Open the destination file and copy over the data. 484 fRc = True; 485 try: 486 oDstFile = utils.openNoInherit(sDstFilename, 'w'); 487 except Exception, oXcpt: 488 self.log(0, 'error opening %s: %s' % (sDstFilename, oXcpt), sCaller, sTsPrf); 489 else: 490 try: 491 oDstFile.write(sLog); 492 except Exception, oXcpt: 493 fRc = False; 494 self.log(0, 'error writing %s: %s' % (sDstFilename, oXcpt), sCaller, sTsPrf); 495 496 oDstFile.close(); 497 498 # Leave a mark in the XML log. 499 self._xmlWrite(['<LogFile timestamp="%s" filename="%s" source="%s" kind="%s" ok="%s">%s</LogFile>\n' 500 % (utils.getIsoTimestamp(), self._xmlEscAttr(os.path.basename(sDstFilename)), self._xmlEscAttr(sLogName), \ 501 self._xmlEscAttr(sKind), fRc, self._xmlEscAttr(sDescription))] ); 502 _ = sAltName; 503 return fRc; 504 467 505 def subXmlStart(self, oFileWrapper): 468 506 # Open a new file and just include it from the main XML. … … 682 720 return False; 683 721 722 def _doUploadString(self, sSrc, sSrcName, sDescription, sKind, sMime): 723 """ Uploads the given string as a separate file to the test manager. """ 724 725 # Prepare header and url. 726 dHeader = dict(self._dHttpHeader); 727 dHeader['Content-Type'] = 'application/octet-stream'; 728 self._writeOutput('%s: _doUploadString: sHeader=%s' % (utils.getTimePrefix(), dHeader,)); 729 self._writeOutput('%s: _doUploadString: size=%d' % (utils.getTimePrefix(), sys.getsizeof(sSrc),)); 730 731 from common import constants; 732 sUrl = self._sTmServerPath + '&' \ 733 + self._fnUrlEncode({ constants.tbreq.UPLOAD_PARAM_NAME: os.path.basename(sSrcName), 734 constants.tbreq.UPLOAD_PARAM_DESC: sDescription, 735 constants.tbreq.UPLOAD_PARAM_KIND: sKind, 736 constants.tbreq.UPLOAD_PARAM_MIME: sMime, 737 constants.tbreq.ALL_PARAM_ACTION: constants.tbreq.UPLOAD, 738 }); 739 740 # Retry loop. 741 secStart = utils.timestampSecond(); 742 while True: 743 try: 744 oConn = self._fnTmConnect(); 745 oConn.request('POST', sUrl, sSrc, dHeader); 746 fRc = self._processTmStatusResponse(oConn, '_doUploadString', fClose = True); 747 oConn.close(); 748 if fRc is not None: 749 return fRc; 750 except: 751 logXcpt('warning: exception during UPLOAD request'); 752 753 if utils.timestampSecond() - secStart >= self.kcSecTestManagerRetryTimeout: 754 self._writeOutput('%s: _doUploadString: Timed out.' % (utils.getTimePrefix(),)); 755 break; 756 self._writeOutput('%s: _doUploadString: Retrying...' % (utils.getTimePrefix(), )); 757 time.sleep(2); 758 759 return False; 760 684 761 def _xmlDoFlush(self, asXml, fRetry = False, fDtor = False): 685 762 """ … … 757 834 self.log(0, '*** UNKNOWN FILE "%s" - KIND "%s" - DESC "%s" ***' 758 835 % (sSrcFilename, sKind, sDescription), sCaller, sTsPrf); 836 return fRc; 837 838 def addLogString(self, sLog, sLogName, sAltName, sDescription, sKind, sCaller, sTsPrf): 839 fRc = True; 840 if sKind in [ 'text', 'log', ] or sKind.startswith('log/'): 841 self.log(0, '*** Uploading "%s" - KIND: "%s" - DESC: "%s" ***' 842 % (sLogName, sKind, sDescription), sCaller, sTsPrf); 843 self.xmlFlush(); 844 g_oLock.release(); 845 self._doUploadString(sLog, sAltName, sDescription, sKind, 'text/plain'); 846 g_oLock.acquire(); 847 else: 848 self.log(0, '*** UNKNOWN FILE "%s" - KIND "%s" - DESC "%s" ***' 849 % (sLogName, sKind, sDescription), sCaller, sTsPrf); 759 850 return fRc; 760 851 … … 1223 1314 return fRc; 1224 1315 1316 def addLogString(sLog, sLogName, sKind, sDescription = ''): 1317 """ 1318 Adds the specified log string to the report. 1319 1320 The sLog parameter sets the name of the log file. 1321 1322 The sDescription is a free form description of the log file. 1323 1324 The sKind parameter is for adding some machine parsable hint what kind of 1325 log file this really is. 1326 1327 Returns True on success, False on failure (no ENOENT errors are logged). 1328 """ 1329 sTsPrf = utils.getTimePrefix(); 1330 sCaller = utils.getCallerName(); 1331 fRc = False; 1332 1333 g_oLock.acquire(); 1334 fRc = g_oReporter.addLogString(sLog, sLogName, None, sDescription, sKind, sCaller, sTsPrf); 1335 g_oLock.release(); 1336 return fRc; 1337 1225 1338 def isLocal(): 1226 1339 """Is this a local reporter?""" -
trunk/src/VBox/ValidationKit/testdriver/vbox.py
r61154 r61323 801 801 self.fAlwaysUploadLogs = False; 802 802 self.fAlwaysUploadScreenshots = False; 803 self.fEnableDebugger = True; 803 804 804 805 # Quietly detect build and validation kit. … … 1523 1524 reporter.log(' --vbox-always-upload-screenshots'); 1524 1525 reporter.log(' Whether to always upload final screen shots, or only do so on failure.'); 1526 reporter.log(' --debugger, --no-debugger'); 1527 reporter.log(' Enables the VBox debugger, port at 5000'); 1528 reporter.log(' Default: --debugger'); 1525 1529 if self.oTestVmSet is not None: 1526 1530 self.oTestVmSet.showUsage(); … … 1624 1628 elif asArgs[iArg] == '--vbox-always-upload-screenshots': 1625 1629 self.fAlwaysUploadScreenshots = True; 1630 elif asArgs[iArg] == '--debugger': 1631 self.fEnableDebugger = True; 1632 elif asArgs[iArg] == '--no-debugger': 1633 self.fEnableDebugger = False; 1626 1634 else: 1627 1635 # Relevant for selecting VMs to test? … … 2124 2132 elif sFirmwareType == 'efi': 2125 2133 fRc = oSession.setFirmwareType(vboxcon.FirmwareType_EFI); 2134 if fRc and self.fEnableDebugger: 2135 fRc = oSession.setExtraData('VBoxInternal/DBGC/Enabled', '1'); 2126 2136 2127 2137 if fRc: fRc = oSession.saveSettings(); … … 2527 2537 # Take Screenshot and upload it (see below) to Test Manager if appropriate/requested. 2528 2538 # 2529 sLastScreenshotPath = None 2539 sLastScreenshotPath = None; 2530 2540 if fTakeScreenshot is True or self.fAlwaysUploadScreenshots or reporter.testErrorCount() > 0: 2531 sLastScreenshotPath = os.path.join(self.sScratchPath, "LastScreenshot-%s.png" % oSession.sName) 2532 fRc = oSession.takeScreenshot(sLastScreenshotPath) 2541 sLastScreenshotPath = os.path.join(self.sScratchPath, "LastScreenshot-%s.png" % oSession.sName); 2542 fRc = oSession.takeScreenshot(sLastScreenshotPath); 2533 2543 if fRc is not True: 2534 sLastScreenshotPath = None 2544 sLastScreenshotPath = None; 2545 2546 # 2547 # Query the OS kernel log from the debugger if appropriate/requested. 2548 # 2549 sOsKernelLog = None; 2550 if self.fAlwaysUploadLogs or reporter.testErrorCount() > 0: 2551 sOsKernelLog = oSession.queryOsKernelLog(); 2535 2552 2536 2553 # … … 2603 2620 else: 2604 2621 reporter.addLogFile(sLastScreenshotPath, 'screenshot/success', 'Last VM screenshot'); 2622 2623 # Add the guest OS log if it has been requested and taken successfully. 2624 if sOsKernelLog is not None: 2625 if reporter.testErrorCount() > 0: 2626 reporter.addLogString(sOsKernelLog, 'kern.log', 'log/guest/kernel/failure', 'Guest OS kernel log'); 2627 else: 2628 reporter.addLogString(sOsKernelLog, 'kern.log', 'log/guest/kernel/success', 'Guest OS kernel log'); 2605 2629 2606 2630 return fRc; -
trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py
r61105 r61323 2373 2373 2374 2374 # 2375 # IMachineDebugger wrappers. 2376 # 2377 2378 def queryOsKernelLog(self): 2379 """ 2380 Tries to get the OS kernel log using the VM debugger interface. 2381 2382 Returns string containing the kernel log on success. 2383 Returns None on failure. 2384 """ 2385 try: 2386 sPluginsLoaded = self.o.console.debugger.loadPlugIn('all'); 2387 if sPluginsLoaded == 'all': 2388 sOsDetected = self.o.console.debugger.detectOS(); 2389 if sOsDetected is not None: 2390 sOsKernelLog = self.o.console.debugger.queryOSKernelLog(0); 2391 else: 2392 reporter.log('Unable to load debugger plugins'); 2393 return None; 2394 except: 2395 reporter.logXcpt('Unable to query the OS kernel log'); 2396 return None; 2397 2398 return sOsKernelLog; 2399 2400 # 2375 2401 # Other methods. 2376 2402 #
Note:
See TracChangeset
for help on using the changeset viewer.