Changeset 92283 in vbox for trunk/src/VBox/ValidationKit
- Timestamp:
- Nov 9, 2021 10:05:23 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testdriver/reporter.py
r90616 r92283 1249 1249 1250 1250 class FileWrapperTestPipe(object): 1251 """ File like class for the test pipe (TXS EXEC and similar). """ 1251 """ 1252 File like class for the test pipe (TXS EXEC and similar). 1253 1254 This is also used to submit XML test result files. 1255 """ 1252 1256 def __init__(self): 1253 1257 self.sPrefix = ''; … … 1255 1259 self.fClosed = False; 1256 1260 self.sTagBuffer = None; 1261 self.cTestDepth = 0; 1262 self.acTestErrors = []; 1257 1263 1258 1264 def __del__(self): … … 1263 1269 if self.fStarted is True and self.fClosed is False: 1264 1270 self.fClosed = True; 1271 1272 # Close open <Test> elements: 1273 if self.cTestDepth > 0: 1274 sNow = utils.getIsoTimestamp() 1275 cErrors = 0; 1276 while self.cTestDepth > 0: 1277 self.cTestDepth -= 1; 1278 if self.acTestErrors: 1279 cErrors += self.acTestErrors.pop(); 1280 cErrors += 1; 1281 g_oReporter.subXmlWrite(self, ' <Failed timestamp="%s"/ errors="%s">\n</Test>\n' % (sNow, cErrors), 1282 utils.getCallerName()); 1283 1284 # Tell the reporter that the XML input is done. 1265 1285 try: g_oReporter.subXmlEnd(self); 1266 1286 except: … … 1300 1320 1301 1321 try: 1322 # 1323 # Write the XML to the reporter. 1324 # 1302 1325 g_oReporter.subXmlWrite(self, sText, utils.getCallerName()); 1326 1327 # 1303 1328 # Parse the supplied text and look for <Failed.../> tags to keep track of the 1304 1329 # error counter. This is only a very lazy aproach. 1305 sText.strip();1330 # 1306 1331 idxText = 0; 1307 1332 while sText: 1308 1333 if self.sTagBuffer is None: 1309 1334 # Look for the start of a tag. 1310 idxStart = sText [idxText:].find('<');1335 idxStart = sText.find('<', idxText); 1311 1336 if idxStart != -1: 1312 # Look for the end of the tag.1313 idxEnd = sText[idxStart:].find('>');1314 1315 1337 # If the end was found inside the current buffer, parse the line, 1316 # else we have to save it for later. 1338 # otherwise we have to save it for later. 1339 idxEnd = sText.find('>', idxStart); 1317 1340 if idxEnd != -1: 1318 idxEnd += idxStart + 1; 1319 self._processXmlElement(sText[idxStart:idxEnd]); 1341 self._processXmlElement(sText[idxStart:idxEnd+1]); 1320 1342 idxText = idxEnd; 1321 1343 else: 1322 1344 self.sTagBuffer = sText[idxStart:]; 1323 idxText = len(sText);1345 break; 1324 1346 else: 1325 idxText = len(sText);1347 break; 1326 1348 else: 1327 1349 # Search for the end of the tag and parse the whole tag. 1328 idxEnd = sText[idxText:].find('>'); 1350 assert(idxText == 0); 1351 idxEnd = sText.find('>'); 1329 1352 if idxEnd != -1: 1330 idxEnd += idxStart + 1; 1331 self._processXmlElement(self.sTagBuffer + sText[idxText:idxEnd]); 1353 self._processXmlElement(self.sTagBuffer + sText[:idxEnd+1]); 1332 1354 self.sTagBuffer = None; 1333 1355 idxText = idxEnd; 1334 1356 else: 1335 1357 self.sTagBuffer = self.sTagBuffer + sText[idxText:]; 1336 idxText = len(sText); 1337 1338 sText = sText[idxText:]; 1339 sText = sText.lstrip(); 1358 break; 1340 1359 except: 1341 1360 traceback.print_exc(); … … 1344 1363 def _processXmlElement(self, sElement): 1345 1364 """ 1346 Processes a complete XML tag (so far we only search for the Failed to tag 1347 to keep track of the error counter. 1365 Processes a complete XML tag. 1366 1367 We handle the 'Failed' tag to keep track of the error counter. 1368 We also track 'Test' tags to make sure we close with all of them properly closed. 1348 1369 """ 1349 1370 # Make sure we don't parse any space between < and the element name. … … 1353 1374 idxEndName = sElement.find(' '); 1354 1375 if idxEndName == -1: 1355 idxEndName = sElement.find('/');1356 if idxEndName == -1:1357 1376 idxEndName = sElement.find('>'); 1358 1359 if idxEndName != -1: 1360 if sElement[1:idxEndName] == 'Failed': 1361 g_oLock.acquire(); 1362 try: 1363 g_oReporter.testIncErrors(); 1364 finally: 1365 g_oLock.release(); 1366 else: 1367 error('_processXmlElement(%s)' % sElement); 1377 if idxEndName >= 0: 1378 if sElement[idxEndName - 1] == '/': 1379 idxEndName -= 1; 1380 else: 1381 idxEndName = len(sElement); 1382 sElementName = sElement[1:idxEndName]; 1383 1384 # <Failed>: 1385 if sElementName == 'Failed': 1386 g_oLock.acquire(); 1387 try: 1388 g_oReporter.testIncErrors(); 1389 finally: 1390 g_oLock.release(); 1391 if self.acTestErrors: 1392 self.acTestErrors[-1] += 1; # get errors attrib 1393 # <Test> 1394 elif sElementName == 'Test': 1395 self.cTestDepth += 1; 1396 self.acTestErrors.append(0); 1397 # </Test> 1398 elif sElementName == '/Test': 1399 self.cTestDepth -= 1; 1400 if self.acTestErrors: 1401 cErrors = self.acTestErrors.pop(); 1402 if self.acTestErrors: 1403 self.acTestErrors[-1] += cErrors; 1368 1404 1369 1405
Note:
See TracChangeset
for help on using the changeset viewer.