4def extract_test_args(s):
5 p = re.compile(
'eval\\((.*)\\)')
10def pytest_addoption(parser):
11 parser.addoption(
"--test_list", action=
"store", help=
"Path to test list")
12 parser.addoption(
"--artifacts", action=
"store", help=
"Path to test artifacts")
13 parser.addoption(
"--target_artifacts",
15 help=
"Path to test target artifacts")
16 parser.addoption(
"--luci_eval_driver",
18 help=
"Path to luci eval driver")
21def pytest_generate_tests(metafunc):
22 list_path = metafunc.config.getoption(
'test_list')
23 artifacts_path = metafunc.config.getoption(
'artifacts')
24 target_artifacts_path = metafunc.config.getoption(
'target_artifacts')
25 eval_driver_path = metafunc.config.getoption(
'luci_eval_driver')
27 tests_default_tol = []
29 ref_tests_default_tol = []
30 ref_tests_with_tol = []
32 with open(list_path)
as f:
33 contents = [line.rstrip()
for line
in f]
35 comment_removed = [line
for line
in contents
if not line.startswith(
'#')]
36 newline_removed = [line
for line
in comment_removed
if line.startswith(
'eval(')]
37 test_args = [extract_test_args(line)
for line
in newline_removed]
39 tests_default_tol = [(arg, artifacts_path, eval_driver_path)
for arg
in test_args
40 if len(arg.split()) == 1]
42 tests_with_tol = [(arg.split()[0], artifacts_path, eval_driver_path,
43 arg.split()[1], arg.split()[2])
for arg
in test_args
44 if len(arg.split()) == 3]
46 if 'default_test_name' in metafunc.fixturenames:
47 metafunc.parametrize(
'default_test_name,artifacts_path,eval_driver_path',
50 if 'tol_test_name' in metafunc.fixturenames:
52 'tol_test_name,artifacts_path,eval_driver_path,rtolf32,atolf32',
55 if target_artifacts_path
is not None:
57 ref_tests_default_tol = [(arg, artifacts_path, target_artifacts_path,
58 eval_driver_path)
for arg
in test_args
59 if len(arg.split()) == 1]
61 ref_tests_with_tol = [(arg.split()[0], artifacts_path, target_artifacts_path,
62 eval_driver_path, arg.split()[1], arg.split()[2])
63 for arg
in test_args
if len(arg.split()) == 3]
67 if 'default_ref_test_name' in metafunc.fixturenames:
69 'default_ref_test_name,ref_artifacts_path,target_artifacts_path,eval_driver_path',
70 ref_tests_default_tol)
72 if 'tol_ref_test_name' in metafunc.fixturenames:
74 'tol_ref_test_name,ref_artifacts_path,target_artifacts_path,eval_driver_path,rtolf32,atolf32',