Changeset 65815 in vbox
- Timestamp:
- Feb 20, 2017 3:35:24 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/reporter.py
r65460 r65815 845 845 self.xmlFlush(); 846 846 g_oLock.release(); 847 self._doUploadFile(oSrcFile, sAltName, sDescription, sKind, 'text/plain'); 848 g_oLock.acquire(); 847 try: 848 self._doUploadFile(oSrcFile, sAltName, sDescription, sKind, 'text/plain'); 849 finally: 850 g_oLock.acquire(); 849 851 elif sKind.startswith('screenshot/'): 850 852 self.log(0, '*** Uploading "%s" - KIND: "%s" - DESC: "%s" ***' … … 852 854 self.xmlFlush(); 853 855 g_oLock.release(); 854 self._doUploadFile(oSrcFile, sAltName, sDescription, sKind, 'image/png'); 855 g_oLock.acquire(); 856 try: 857 self._doUploadFile(oSrcFile, sAltName, sDescription, sKind, 'image/png'); 858 finally: 859 g_oLock.acquire(); 856 860 elif sKind.startswith('misc/'): 857 861 self.log(0, '*** Uploading "%s" - KIND: "%s" - DESC: "%s" ***' … … 859 863 self.xmlFlush(); 860 864 g_oLock.release(); 861 self._doUploadFile(oSrcFile, sAltName, sDescription, sKind, 'application/octet-stream'); 862 g_oLock.acquire(); 865 try: 866 self._doUploadFile(oSrcFile, sAltName, sDescription, sKind, 'application/octet-stream'); 867 finally: 868 g_oLock.acquire(); 863 869 else: 864 870 self.log(0, '*** UNKNOWN FILE "%s" - KIND "%s" - DESC "%s" ***' … … 876 882 self.xmlFlush(); 877 883 g_oLock.release(); 878 self._doUploadString(sLog, sLogName, sDescription, sKind, 'text/plain'); 879 g_oLock.acquire(); 884 try: 885 self._doUploadString(sLog, sLogName, sDescription, sKind, 'text/plain'); 886 finally: 887 g_oLock.acquire(); 880 888 else: 881 889 self.log(0, '*** UNKNOWN FILE "%s" - KIND "%s" - DESC "%s" ***' … … 895 903 896 904 g_oLock.release(); 897 (asXml, fIncErrors) = self._xmlDoFlush(asXml, fRetry = fRetry); 898 g_oLock.acquire(); 905 try: 906 (asXml, fIncErrors) = self._xmlDoFlush(asXml, fRetry = fRetry); 907 finally: 908 g_oLock.acquire(); 899 909 900 910 if fIncErrors: … … 954 964 # this instead. 955 965 g_oLock.acquire(); 956 self._asXml += [ '<PushHint testdepth="%d"/>' % (len(self.atTests),), 957 sRawXml, 958 '<PopHint testdepth="%d"/>' % (len(self.atTests),),]; 959 self._xmlFlushIfNecessary(); 960 g_oLock.release(); 966 try: 967 self._asXml += [ '<PushHint testdepth="%d"/>' % (len(self.atTests),), 968 sRawXml, 969 '<PopHint testdepth="%d"/>' % (len(self.atTests),),]; 970 self._xmlFlushIfNecessary(); 971 finally: 972 g_oLock.release(); 961 973 return None; 962 974 … … 964 976 if len(self._asXml) > 0: 965 977 g_oLock.acquire(); 966 self._xmlFlushIfNecessary(fPolling = True, sDebug = sDebug); 967 g_oLock.release(); 978 try: 979 self._xmlFlushIfNecessary(fPolling = True, sDebug = sDebug); 980 finally: 981 g_oLock.release(); 968 982 return None; 969 983 … … 979 993 """ 980 994 g_oLock.acquire(); 981 if fIncErrors: 982 g_oReporter.testIncErrors(); 983 984 ## @todo skip all this if iLevel is too high! 985 986 # Try get exception info. 987 sTsPrf = utils.getTimePrefix(); 988 try: 989 oType, oValue, oTraceback = sys.exc_info(); 990 except: 991 oType = oValue = oTraceback = None; 992 if oType is not None: 993 994 # Try format the info 995 try: 996 997 if fIncErrors: 998 g_oReporter.testIncErrors(); 999 1000 ## @todo skip all this if iLevel is too high! 1001 1002 # Try get exception info. 1003 sTsPrf = utils.getTimePrefix(); 995 1004 try: 996 rc = 0; 997 sCaller = utils.getCallerName(oTraceback.tb_frame); 998 if sText is not None: 999 rc = g_oReporter.log(iLevel, "%s%s" % (sPrefix, sText), sCaller, sTsPrf); 1000 asInfo = []; 1001 try: 1002 asInfo = asInfo + traceback.format_exception_only(oType, oValue); 1003 if cFrames is not None and cFrames <= 1: 1004 asInfo = asInfo + traceback.format_tb(oTraceback, 1); 1005 oType, oValue, oTraceback = sys.exc_info(); 1006 except: 1007 oType = oValue = oTraceback = None; 1008 if oType is not None: 1009 1010 # Try format the info 1011 try: 1012 rc = 0; 1013 sCaller = utils.getCallerName(oTraceback.tb_frame); 1014 if sText is not None: 1015 rc = g_oReporter.log(iLevel, "%s%s" % (sPrefix, sText), sCaller, sTsPrf); 1016 asInfo = []; 1017 try: 1018 asInfo = asInfo + traceback.format_exception_only(oType, oValue); 1019 if cFrames is not None and cFrames <= 1: 1020 asInfo = asInfo + traceback.format_tb(oTraceback, 1); 1021 else: 1022 asInfo.append('Traceback:') 1023 asInfo = asInfo + traceback.format_tb(oTraceback, cFrames); 1024 asInfo.append('Stack:') 1025 asInfo = asInfo + traceback.format_stack(oTraceback.tb_frame.f_back, cFrames); 1026 except: 1027 g_oReporter.log(0, '** internal-error: Hit exception #2! %s' % (traceback.format_exc()), sCaller, sTsPrf); 1028 1029 if len(asInfo) > 0: 1030 # Do the logging. 1031 for sItem in asInfo: 1032 asLines = sItem.splitlines(); 1033 for sLine in asLines: 1034 rc = g_oReporter.log(iLevel, '%s%s' % (sPrefix, sLine), sCaller, sTsPrf); 1035 1005 1036 else: 1006 asInfo.append('Traceback:') 1007 asInfo = asInfo + traceback.format_tb(oTraceback, cFrames); 1008 asInfo.append('Stack:') 1009 asInfo = asInfo + traceback.format_stack(oTraceback.tb_frame.f_back, cFrames); 1037 g_oReporter.log(iLevel, 'No exception info...', sCaller, sTsPrf); 1038 rc = -3; 1010 1039 except: 1011 g_oReporter.log(0, '** internal-error: Hit exception #2! %s' % (traceback.format_exc()), sCaller, sTsPrf); 1012 1013 if len(asInfo) > 0: 1014 # Do the logging. 1015 for sItem in asInfo: 1016 asLines = sItem.splitlines(); 1017 for sLine in asLines: 1018 rc = g_oReporter.log(iLevel, '%s%s' % (sPrefix, sLine), sCaller, sTsPrf); 1019 1020 else: 1021 g_oReporter.log(iLevel, 'No exception info...', sCaller, sTsPrf); 1022 rc = -3; 1023 except: 1024 g_oReporter.log(0, '** internal-error: Hit exception! %s' % (traceback.format_exc()), None, sTsPrf); 1025 rc = -2; 1026 else: 1027 g_oReporter.log(0, '** internal-error: No exception! %s' 1028 % (utils.getCallerName(iFrame=3)), utils.getCallerName(iFrame=3), sTsPrf); 1029 rc = -1; 1030 1031 g_oLock.release(); 1040 g_oReporter.log(0, '** internal-error: Hit exception! %s' % (traceback.format_exc()), None, sTsPrf); 1041 rc = -2; 1042 else: 1043 g_oReporter.log(0, '** internal-error: No exception! %s' 1044 % (utils.getCallerName(iFrame=3)), utils.getCallerName(iFrame=3), sTsPrf); 1045 rc = -1; 1046 1047 finally: 1048 g_oLock.release(); 1032 1049 return rc; 1033 1050 … … 1069 1086 except: 1070 1087 traceback.print_exc(); 1071 g_oLock.release(); 1088 finally: 1089 g_oLock.release(); 1072 1090 return None; 1073 1091 … … 1174 1192 if sElement[1:idxEndName] == 'Failed': 1175 1193 g_oLock.acquire(); 1176 g_oReporter.testIncErrors(); 1177 g_oLock.release(); 1194 try: 1195 g_oReporter.testIncErrors(); 1196 finally: 1197 g_oLock.release(); 1178 1198 else: 1179 1199 error('_processXmlElement(%s)' % sElement); … … 1191 1211 except: 1192 1212 rc = -1; 1193 g_oLock.release(); 1213 finally: 1214 g_oLock.release(); 1194 1215 return rc; 1195 1216 … … 1208 1229 except: 1209 1230 rc = -1; 1210 g_oLock.release(); 1231 finally: 1232 g_oLock.release(); 1211 1233 return rc; 1212 1234 … … 1252 1274 """ 1253 1275 g_oLock.acquire(); 1254 g_oReporter.testIncErrors();1255 try:1276 try: 1277 g_oReporter.testIncErrors(); 1256 1278 g_oReporter.log(0, '** error: %s' % (sText), utils.getCallerName(), utils.getTimePrefix()); 1257 1279 except: 1258 1280 pass; 1259 g_oLock.release(); 1281 finally: 1282 g_oLock.release(); 1260 1283 return False; 1261 1284 … … 1283 1306 """ 1284 1307 g_oLock.acquire(); 1285 g_oReporter.testSetTimedOut();1286 try:1308 try: 1309 g_oReporter.testSetTimedOut(); 1287 1310 g_oReporter.log(0, '** timeout-error: %s' % (sText), utils.getCallerName(), utils.getTimePrefix()); 1288 1311 except: 1289 1312 pass; 1290 g_oLock.release(); 1313 finally: 1314 g_oLock.release(); 1291 1315 return False; 1292 1316 … … 1301 1325 """ 1302 1326 g_oLock.acquire(); 1303 g_oReporter.testIncErrors();1304 try:1327 try: 1328 g_oReporter.testIncErrors(); 1305 1329 g_oReporter.log(0, '** fatal error: %s' % (sText), utils.getCallerName(), utils.getTimePrefix()); 1306 1330 except: 1307 1331 pass 1308 g_oLock.release(); 1332 finally: 1333 g_oLock.release(); 1309 1334 return False; 1310 1335 … … 1351 1376 else: 1352 1377 g_oLock.acquire(); 1353 fRc = g_oReporter.addLogFile(oSrcFile, sFilename, sAltName, sDescription, sKind, sCaller, sTsPrf); 1354 g_oLock.release(); 1355 oSrcFile.close(); 1378 try: 1379 fRc = g_oReporter.addLogFile(oSrcFile, sFilename, sAltName, sDescription, sKind, sCaller, sTsPrf); 1380 finally: 1381 g_oLock.release(); 1382 oSrcFile.close(); 1356 1383 return fRc; 1357 1384 … … 1374 1401 1375 1402 g_oLock.acquire(); 1376 fRc = g_oReporter.addLogString(sLog, sLogName, sDescription, sKind, sCaller, sTsPrf); 1377 g_oLock.release(); 1403 try: 1404 fRc = g_oReporter.addLogString(sLog, sLogName, sDescription, sKind, sCaller, sTsPrf); 1405 finally: 1406 g_oLock.release(); 1378 1407 return fRc; 1379 1408 … … 1402 1431 """ 1403 1432 g_oLock.acquire(); 1404 cErrors = g_oReporter.cErrors; 1405 g_oLock.release(); 1433 try: 1434 cErrors = g_oReporter.cErrors; 1435 finally: 1436 g_oLock.release(); 1406 1437 return cErrors; 1407 1438 … … 1424 1455 """ 1425 1456 g_oLock.acquire(); 1426 rc = g_oReporter.testStart(sName, utils.getCallerName()); 1427 g_oLock.release(); 1457 try: 1458 rc = g_oReporter.testStart(sName, utils.getCallerName()); 1459 finally: 1460 g_oLock.release(); 1428 1461 return rc; 1429 1462 … … 1433 1466 """ 1434 1467 g_oLock.acquire(); 1435 rc = g_oReporter.testValue(sName, str(sValue), sUnit, utils.getCallerName()); 1436 g_oLock.release(); 1468 try: 1469 rc = g_oReporter.testValue(sName, str(sValue), sUnit, utils.getCallerName()); 1470 finally: 1471 g_oLock.release(); 1437 1472 return rc; 1438 1473 … … 1445 1480 """ 1446 1481 g_oLock.acquire(); 1447 g_oReporter.testFailure(sDetails, utils.getCallerName()); 1448 g_oLock.release(); 1482 try: 1483 g_oReporter.testFailure(sDetails, utils.getCallerName()); 1484 finally: 1485 g_oLock.release(); 1449 1486 return False; 1450 1487 … … 1470 1507 # Use testFailure to do the work. 1471 1508 g_oLock.acquire(); 1472 if sDetails == '': 1473 g_oReporter.testFailure('Exception: %s' % (sXcpt,), sCaller); 1474 else: 1475 g_oReporter.testFailure('%s: %s' % (sDetails, sXcpt), sCaller); 1476 g_oLock.release(); 1509 try: 1510 if sDetails == '': 1511 g_oReporter.testFailure('Exception: %s' % (sXcpt,), sCaller); 1512 else: 1513 g_oReporter.testFailure('%s: %s' % (sDetails, sXcpt), sCaller); 1514 finally: 1515 g_oLock.release(); 1477 1516 return False; 1478 1517 … … 1484 1523 """ 1485 1524 g_oLock.acquire(); 1486 rc = g_oReporter.testDone(fSkipped, utils.getCallerName()); 1487 g_oLock.release(); 1525 try: 1526 rc = g_oReporter.testDone(fSkipped, utils.getCallerName()); 1527 finally: 1528 g_oLock.release(); 1488 1529 return rc; 1489 1530 … … 1495 1536 """ 1496 1537 g_oLock.acquire(); 1497 cErrors = g_oReporter.testErrorCount(); 1498 g_oLock.release(); 1538 try: 1539 cErrors = g_oReporter.testErrorCount(); 1540 finally: 1541 g_oLock.release(); 1499 1542 return cErrors; 1500 1543 … … 1506 1549 """ 1507 1550 g_oLock.acquire(); 1508 fRc = g_oReporter.testCleanup(utils.getCallerName()); 1509 g_oReporter.xmlFlush(fRetry = False, fForce = True); 1510 g_oLock.release(); 1551 try: 1552 fRc = g_oReporter.testCleanup(utils.getCallerName()); 1553 g_oReporter.xmlFlush(fRetry = False, fForce = True); 1554 finally: 1555 g_oLock.release(); 1511 1556 return fRc; 1512 1557 … … 1584 1629 """ 1585 1630 g_oLock.acquire(); 1586 fRc = g_oReporter.xmlFlush(fRetry = False, fForce = True); 1587 g_oLock.release(); 1631 try: 1632 fRc = g_oReporter.xmlFlush(fRetry = False, fForce = True); 1633 finally: 1634 g_oLock.release(); 1588 1635 return fRc; 1589 1636 … … 1600 1647 if fSkipXml is not True: 1601 1648 g_oLock.acquire(); 1602 g_oReporter.xmlFlush(fRetry = False); 1603 g_oLock.release(); 1649 try: 1650 g_oReporter.xmlFlush(fRetry = False); 1651 finally: 1652 g_oLock.release(); 1604 1653 1605 1654 return True;
Note:
See TracChangeset
for help on using the changeset viewer.