sanitycheck: Add checking of zephyr version
Adds function checking the version of zephyr, used for reporting Signed-off-by: Maciej Perkowski <Maciej.Perkowski@nordicsemi.no>
This commit is contained in:
parent
725d19b79e
commit
060e00d9c5
3 changed files with 27 additions and 11 deletions
|
@ -2451,6 +2451,20 @@ class TestSuite(DisablePyTestCollectionMixin):
|
|||
# run integration tests only
|
||||
self.integration = False
|
||||
|
||||
self.version = "NA"
|
||||
|
||||
def check_zephyr_version(self):
|
||||
try:
|
||||
subproc = subprocess.run(["git", "describe"],
|
||||
stdout=subprocess.PIPE,
|
||||
universal_newlines=True,
|
||||
cwd=ZEPHYR_BASE)
|
||||
if subproc.returncode == 0:
|
||||
self.version = subproc.stdout.strip()
|
||||
logger.info(f"Zephyr version: {self.version}")
|
||||
except OSError:
|
||||
logger.info("Cannot read zephyr version.")
|
||||
|
||||
def get_platform_instances(self, platform):
|
||||
filtered_dict = {k:v for k,v in self.instances.items() if k.startswith(platform + "/")}
|
||||
return filtered_dict
|
||||
|
@ -2482,7 +2496,6 @@ class TestSuite(DisablePyTestCollectionMixin):
|
|||
self.total_skipped_cases += 1
|
||||
self.total_to_do = self.total_tests - self.total_skipped
|
||||
|
||||
|
||||
def compare_metrics(self, filename):
|
||||
# name, datatype, lower results better
|
||||
interesting_metrics = [("ram_size", int, True),
|
||||
|
@ -2620,8 +2633,10 @@ class TestSuite(DisablePyTestCollectionMixin):
|
|||
filename = "{}_{}".format(filename, suffix)
|
||||
|
||||
if not no_update:
|
||||
self.xunit_report(filename + ".xml", full_report=False, append=only_failed)
|
||||
self.xunit_report(filename + "_report.xml", full_report=True, append=only_failed)
|
||||
self.xunit_report(filename + ".xml", full_report=False,
|
||||
append=only_failed, version=self.version)
|
||||
self.xunit_report(filename + "_report.xml", full_report=True,
|
||||
append=only_failed, version=self.version)
|
||||
self.csv_report(filename + ".csv")
|
||||
|
||||
self.target_report(outdir, suffix, append=only_failed)
|
||||
|
@ -3131,7 +3146,8 @@ class TestSuite(DisablePyTestCollectionMixin):
|
|||
filename = os.path.join(outdir,"{}_{}.xml".format(platform, suffix))
|
||||
else:
|
||||
filename = os.path.join(outdir,"{}.xml".format(platform))
|
||||
self.xunit_report(filename, platform, full_report=True, append=append)
|
||||
self.xunit_report(filename, platform, full_report=True,
|
||||
append=append, version=self.version)
|
||||
|
||||
|
||||
@staticmethod
|
||||
|
@ -3219,9 +3235,7 @@ class TestSuite(DisablePyTestCollectionMixin):
|
|||
eleTSPropetries = ET.SubElement(eleTestsuite, 'properties')
|
||||
# Multiple 'property' can be added to 'properties'
|
||||
# differing by name and value
|
||||
eleTSPVerstion = ET.SubElement(eleTSPropetries, 'property',
|
||||
name="version",
|
||||
value=version)
|
||||
ET.SubElement(eleTSPropetries, 'property', name="version", value=version)
|
||||
|
||||
else:
|
||||
eleTestsuite = ET.SubElement(eleTestsuites, 'testsuite',
|
||||
|
@ -3232,9 +3246,7 @@ class TestSuite(DisablePyTestCollectionMixin):
|
|||
eleTSPropetries = ET.SubElement(eleTestsuite, 'properties')
|
||||
# Multiple 'property' can be added to 'properties'
|
||||
# differing by name and value
|
||||
eleTSPVerstion = ET.SubElement(eleTSPropetries, 'property',
|
||||
name="version",
|
||||
value=version)
|
||||
ET.SubElement(eleTSPropetries, 'property', name="version", value=version)
|
||||
|
||||
for _, instance in inst.items():
|
||||
if full_report:
|
||||
|
|
|
@ -834,6 +834,9 @@ def main():
|
|||
|
||||
suite = TestSuite(options.board_root, options.testcase_root, options.outdir)
|
||||
|
||||
# Check version of zephyr repo
|
||||
suite.check_zephyr_version()
|
||||
|
||||
# Set testsuite options from command line.
|
||||
suite.build_only = options.build_only
|
||||
suite.cmake_only = options.cmake_only
|
||||
|
|
|
@ -111,7 +111,8 @@ def test_xunit_report(class_testsuite, test_data,
|
|||
assert int(tree.findall('testsuite')[0].attrib["errors"]) == int(errors)
|
||||
assert int(tree.findall('testsuite')[0].attrib["tests"]) == int(passes+fails+skips+errors)
|
||||
|
||||
for index in range(0, len(class_testsuite.instances)):
|
||||
for index in range(1, len(class_testsuite.instances)+1):
|
||||
# index=0 corresponds to 'properties'. Test cases start from index=1
|
||||
if len(list(tree.findall('testsuite')[0][index])) != 0:
|
||||
if tree.findall('testsuite')[0][index][0].attrib["type"] == "failure":
|
||||
assert tree.findall('testsuite')[0][index].attrib["name"] == \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue