-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.py
83 lines (58 loc) · 2.52 KB
/
build.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
# Copyright 2021, Proofcraft Pty Ltd
#
# SPDX-License-Identifier: BSD-2-Clause
"""
Parse builds.yml and run CAmkES VM test on each of the build definitions.
Expects seL4-platforms/ to be co-located or otherwise in the PYTHONPATH.
"""
from builds import Build, run_build_script, run_builds, load_builds, release_mq_locks, SKIP
from pprint import pprint
import os
import sys
# See also builds.yml for how builds are split up in this test. We use the build
# matrix and filtering for the hardware builds, and an explicit list for the
# simulation builds.
# The only thing this really has in common with a "Build" is the "name" field.
def run_build(manifest_dir: str, build: Build):
"""Run one CAmkES VM test."""
plat = build.get_platform()
build.files = plat.image_names(build.get_mode(), "capdl-loader")
build.settings['CAMKES_VM_APP'] = build.app or build.name
del build.settings['BAMBOO'] # not used in this test, avoid warning
if plat.arch == 'x86':
del build.settings['PLATFORM'] # not used for x86 in this test, avoid warning
# if vm_platform is set, the init-build.sh script expects a different platform name.
if build.vm_platform:
build.settings['PLATFORM'] = build.vm_platform
script = [
["../init-build.sh"] + build.settings_args(),
["ninja"],
["tar", "czf", f"../{build.name}-images.tar.gz", "images/"],
]
if plat.has_simulation and plat.name != 'PC99':
script.append(
["bash", "-c",
f"expect -c 'spawn ./simulate; set timeout 3000; expect \"{build.success}\"'"]
)
return run_build_script(manifest_dir, build, script)
def hw_run(manifest_dir: str, build: Build):
"""Run one hardware test."""
if build.is_disabled():
print(f"Build {build.name} disabled, skipping.")
return SKIP
plat = build.get_platform()
build.files = plat.image_names(build.get_mode(), "capdl-loader")
script, final = build.hw_run('log.txt')
return run_build_script(manifest_dir, build, script, final_script=final)
# If called as main, run all builds from builds.yml
if __name__ == '__main__':
builds = load_builds(os.path.dirname(__file__) + "/builds.yml")
if len(sys.argv) > 1 and sys.argv[1] == '--dump':
pprint(builds)
sys.exit(0)
elif len(sys.argv) > 1 and sys.argv[1] == '--hw':
sys.exit(run_builds(builds, hw_run))
elif len(sys.argv) > 1 and sys.argv[1] == '--post':
release_mq_locks(builds)
sys.exit(0)
sys.exit(run_builds(builds, run_build))