labgrid-boardkit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- labgrid_boardkit/__init__.py +0 -0
- labgrid_boardkit/fixtures.py +77 -0
- labgrid_boardkit/helpers.py +58 -0
- labgrid_boardkit/loader.py +27 -0
- labgrid_boardkit/manifest.py +53 -0
- labgrid_boardkit/ptest/__init__.py +0 -0
- labgrid_boardkit/ptest/test_ptests.py +28 -0
- labgrid_boardkit/render.py +147 -0
- labgrid_boardkit/schema/board.schema.json +145 -0
- labgrid_boardkit/strategies/__init__.py +25 -0
- labgrid_boardkit/strategies/base.py +32 -0
- labgrid_boardkit/strategies/fastboot.py +141 -0
- labgrid_boardkit/strategies/qemu.py +86 -0
- labgrid_boardkit/strategies/sdmux.py +81 -0
- labgrid_boardkit/strategies/tftp.py +109 -0
- labgrid_boardkit/templates/client-fastboot.yaml.j2 +55 -0
- labgrid_boardkit/templates/client-qemu.yaml.j2 +44 -0
- labgrid_boardkit/templates/client-sdmux.yaml.j2 +58 -0
- labgrid_boardkit/templates/client-tftp.yaml.j2 +59 -0
- labgrid_boardkit/templates/strategy.py.j2 +19 -0
- labgrid_boardkit/tests/__init__.py +0 -0
- labgrid_boardkit/tests/test_fastboot.py +23 -0
- labgrid_boardkit/tests/test_sd.py +28 -0
- labgrid_boardkit/tests/test_tftp.py +35 -0
- labgrid_boardkit/validate.py +72 -0
- labgrid_boardkit-0.1.0.dist-info/METADATA +108 -0
- labgrid_boardkit-0.1.0.dist-info/RECORD +30 -0
- labgrid_boardkit-0.1.0.dist-info/WHEEL +4 -0
- labgrid_boardkit-0.1.0.dist-info/entry_points.txt +13 -0
- labgrid_boardkit-0.1.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Shared SD-mux boot smoke tests. Auto-skipped for boards whose strategy
|
|
2
|
+
isn't an SdMuxBootStrategy (see ``sd`` fixture in ``labgrid_boardkit.fixtures``).
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
from labgrid.driver import ExecutionError
|
|
8
|
+
|
|
9
|
+
from labgrid_boardkit import helpers
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_uname_a(sd):
|
|
13
|
+
version = os.environ.get("VERSION")
|
|
14
|
+
try:
|
|
15
|
+
state = sd.run_check("/bin/uname -a", timeout=60.0)
|
|
16
|
+
|
|
17
|
+
assert helpers.kernel_version_in(version, state[0]), state[0]
|
|
18
|
+
except ExecutionError:
|
|
19
|
+
sd.run("ls /bin/uname")
|
|
20
|
+
raise
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_buildinfo(sd):
|
|
24
|
+
try:
|
|
25
|
+
sd.run_check("cat /etc/buildinfo", timeout=60.0)
|
|
26
|
+
except ExecutionError:
|
|
27
|
+
sd.run("ls /etc/")
|
|
28
|
+
raise
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""Shared TFTP boot smoke tests. Auto-skipped for boards whose strategy
|
|
2
|
+
isn't a TftpBootStrategy (see ``tftp`` fixture in ``labgrid_boardkit.fixtures``).
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
|
|
7
|
+
import pytest
|
|
8
|
+
from labgrid.driver import ExecutionError
|
|
9
|
+
|
|
10
|
+
from labgrid_boardkit import helpers
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _is_initramfs(strategy) -> bool:
|
|
14
|
+
"""True if this board's manifest boots a bare initramfs rather than a
|
|
15
|
+
full rootfs (see ``tftp.initramfs`` in board.yaml; a fitImage bundles one)."""
|
|
16
|
+
tftp = strategy.manifest.get("tftp", {})
|
|
17
|
+
return "initramfs" in tftp or tftp.get("kernel") == "fitImage"
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def test_tools_available(tftp, strategy):
|
|
21
|
+
if _is_initramfs(strategy):
|
|
22
|
+
pytest.skip("initramfs boot: busybox-only environment, no /bin/bash expected")
|
|
23
|
+
tools = ["/bin/bash", "/bin/ls"]
|
|
24
|
+
missing = [t for t in tools if tftp.run(f"test -x {t}")[2] != 0]
|
|
25
|
+
assert missing == []
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_uname_a(tftp):
|
|
29
|
+
version = os.environ.get("VERSION")
|
|
30
|
+
try:
|
|
31
|
+
state = tftp.run_check("/bin/uname -a", timeout=60.0)
|
|
32
|
+
assert helpers.kernel_version_in(version, state[0]), state[0]
|
|
33
|
+
except ExecutionError:
|
|
34
|
+
tftp.run("ls /bin/uname")
|
|
35
|
+
raise
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"""Validate board.yaml manifests against ``schema/board.schema.json``.
|
|
2
|
+
|
|
3
|
+
CLI:
|
|
4
|
+
boardkit-validate # walks boards/*/board.yaml under the repo root (cwd)
|
|
5
|
+
boardkit-validate path/to/board.yaml [more.yaml ...]
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
import argparse
|
|
9
|
+
import json
|
|
10
|
+
import sys
|
|
11
|
+
from importlib.resources import files
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
import jsonschema
|
|
15
|
+
|
|
16
|
+
from labgrid_boardkit.loader import strategy_for
|
|
17
|
+
from labgrid_boardkit.manifest import board_variants, load_board
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _schema() -> dict:
|
|
21
|
+
return json.loads(files("labgrid_boardkit.schema").joinpath("board.schema.json").read_text())
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def validate_manifest(manifest: dict) -> None:
|
|
25
|
+
"""Raise ``jsonschema.ValidationError`` if the manifest is invalid.
|
|
26
|
+
|
|
27
|
+
Also confirms the referenced strategy family is registered.
|
|
28
|
+
"""
|
|
29
|
+
jsonschema.validate(manifest, _schema())
|
|
30
|
+
strategy_for(manifest) # raises UnknownStrategy if unregistered
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _iter_board_yamls(root: Path):
|
|
34
|
+
yield from sorted(root.glob("*/board.yaml"))
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def main(argv: list[str] | None = None) -> int:
|
|
38
|
+
parser = argparse.ArgumentParser(description="Validate labgrid-boardkit board.yaml manifests")
|
|
39
|
+
parser.add_argument(
|
|
40
|
+
"paths",
|
|
41
|
+
nargs="*",
|
|
42
|
+
type=Path,
|
|
43
|
+
help="board.yaml files (or board dirs). Default: boards/*/board.yaml under the repo root (cwd).",
|
|
44
|
+
)
|
|
45
|
+
args = parser.parse_args(argv)
|
|
46
|
+
|
|
47
|
+
targets: list[Path] = []
|
|
48
|
+
if args.paths:
|
|
49
|
+
for p in args.paths:
|
|
50
|
+
targets.append(p if p.is_dir() else p.parent)
|
|
51
|
+
else:
|
|
52
|
+
targets = [p.parent for p in _iter_board_yamls(Path.cwd() / "boards")]
|
|
53
|
+
|
|
54
|
+
if not targets:
|
|
55
|
+
print("no board.yaml files found", file=sys.stderr)
|
|
56
|
+
return 2
|
|
57
|
+
|
|
58
|
+
failures = 0
|
|
59
|
+
for board_dir in targets:
|
|
60
|
+
try:
|
|
61
|
+
for variant in [None, *board_variants(board_dir)]:
|
|
62
|
+
validate_manifest(load_board(board_dir, variant))
|
|
63
|
+
except Exception as exc: # noqa: BLE001
|
|
64
|
+
failures += 1
|
|
65
|
+
print(f"FAIL {board_dir}/board.yaml: {exc}", file=sys.stderr)
|
|
66
|
+
else:
|
|
67
|
+
print(f"ok {board_dir}/board.yaml")
|
|
68
|
+
return 0 if failures == 0 else 1
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
if __name__ == "__main__":
|
|
72
|
+
sys.exit(main())
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: labgrid-boardkit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Board manifests, boot strategies, fixtures and test suites for labgrid
|
|
5
|
+
Author: Trevor Gamblin
|
|
6
|
+
Author-email: Trevor Gamblin <tgamblin@baylibre.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: Framework :: Pytest
|
|
10
|
+
Classifier: Topic :: Software Development :: Embedded Systems
|
|
11
|
+
Classifier: Topic :: Software Development :: Testing
|
|
12
|
+
Requires-Dist: jinja2
|
|
13
|
+
Requires-Dist: jsonschema
|
|
14
|
+
Requires-Dist: labgrid>=26.0
|
|
15
|
+
Requires-Dist: pytest
|
|
16
|
+
Requires-Dist: pyyaml
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Project-URL: Repository, https://github.com/threexc/labgrid-boardkit
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# labgrid-boardkit
|
|
22
|
+
|
|
23
|
+
Board manifests, boot strategies, pytest fixtures and test suites for
|
|
24
|
+
[labgrid](https://github.com/labgrid-project/labgrid).
|
|
25
|
+
|
|
26
|
+
Describe a board once in a `board.yaml` manifest, and labgrid-boardkit
|
|
27
|
+
generates its labgrid `client.yaml` and drives it through a reusable boot
|
|
28
|
+
strategy family:
|
|
29
|
+
|
|
30
|
+
| Family | Boots via |
|
|
31
|
+
|------------|---------------------------------------------|
|
|
32
|
+
| `tftp` | U-Boot `tftpboot` (kernel, DTB, initramfs/FIT) |
|
|
33
|
+
| `sdmux` | an SD card image written through a USB-SD-Mux |
|
|
34
|
+
| `fastboot` | images flashed to eMMC/NOR over fastboot |
|
|
35
|
+
| `qemu` | QEMU, no hardware needed |
|
|
36
|
+
|
|
37
|
+
## Install
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
pip install labgrid-boardkit
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
Lay out your boards as `boards/<name>/board.yaml`. Shared settings can go in
|
|
46
|
+
a file listed under `inherits:`. For example (`tests/fixtures/boards/` has one
|
|
47
|
+
board per family, plus a shared `families/` file and a variant):
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
name: example-qemu
|
|
51
|
+
yocto_machine: qemuriscv64
|
|
52
|
+
strategy: qemu
|
|
53
|
+
arch: riscv64
|
|
54
|
+
description: QEMU RISC-V virt machine, no hardware needed
|
|
55
|
+
|
|
56
|
+
boot:
|
|
57
|
+
bootargs: root=/dev/vda rw console=ttyS0
|
|
58
|
+
|
|
59
|
+
qemu:
|
|
60
|
+
binary: qemu-system-riscv64
|
|
61
|
+
machine: virt
|
|
62
|
+
cpu: rv64
|
|
63
|
+
memory: 2048
|
|
64
|
+
ssh_port: 2222
|
|
65
|
+
telnet_port: 2323
|
|
66
|
+
|
|
67
|
+
images:
|
|
68
|
+
bios: /srv/images/example-qemu/fw_jump.elf
|
|
69
|
+
kernel: /srv/images/example-qemu/Image
|
|
70
|
+
ext4: /srv/images/example-qemu/rootfs.ext4
|
|
71
|
+
|
|
72
|
+
shell:
|
|
73
|
+
username: root
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
From the directory that contains `boards/`:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
boardkit-validate # check every boards/*/board.yaml against the schema
|
|
80
|
+
boardkit-render # write each board's client.yaml/env.yaml and boards/machines.tsv
|
|
81
|
+
boardkit-render --check # exit 1 if any rendered file is out of date (for CI)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Installing the package also registers a pytest plugin. It picks `--lg-env`
|
|
85
|
+
from `$BOARD` or the nearest `client.yaml`, and provides the `tftp`, `sd` and
|
|
86
|
+
`fastboot` fixtures. Generic on-target suites ship with the package:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
BOARD=boards/my-board pytest --pyargs labgrid_boardkit.tests
|
|
90
|
+
pytest --lg-env boards/example-qemu/env.yaml --pyargs labgrid_boardkit.ptest
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Adding a strategy family
|
|
94
|
+
|
|
95
|
+
Families are found through the `labgrid_boardkit.strategies` entry-point
|
|
96
|
+
group, so another package can add one without changing this one:
|
|
97
|
+
|
|
98
|
+
```toml
|
|
99
|
+
[project.entry-points."labgrid_boardkit.strategies"]
|
|
100
|
+
myfamily = "my_package.strategies:MyBootStrategy"
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Development
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
uv run pytest
|
|
107
|
+
uv run ruff check . && uv run ruff format --check .
|
|
108
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
labgrid_boardkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
labgrid_boardkit/fixtures.py,sha256=eGwM9caehP5PNFrxWk57LJWgkYO-98UzLzuW7Lj4HKU,2490
|
|
3
|
+
labgrid_boardkit/helpers.py,sha256=Ah82l4gNf5dkviDm_emyzPtCvs-7UazMeexZl-RsBJk,1741
|
|
4
|
+
labgrid_boardkit/loader.py,sha256=a-tctVGmZInBPmLsMoCv5HfXfF6ortDl5vxhvbpeXCE,972
|
|
5
|
+
labgrid_boardkit/manifest.py,sha256=RiuT1pGGz_lDMn0Qk4rPsmsilFpNbvNQOfovQrVJkjE,1894
|
|
6
|
+
labgrid_boardkit/ptest/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
+
labgrid_boardkit/ptest/test_ptests.py,sha256=NSRvbpD5GSzU04prlElB4RZI_gEAVSycZl-wnGACPOA,913
|
|
8
|
+
labgrid_boardkit/render.py,sha256=GmJG-ItQbx6_o2P0HFQ9P_M2LelFH15OnWlU-f_E77I,5679
|
|
9
|
+
labgrid_boardkit/schema/board.schema.json,sha256=4sNcxWFEZoCvdHL0TVfYiQOT5l2dNLwUXRINX8AMYBU,4733
|
|
10
|
+
labgrid_boardkit/strategies/__init__.py,sha256=HRhh5RFf7XRm80uu3xdAX2bXZbIb_IpHDMusV0-Nloc,922
|
|
11
|
+
labgrid_boardkit/strategies/base.py,sha256=DbRR1bfisjAUmS4Ul6E4MSZocg0NJG_M-HL3pk-9XVE,1022
|
|
12
|
+
labgrid_boardkit/strategies/fastboot.py,sha256=DNKzrpw8bPhozwpisqmsAy8IV50ITW3Q-X6f9LUOC74,5326
|
|
13
|
+
labgrid_boardkit/strategies/qemu.py,sha256=zX79sX2VOieZuGtQthMn3pJDhW_lzuZQYwgbqXe_X_0,2677
|
|
14
|
+
labgrid_boardkit/strategies/sdmux.py,sha256=Qj_8I65kk89i2q225X_9yiVxg2ZOXbdnOnHNZhmhQW4,2701
|
|
15
|
+
labgrid_boardkit/strategies/tftp.py,sha256=DmmjIR6wH_E-jgshGpAKiXzVjD24qlwvaK-45lgzMyE,3792
|
|
16
|
+
labgrid_boardkit/templates/client-fastboot.yaml.j2,sha256=iUzRzVRafQE8pgCvMUt_NDIR28F_wZKYmh16ex1E4kE,1811
|
|
17
|
+
labgrid_boardkit/templates/client-qemu.yaml.j2,sha256=a_08sZ8ZFmeSqbIoI24TAcUdXb1LqXDRK1n_YRgIcI4,1731
|
|
18
|
+
labgrid_boardkit/templates/client-sdmux.yaml.j2,sha256=kdlKqs_EmKSrU5qqEmuBvFYX89EA5BWufNKglDNpvME,1662
|
|
19
|
+
labgrid_boardkit/templates/client-tftp.yaml.j2,sha256=fZNWRe_6XNsiWjW93asg6HYFEDiepy5MAVTN6J_V6t0,1926
|
|
20
|
+
labgrid_boardkit/templates/strategy.py.j2,sha256=Wtb8TleXwZdNBguOdTlkg5zixIiiSAjCCrdSLUvFXMo,466
|
|
21
|
+
labgrid_boardkit/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
22
|
+
labgrid_boardkit/tests/test_fastboot.py,sha256=LbytBv8yxasfN8S4J0os9i_E5hFf5hjtNJFW8P9Q9L0,639
|
|
23
|
+
labgrid_boardkit/tests/test_sd.py,sha256=oSt--zInFta8LyN1ktGt_jD-RehISFB7DlMWRd4gQPM,689
|
|
24
|
+
labgrid_boardkit/tests/test_tftp.py,sha256=OMM5pUMyeZwLLxL4eo6KPf96xThFMh97hXBs2DY2pes,1148
|
|
25
|
+
labgrid_boardkit/validate.py,sha256=RCUBZvgjRXbm4jBxVXg5rScWzfsMzczsSyscp7VIv9U,2174
|
|
26
|
+
labgrid_boardkit-0.1.0.dist-info/licenses/LICENSE,sha256=xY6elygjI1Fj2aNTYWlqRSJ5X0Ky2IvsfFwu0wbk9ek,1071
|
|
27
|
+
labgrid_boardkit-0.1.0.dist-info/WHEEL,sha256=MWx7psoF7KNST9G72pGtiBYuaXRXQXBk9pw5R6FzYko,80
|
|
28
|
+
labgrid_boardkit-0.1.0.dist-info/entry_points.txt,sha256=LGy34G5xOAazSn_sv2_mq2425wRwUprN-XVRszLbD1Y,449
|
|
29
|
+
labgrid_boardkit-0.1.0.dist-info/METADATA,sha256=ql_cUp6F7oTCMJFxPWNe6ACXNEAL06dKkYb2V5YnyxY,3157
|
|
30
|
+
labgrid_boardkit-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
[console_scripts]
|
|
2
|
+
boardkit-render = labgrid_boardkit.render:main
|
|
3
|
+
boardkit-validate = labgrid_boardkit.validate:main
|
|
4
|
+
|
|
5
|
+
[labgrid_boardkit.strategies]
|
|
6
|
+
fastboot = labgrid_boardkit.strategies.fastboot:FastbootFlashStrategy
|
|
7
|
+
qemu = labgrid_boardkit.strategies.qemu:QemuBootStrategy
|
|
8
|
+
sdmux = labgrid_boardkit.strategies.sdmux:SdMuxBootStrategy
|
|
9
|
+
tftp = labgrid_boardkit.strategies.tftp:TftpBootStrategy
|
|
10
|
+
|
|
11
|
+
[pytest11]
|
|
12
|
+
labgrid_boardkit = labgrid_boardkit.fixtures
|
|
13
|
+
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Trevor Gamblin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|