|
|
|
@ -26,25 +26,28 @@ from .utils import keyword
|
|
|
|
|
|
|
|
|
|
def mindspore_test(verification_pipeline):
|
|
|
|
|
"""
|
|
|
|
|
Run verification pipeline.
|
|
|
|
|
运行验证流水线。
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
verification_pipeline (list): Pipeline designed to do verification.
|
|
|
|
|
verification_pipeline (list): 设计的验证流水线。
|
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
def decorate(get_verification_set):
|
|
|
|
|
# 获取验证集
|
|
|
|
|
verification_set = get_verification_set()
|
|
|
|
|
|
|
|
|
|
facade_components = []
|
|
|
|
|
data_components = []
|
|
|
|
|
builder_components = []
|
|
|
|
|
executor_components = []
|
|
|
|
|
verifier_components = []
|
|
|
|
|
fi_policy_components = []
|
|
|
|
|
er_policy_components = []
|
|
|
|
|
# 初始化组件列表
|
|
|
|
|
facade_components = [] # 外观组件列表
|
|
|
|
|
data_components = [] # 数据组件列表
|
|
|
|
|
builder_components = [] # 构建组件列表
|
|
|
|
|
executor_components = [] # 执行组件列表
|
|
|
|
|
verifier_components = [] # 验证组件列表
|
|
|
|
|
fi_policy_components = [] # FI策略组件列表
|
|
|
|
|
er_policy_components = [] # ER策略组件列表
|
|
|
|
|
for component in verification_pipeline:
|
|
|
|
|
# 判断组件类型并添加到对应列表
|
|
|
|
|
if issubclass(component, IFacadeComponent):
|
|
|
|
|
facade_components.append(component)
|
|
|
|
|
elif issubclass(component, IDataComponent):
|
|
|
|
@ -62,68 +65,90 @@ def mindspore_test(verification_pipeline):
|
|
|
|
|
else:
|
|
|
|
|
raise Exception(f'{component} is not an instance of {IComponent}')
|
|
|
|
|
|
|
|
|
|
# 依次处理外观组件
|
|
|
|
|
for component in facade_components:
|
|
|
|
|
fc = component(verification_set)
|
|
|
|
|
verification_set = fc()
|
|
|
|
|
|
|
|
|
|
# 初始化输入列表
|
|
|
|
|
inputs = []
|
|
|
|
|
# 依次处理数据组件
|
|
|
|
|
for component in data_components:
|
|
|
|
|
dc = component(verification_set)
|
|
|
|
|
item = dc()
|
|
|
|
|
inputs.extend(item)
|
|
|
|
|
|
|
|
|
|
# 如果输入列表为空,记录警告
|
|
|
|
|
if not inputs:
|
|
|
|
|
logging.warning("Inputs set is empty.")
|
|
|
|
|
|
|
|
|
|
# 初始化函数列表
|
|
|
|
|
functions = []
|
|
|
|
|
# 依次处理构建组件
|
|
|
|
|
for component in builder_components:
|
|
|
|
|
bc = component(verification_set)
|
|
|
|
|
f = bc()
|
|
|
|
|
functions.extend(f)
|
|
|
|
|
|
|
|
|
|
# 如果函数列表为空,记录警告
|
|
|
|
|
if not functions:
|
|
|
|
|
logging.warning("Function set is empty.")
|
|
|
|
|
|
|
|
|
|
# 初始化函数输入对列表
|
|
|
|
|
fis = []
|
|
|
|
|
# 依次处理FI策略组件
|
|
|
|
|
for component in fi_policy_components:
|
|
|
|
|
fipc = component(verification_set, functions, inputs)
|
|
|
|
|
result = fipc()
|
|
|
|
|
fis.extend(result)
|
|
|
|
|
|
|
|
|
|
# 如果函数输入对列表为空,记录警告
|
|
|
|
|
if not fis:
|
|
|
|
|
logging.warning("Function inputs pair set is empty.")
|
|
|
|
|
|
|
|
|
|
# 定义测试用例函数
|
|
|
|
|
def test_case(args):
|
|
|
|
|
# 提取系统待测和输入参数
|
|
|
|
|
sut, inputs = args
|
|
|
|
|
|
|
|
|
|
# 初始化结果列表
|
|
|
|
|
results = []
|
|
|
|
|
# 依次处理执行组件
|
|
|
|
|
for component in executor_components:
|
|
|
|
|
ec = component(verification_set, sut, inputs)
|
|
|
|
|
result = ec()
|
|
|
|
|
results.append(result)
|
|
|
|
|
|
|
|
|
|
# 如果结果列表为空,记录警告
|
|
|
|
|
if not results:
|
|
|
|
|
logging.warning("Result set is empty.")
|
|
|
|
|
|
|
|
|
|
# 初始化期望实际结果对列表
|
|
|
|
|
expect_actuals = []
|
|
|
|
|
# 依次处理ER策略组件
|
|
|
|
|
for component in er_policy_components:
|
|
|
|
|
erpc = component(verification_set, verification_set['expect'], results)
|
|
|
|
|
result = erpc()
|
|
|
|
|
expect_actuals.extend(result)
|
|
|
|
|
|
|
|
|
|
# 如果期望实际结果对列表为空,记录警告
|
|
|
|
|
if not expect_actuals:
|
|
|
|
|
logging.warning("Expect Result pair set is empty.")
|
|
|
|
|
|
|
|
|
|
# 依次处理验证组件
|
|
|
|
|
for ea in expect_actuals:
|
|
|
|
|
for component in verifier_components:
|
|
|
|
|
vc = component(verification_set, *ea)
|
|
|
|
|
vc()
|
|
|
|
|
|
|
|
|
|
# 定义测试用例名称生成函数
|
|
|
|
|
def get_tc_name(f, inputs):
|
|
|
|
|
# 拼接测试用例ID和组名
|
|
|
|
|
tc_id = f[keyword.id] + '-' + inputs[keyword.id]
|
|
|
|
|
group = f[keyword.group] + '-' + inputs[keyword.group]
|
|
|
|
|
return 'Group_' + group + '-' + 'Id_' + tc_id
|
|
|
|
|
|
|
|
|
|
# 如果存在函数输入对,则生成测试用例
|
|
|
|
|
if fis:
|
|
|
|
|
m = pytest.mark.parametrize('args', fis, ids=lambda fi: get_tc_name(*fi))(test_case)
|
|
|
|
|
m.__orig__ = get_verification_set
|
|
|
|
|