-
Notifications
You must be signed in to change notification settings - Fork 18
/
resolve_binaries.py
executable file
·72 lines (53 loc) · 1.87 KB
/
resolve_binaries.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /usr/bin/env python3
import argparse
from trunner.test_runner import TestsRunner
from trunner.config import Config, ConfigParser, TestCaseConfig, TestConfig, PHRTOS_TEST_DIR, \
ALL_TARGETS
def parse_args():
parser = argparse.ArgumentParser(
description="Program prints binaries defined in the yamls configs accepted by the runner. "
"If the target flag is used, then configs are constricted to targets specified "
"by a user."
)
parser.add_argument("-T", "--target",
action='append',
choices=ALL_TARGETS,
help="Filters binaries by target. Flag can be used multiple times.")
args = parser.parse_args()
if not args.target:
args.target = list(ALL_TARGETS)
return args
def resolve_test_bins(targets):
runner = TestsRunner(
targets=targets,
test_paths=[PHRTOS_TEST_DIR],
build=False,
flash=False
)
runner.search_for_tests()
execs = set()
parser = ConfigParser()
for path in runner.test_paths:
config = TestCaseConfig.load_yaml(path)
main, tests = TestCaseConfig.extract_components(config)
main = Config.from_dict(main)
for test in tests:
test = TestConfig(test)
parser.parse(test)
test.join_targets(main)
test.setdefault_targets()
parser.resolve_targets(test, targets)
if not test['targets']['value']:
# test is not for our target
continue
exec_cmd = test.get('exec') or main.get('exec')
if exec_cmd:
execs.add(exec_cmd[0])
return list(execs)
def main():
args = parse_args()
execs = resolve_test_bins(args.target)
for binary in execs:
print(binary)
if __name__ == "__main__":
main()