Add multi-target support for performance tests
This commit is contained in:
@@ -137,31 +137,42 @@ def log_performance(item, value):
|
||||
current_junit_case.stdout += performance_msg + "\r\n"
|
||||
|
||||
|
||||
def check_performance(item, value):
|
||||
def check_performance(item, value, target):
|
||||
"""
|
||||
check if idf performance meet pass standard
|
||||
|
||||
:param item: performance item name
|
||||
:param value: performance item value
|
||||
:param target: target chip
|
||||
:raise: AssertionError: if check fails
|
||||
"""
|
||||
ret = True
|
||||
standard_value = 0
|
||||
|
||||
idf_path = IDFApp.get_sdk_path()
|
||||
performance_file = os.path.join(idf_path, "components", "idf_test", "include", "idf_performance.h")
|
||||
|
||||
if os.path.exists(performance_file):
|
||||
with open(performance_file, "r") as f:
|
||||
def _find_perf_item(path):
|
||||
with open(path, 'r') as f:
|
||||
data = f.read()
|
||||
match = re.search(r"#define\s+IDF_PERFORMANCE_(MIN|MAX)_{}\s+([\d.]+)".format(item.upper()), data)
|
||||
if match:
|
||||
op = match.group(1)
|
||||
standard_value = float(match.group(2))
|
||||
if op == "MAX":
|
||||
ret = value <= standard_value
|
||||
else:
|
||||
ret = value >= standard_value
|
||||
if not ret:
|
||||
raise AssertionError("[Performance] {} value is {}, doesn't meet pass standard {}"
|
||||
.format(item, value, standard_value))
|
||||
match = re.search(r'#define\s+IDF_PERFORMANCE_(MIN|MAX)_{}\s+([\d.]+)'.format(item.upper()), data)
|
||||
return match.group(1), float(match.group(2))
|
||||
|
||||
def _check_perf(op, standard_value):
|
||||
if op == 'MAX':
|
||||
ret = value <= standard_value
|
||||
else:
|
||||
ret = value >= standard_value
|
||||
if not ret:
|
||||
raise AssertionError("[Performance] {} value is {}, doesn't meet pass standard {}"
|
||||
.format(item, value, standard_value))
|
||||
|
||||
path_prefix = os.path.join(IDFApp.get_sdk_path(), 'components', 'idf_test', 'include')
|
||||
performance_files = (os.path.join(path_prefix, target, 'idf_performance_target.h'),
|
||||
os.path.join(path_prefix, 'idf_performance.h'))
|
||||
|
||||
for performance_file in performance_files:
|
||||
try:
|
||||
op, value = _find_perf_item(performance_file)
|
||||
except (IOError, AttributeError):
|
||||
# performance file doesn't exist or match is not found in it
|
||||
continue
|
||||
|
||||
_check_perf(op, value)
|
||||
# if no exception was thrown then the performance is met and no need to continue
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user