-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathmatrix.py
More file actions
175 lines (157 loc) · 5.04 KB
/
Copy pathmatrix.py
File metadata and controls
175 lines (157 loc) · 5.04 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env python3
# Copyright 2025, UNSW
# SPDX-License-Identifier: BSD-2-Clause
from __future__ import annotations
from itertools import chain
from typing import TYPE_CHECKING, Any, Literal, Optional, Sequence, TypedDict
from ts_ci import MACHINE_QUEUE_BOARDS, matrix_product
from . import common
from .common import TestConfig, TestFunction, BackendFunction
# longer because release mode image unpacking of vmms
NO_OUTPUT_DEFAULT_TIMEOUT_S: int = 300
def generate_example_test_cases(
test: str,
example_names: list[str],
test_fn: TestFunction,
backend_fn: BackendFunction,
no_output_timeout_s: int,
) -> list[TestConfig]:
def listify(s: str | Sequence[str]) -> Sequence[str]:
if isinstance(s, str):
return [s]
else:
return s
examples_matrices = [EXAMPLES[ex] for ex in example_names]
test_cases = set()
for example in example_names:
example_matrix = EXAMPLES[example]
test_cases |= set(
matrix_product(
TestConfig,
test=[test],
example=[example],
board=example_matrix["boards"],
config=example_matrix["configs"],
build_system=example_matrix["build_systems"],
test_fn=[test_fn],
backend_fn=[backend_fn],
no_output_timeout_s=[no_output_timeout_s],
)
)
for exclude in example_matrix["tests_exclude"]:
test_cases -= set(
matrix_product(
TestConfig,
test=[test],
example=[example],
board=listify(exclude.get("board", example_matrix["boards"])),
config=listify(exclude.get("config", example_matrix["configs"])),
build_system=listify(
exclude.get("build_system", example_matrix["build_systems"])
),
test_fn=[test_fn],
backend_fn=[backend_fn],
no_output_timeout_s=[no_output_timeout_s],
)
)
return list(test_cases)
EXAMPLES: dict[str, _ExampleMatrixType] = {
"rust": {
"configs": ["debug", "release"],
"build_systems": ["make"],
"boards": [
"qemu_virt_aarch64",
],
# disabled due to https://github.com/seL4/microkit/pull/532 breaking rust-sel4
"tests_exclude": [
{ "config": "debug" },
{ "config": "release" },
],
},
"simple": {
"configs": ["debug", "release"],
"build_systems": ["make"],
"boards": [
"qemu_virt_aarch64",
"odroidc4",
"maaxboard",
"qemu_virt_x86_64",
"skylake",
],
"tests_exclude": [],
},
"smp": {
"configs": ["smp-debug", "smp-release"],
"build_systems": ["make"],
"boards": [
"qemu_virt_aarch64",
"odroidc4",
"maaxboard",
],
# Disable until https://github.com/au-ts/libvmm/issues/233 is resolved.
"tests_exclude": [
{ "config": "smp-debug" },
{ "config": "smp-release" },
],
},
"virtio": {
"configs": ["debug", "release"],
"build_systems": ["make"],
"boards": [
"qemu_virt_aarch64",
"maaxboard",
],
"tests_exclude": [],
},
"virtio_pci": {
"configs": ["debug", "release"],
"build_systems": ["make"],
"boards": [
"qemu_virt_aarch64",
"maaxboard",
"qemu_virt_x86_64",
],
"tests_exclude": [],
},
"virtio_vswitch": {
"configs": ["smp-debug", "smp-release"],
"build_systems": ["make"],
"boards": [
"qemu_virt_aarch64",
"maaxboard",
],
"tests_exclude": [],
},
}
## Type Hinting + Sanity Checks ##
_BoardNames = Literal[
"maaxboard",
"odroidc4",
"qemu_virt_aarch64",
# Note that these are not valid Microkit boards but
# rather the testing targets, which maps to x86_64_generic_vtx
"qemu_virt_x86_64",
"vb_105",
"skylake",
]
known_board_names = set(MACHINE_QUEUE_BOARDS.keys()) | {
# simulation boards
"qemu_virt_aarch64",
"qemu_virt_riscv64",
"qemu_virt_x86_64",
"vb_105",
"skylake",
}
assert (
set(_BoardNames.__args__) <= known_board_names # type: ignore
), f"_BoardNames contains a board that is not valid {known_board_names ^ set(_BoardNames.__args__)}" # type: ignore
for ex in EXAMPLES.values():
for board in chain(
ex["boards"], (excl["board"] for excl in ex["tests_exclude"] if "board" in excl)
):
assert board in known_board_names, f"{board} not a valid board"
class _ExampleMatrixType(TypedDict):
configs: list[Literal["debug", "release", "benchmark", "smp-debug", "smp-release", "smp-benchmark"]]
build_systems: list[Literal["make"]]
boards: list[_BoardNames]
tests_exclude: list[dict[str, str]]