-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker.py
executable file
·138 lines (111 loc) · 4.63 KB
/
worker.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env python
"""
Run a build and test profile for reporting to LIVVkit's CDash board
"""
import argparse
import os
import platform
from ruamel.yaml import YAML, YAMLError
from pyctest import pyctest
from pyctest import helpers
_HERE = os.path.abspath(os.path.dirname(__file__))
def parse_args(cl_args=None):
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawTextHelpFormatter
)
parser.add_argument(
"profile", help="A YAML file describing the build and test profile to run"
)
parser.add_argument("--site", help="Specify the site name", default=None)
parser.add_argument(
"-S",
"--submit",
help="Submit test results to CDASH",
action="store_true",
default=False,
)
worker_args = parser.parse_args(cl_args)
if worker_args.site is None:
worker_args.site = platform.node()
with open(worker_args.profile) as stream:
try:
yaml = YAML(typ="safe")
build_profile = yaml.load(stream)
except YAMLError as e:
print(e)
# NOTE: Just use defaults
pyctest_args = helpers.ArgumentParser(
"LIVVkit",
build_profile["source_directory"],
build_profile["build_directory"],
drop_site="my.cdash.org",
drop_method="http",
site=worker_args.site,
submit=worker_args.submit,
).parse_args(args=[])
return build_profile, pyctest_args
def run(build_profile, pyctest_args):
mali_pio_error = "Failed to compile a PIO test program"
pyctest.MODEL = build_profile["cdash_section"]
pyctest.BUILD_NAME = build_profile["build_name"]
# Test Timeout set in build profile, otherwise default to 10 minutes
test_timeout = build_profile.get("test_timeout", 600)
_ready_command = ["cp"]
for cmd in ["configure_command", "build_command", "test_command"]:
if cmd in build_profile:
_ready_command.append(os.path.join(_HERE, build_profile[cmd]))
_ready_command.append(".")
ready_machine = pyctest.command(_ready_command)
ready_machine.SetWorkingDirectory(pyctest.BINARY_DIRECTORY)
ready_machine.SetErrorQuiet(False)
ready_machine.Execute()
helpers.Cleanup(pyctest.BINARY_DIRECTORY)
# Try again a few times if the submission fails...maybe helps the problem
# with tests completing but not submitting to CDash, I hope?
# Also increase the time between attempts
pyctest.SUBMIT_RETRY_COUNT = 3
pyctest.SUBMIT_RETRY_DELAY = 45
if "configure_command" in build_profile:
pyctest.CONFIGURE_COMMAND = " ".join(
["bash", os.path.basename(build_profile["configure_command"])]
)
if "config_opts" in build_profile:
# Add options to select BISICLES / CHOMBO versions
pyctest.CONFIGURE_COMMAND += " {bisicles} {chombo}".format(
**build_profile["config_opts"]
)
if "build_command" in build_profile:
pyctest.BUILD_COMMAND = " ".join(
["bash", os.path.basename(build_profile["build_command"])]
)
if "MALI" in pyctest.BUILD_NAME:
pyctest.set("CTEST_CUSTOM_ERROR_MATCH", mali_pio_error)
if "tests" in build_profile:
# Check links to see where BISICLES and Chombo point to
if "BISICLES" in pyctest.BUILD_NAME:
_bis_build = os.readlink(
f"{build_profile['source_directory']}/BISICLES"
).split("_")[-1][:-1]
_cho_build = os.readlink(
f"{build_profile['source_directory']}/Chombo"
).split("_")[-1][:-1]
pyctest.BUILD_NAME += f"_B{_bis_build[0].upper()}_C{_cho_build[0].upper()}"
for test in build_profile["tests"]:
test_runner = pyctest.test(properties={"TIMEOUT": f"{test_timeout:d}"})
# Echo tests are comma separated so two arguments are passed to the
# bash script to avoid bash having to do string processing
# the test will be in the yaml file as (e.g.: echo,Dome_restart_test)
# and the test `name` would be echo_Dome_restart_test to match the old style
# If there's no comma in the test name, the split/re-join doesn't have any effect
test_runner.SetName("_".join(test.split(",")))
test_runner.SetCommand(
[
"bash",
os.path.basename(build_profile["test_command"]),
*test.split(","),
]
)
test_runner.SetProperty("WORKING_DIRECTORY", pyctest.BINARY_DIRECTORY)
pyctest.run(pyctest.ARGUMENTS)
if __name__ == "__main__":
run(*parse_args())