6def extract_test_args(s):
7 p = re.compile(
'eval\\((.*)\\)')
12def pytest_addoption(parser):
13 parser.addoption(
"--test_list", action=
"store", help=
"Path to test list")
14 parser.addoption(
"--artifacts", action=
"store", help=
"Path to test artifacts")
15 parser.addoption(
"--tflrecipe", action=
"store", help=
"Path to tfl recipies")
16 parser.addoption(
"--circlerecipe", action=
"store", help=
"Path to circle recipies")
17 parser.addoption(
"--binary", action=
"store", help=
"Path to test binary")
18 parser.addoption(
"--luci_eval_driver",
20 help=
"Path to luci eval driver")
25 if (os.path.isfile(dst_filepath)):
26 file_diff = os.stat(src_filepath).st_mtime - os.stat(dst_filepath).st_mtime
28 print(
"file:" + src_filepath +
" changed, update")
34 print(
"file:" + src_filepath +
" copy to: " + dst_filepath)
35 shutil.copyfile(src_filepath, dst_filepath)
44 input_file_src = ref_file_src + str(num_data)
45 if (
not os.path.isfile(input_file_src)):
47 input_file_dst = ref_file_dst + str(num_data)
50 num_data = num_data + 1
61 recipe_path = tflrecipe_path
63 test_recipe = os.path.join(recipe_path, test_name,
'test.recipe')
64 if (
not os.path.isfile(test_recipe)):
65 recipe_path = circlerecipe_path
67 ref_input_src = os.path.join(recipe_path, test_name,
'ref.input')
68 ref_input_dst = os.path.join(binary_path, test_name +
'.ref.input')
71 ref_input_src = os.path.join(recipe_path, test_name,
'ref.output')
72 ref_input_dst = os.path.join(binary_path, test_name +
'.ref.output')
75 cirle_model_src = os.path.join(artifacts_path, test_name +
'.circle')
76 cicle_model_dst = os.path.join(binary_path, test_name +
'.circle')
81 list_path = metafunc.config.getoption(
'test_list')
82 artifacts_path = metafunc.config.getoption(
'artifacts')
83 tflrecipe_path = metafunc.config.getoption(
'tflrecipe')
84 circlerecipe_path = metafunc.config.getoption(
'circlerecipe')
85 binary_path = metafunc.config.getoption(
'binary')
86 eval_driver_path = metafunc.config.getoption(
'luci_eval_driver')
88 tests_default_tol = []
91 with open(list_path)
as f:
92 contents = [line.rstrip()
for line
in f]
94 comment_removed = [line
for line
in contents
if not line.startswith(
'#')]
95 newline_removed = [line
for line
in comment_removed
if line.startswith(
'eval(')]
98 tests_default_tol = [(arg, binary_path, eval_driver_path)
for arg
in test_args
99 if len(arg.split()) == 1]
101 tests_with_tol = [(arg.split()[0], binary_path, eval_driver_path, arg.split()[1],
102 arg.split()[2])
for arg
in test_args
if len(arg.split()) == 3]
105 for test_item
in tests_default_tol:
107 binary_path, artifacts_path)
109 for test_item
in tests_with_tol:
111 binary_path, artifacts_path)
113 if 'default_test_name' in metafunc.fixturenames:
114 metafunc.parametrize(
'default_test_name,binary_path,eval_driver_path',
117 if 'tol_test_name' in metafunc.fixturenames:
118 metafunc.parametrize(
'tol_test_name,binary_path,eval_driver_path,rtolf32,atolf32',
copy_if_changed(src_filepath, dst_filepath)
pytest_generate_tests(metafunc)
copy_circle_model(model_src, model_dst)
copy_ref_files(ref_file_src, ref_file_dst)
prepare_materials(test_name, tflrecipe_path, circlerecipe_path, binary_path, artifacts_path)