ONE - On-device Neural Engine
Loading...
Searching...
No Matches
conftest.py
Go to the documentation of this file.
1import re
2
3
4def extract_test_args(s):
5 p = re.compile('eval\\((.*)\\)')
6 result = p.search(s)
7 return result.group(1)
8
9
10def pytest_addoption(parser):
11 parser.addoption("--test_list", action="store", help="Path to test list")
12 parser.addoption("--tflite_dir",
13 action="store",
14 help="Directory including tflite file")
15 parser.addoption("--circle_dir",
16 action="store",
17 help="Directory including circle file")
18 parser.addoption("--luci_eval_driver",
19 action="store",
20 help="Path to luci eval driver")
21
22
23def pytest_generate_tests(metafunc):
24 list_path = metafunc.config.getoption('test_list')
25 tflite_dir = metafunc.config.getoption('tflite_dir')
26 circle_dir = metafunc.config.getoption('circle_dir')
27 eval_driver_path = metafunc.config.getoption('luci_eval_driver')
28 if list_path is None:
29 tests_default_tol = []
30 else:
31 with open(list_path) as f:
32 contents = [line.rstrip() for line in f]
33
34 comment_removed = [line for line in contents if not line.startswith('#')]
35 newline_removed = [line for line in comment_removed if line.startswith('eval(')]
36 test_args = [extract_test_args(line) for line in newline_removed]
37 # eval(TEST_NAME)
38 tests_default_tol = [(arg.split()[0], tflite_dir, circle_dir, eval_driver_path)
39 for arg in test_args]
40
41 if 'test_name' in metafunc.fixturenames:
42 metafunc.parametrize('test_name,tflite_dir,circle_dir,eval_driver_path',
43 tests_default_tol)