# -*- coding: utf-8 -*-
# $Id$
"""
XML reader module.
This produces a test result tree that can be processed and passed to
reporting.
"""
__copyright__ = \
"""
Copyright (C) 2010-2014 Oracle Corporation
This file is part of VirtualBox Open Source Edition (OSE), as
available from http://www.virtualbox.org. This file is free software;
General Public License (GPL) as published by the Free Software
Foundation, in version 2 as it comes in the "COPYING" file of the
VirtualBox OSE distribution. VirtualBox OSE is distributed in the
hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
The contents of this file may alternatively be used under the terms
of the Common Development and Distribution License Version 1.0
(CDDL) only, as it comes in the "COPYING.CDDL" file of the
VirtualBox OSE distribution, in which case the provisions of the
CDDL are applicable instead of those of the GPL.
You may elect to license modified versions of this file under the
terms and conditions of either the GPL or the CDDL or both.
"""
# Standard python imports.
import os
import traceback
# pylint: disable=C0111
"""
Represents a value. Usually this is benchmark result or parameter.
"""
# parsing
# debug
print '%sValue: name=%s timestamp=%s unit=%s value="%s"' \
"""
Nested test result.
"""
self.aoChildren = [];
self.sStatusDiff = None;
self.cErrorsDiff = None;
# parsing
return oChild;
return oValue;
except: pass;
except: pass;
except: pass;
except: pass;
""" oTest will be robbed. """
if oTest is not None:
oTest.aoChildren = [];
# debug
print '%sTest: name=%s start=%s end=%s' % (''.ljust(iLevel*2), self.sName, self.sStartTS, self.sEndTS);
# getters / queries
if iLevel < cSkipUpper:
else:
"""
Checks if the all of the specified filter strings are substrings
of the full test name. Returns True / False.
"""
return False;
return True;
# manipulation
# depth first
i = 0;
i += 1;
else:
del self.aoChildren[i];
# If we have children, they must've matched up.
return True;
return self;
"""
XML log reader class.
"""
try:
except:
return False;
oParser = ParserCreate();
try:
except:
return False;
return True;
#print '%s%s: %s' % (''.ljust(self.iLevel * 2), sName, str(hsAttrs));
elif sName == 'Value':
elif sName == 'End':
elif sName == 'Passed':
elif sName == 'Skipped':
elif sName == 'Failed':
elif sName == 'Include':
else:
print 'Unknonwn element "%s"' % (sName);
print 'Unexpected data "%s"' % (sData);
return True;
elif sName == 'Value':
return True;
# relative or absolute path.
# Try parse it.
if oSub is None:
print 'error: failed to parse include "%s"' % (sXmlFile);
else:
# Skip the root and the next level before merging it the subtest and
# values in to the current test. The reason for this is that the
# include is the output of some sub-program we've run and we don't need
# the extra test level it automatically adds.
#
# More benchmark heuristics: Walk down until we find more than one
# test or values.
return True;
"""
Parses the test results in the XML.
Returns result tree.
Returns None on failure.
"""
return None;