mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
test: collect unit-test performance items and save to report
This commit is contained in:
parent
0462620a23
commit
b75400294a
@ -65,14 +65,14 @@ class IDFRecvThread(DUT.RecvThread):
|
||||
def __init__(self, read, dut):
|
||||
super(IDFRecvThread, self).__init__(read, dut)
|
||||
self.exceptions = _queue.Queue()
|
||||
self.performances = _queue.Queue()
|
||||
self.performance_items = _queue.Queue()
|
||||
|
||||
def collect_performance(self, comp_data):
|
||||
matches = self.PERFORMANCE_PATTERN.findall(comp_data)
|
||||
for match in matches:
|
||||
Utility.console_log("[Performance][{}]: {}".format(match[0], match[1]),
|
||||
color="orange")
|
||||
self.performances.put((match[0], match[1]))
|
||||
self.performance_items.put((match[0], match[1]))
|
||||
|
||||
def detect_exception(self, comp_data):
|
||||
for pattern in self.EXCEPTION_PATTERNS:
|
||||
@ -157,7 +157,7 @@ class IDFDUT(DUT.SerialDUT):
|
||||
super(IDFDUT, self).__init__(name, port, log_file, app, **kwargs)
|
||||
self.allow_dut_exception = allow_dut_exception
|
||||
self.exceptions = _queue.Queue()
|
||||
self.performances = _queue.Queue()
|
||||
self.performance_items = _queue.Queue()
|
||||
|
||||
@classmethod
|
||||
def get_mac(cls, app, port):
|
||||
@ -365,7 +365,7 @@ class IDFDUT(DUT.SerialDUT):
|
||||
|
||||
def stop_receive(self):
|
||||
if self.receive_thread:
|
||||
for name in ["performances", "exceptions"]:
|
||||
for name in ["performance_items", "exceptions"]:
|
||||
source_queue = getattr(self.receive_thread, name)
|
||||
dest_queue = getattr(self, name)
|
||||
self._queue_copy(source_queue, dest_queue)
|
||||
@ -382,7 +382,7 @@ class IDFDUT(DUT.SerialDUT):
|
||||
|
||||
:return: a list of performance items.
|
||||
"""
|
||||
return self._get_from_queue("performances")
|
||||
return self._get_from_queue("performance_items")
|
||||
|
||||
def close(self):
|
||||
super(IDFDUT, self).close()
|
||||
|
@ -285,16 +285,19 @@ def run_unit_test_cases(env, extra_data):
|
||||
Utility.console_log("Download finished, start running test cases", "O")
|
||||
|
||||
for one_case in case_config[ut_config]:
|
||||
performance_items = []
|
||||
# create junit report test case
|
||||
junit_test_case = TinyFW.JunitReport.create_test_case("[{}] {}".format(ut_config, one_case["name"]))
|
||||
try:
|
||||
run_one_normal_case(dut, one_case, junit_test_case)
|
||||
performance_items = dut.get_performance_items()
|
||||
except TestCaseFailed:
|
||||
failed_cases.append(one_case["name"])
|
||||
except Exception as e:
|
||||
junit_test_case.add_failure_info("Unexpected exception: " + str(e))
|
||||
failed_cases.append(one_case["name"])
|
||||
finally:
|
||||
TinyFW.JunitReport.update_performance(performance_items)
|
||||
TinyFW.JunitReport.test_case_finish(junit_test_case)
|
||||
|
||||
# raise exception if any case fails
|
||||
@ -445,6 +448,13 @@ def run_one_multiple_devices_case(duts, ut_config, env, one_case, app_bin, junit
|
||||
|
||||
if not result:
|
||||
junit_test_case.add_failure_info(output)
|
||||
|
||||
# collect performances from DUTs
|
||||
performance_items = []
|
||||
for dut_name in duts:
|
||||
performance_items.extend(duts[dut_name].get_performance_items())
|
||||
TinyFW.JunitReport.update_performance(performance_items)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@ -628,15 +638,18 @@ def run_multiple_stage_cases(env, extra_data):
|
||||
dut.start_app()
|
||||
|
||||
for one_case in case_config[ut_config]:
|
||||
performance_items = []
|
||||
junit_test_case = TinyFW.JunitReport.create_test_case("[{}] {}".format(ut_config, one_case["name"]))
|
||||
try:
|
||||
run_one_multiple_stage_case(dut, one_case, junit_test_case)
|
||||
performance_items = dut.get_performance_items()
|
||||
except TestCaseFailed:
|
||||
failed_cases.append(one_case["name"])
|
||||
except Exception as e:
|
||||
junit_test_case.add_failure_info("Unexpected exception: " + str(e))
|
||||
failed_cases.append(one_case["name"])
|
||||
finally:
|
||||
TinyFW.JunitReport.update_performance(performance_items)
|
||||
TinyFW.JunitReport.test_case_finish(junit_test_case)
|
||||
|
||||
# raise exception if any case fails
|
||||
|
Loading…
x
Reference in New Issue
Block a user