forked from avengineers/SPLed
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_Disco.py
More file actions
104 lines (90 loc) · 3.38 KB
/
test_Disco.py
File metadata and controls
104 lines (90 loc) · 3.38 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
from pathlib import Path
from typing import Generator
import pytest
from spl_core.test_utils.spl_build import SplBuild
from spl_core.test_utils.artifacts_archiver import ArtifactsArchiver
class Test_Disco:
variant: str = "Disco"
components: list[str] = [
"components/light_controller",
"components/main_control_knob",
"components/power_button",
"components/power_signal_processing",
]
@pytest.fixture(scope="class")
def archiver(self) -> Generator[ArtifactsArchiver, None, None]:
archiver_instance = ArtifactsArchiver()
out_dir = Path("build", self.variant)
archiver_instance.add_archive(
out_dir=out_dir,
archive_filename=self.variant + ".7z",
)
yield archiver_instance
# Create archive and RT upload JSON after all tests in the class have completed
archiver_instance.create_archive()
@pytest.mark.parametrize(
("build_type"),
[
pytest.param("Debug", marks=pytest.mark.build_debug),
pytest.param("Release", marks=pytest.mark.build_release),
],
)
def test_build(self, build_type, archiver: ArtifactsArchiver):
# Arrange
spl_build: SplBuild = SplBuild(
variant=self.variant,
build_kit="prod",
build_type=build_type,
target="all",
)
artifacts = spl_build.get_variant_artifacts()
artifacts.extend(
[
spl_build.build_dir / "spled.exe",
spl_build.build_dir / "kconfig",
]
)
archiver.register(artifacts=artifacts)
# Act
result = spl_build.execute()
# Assert
assert result == 0, "Building failed"
for artifact in artifacts:
assert artifact.exists(), f"Variant artifact {artifact} does not exist"
@pytest.mark.unittests
def test_unittests(self):
# Arrange
spl_build: SplBuild = SplBuild(
variant=self.variant,
build_kit="test",
build_type="Debug",
target="unittests",
)
# Act
result = spl_build.execute()
# Assert
assert result == 0, "Building unittests failed"
artifacts = spl_build.get_components_artifacts(self.components)
for artifact in artifacts:
assert artifact.exists(), f"Artifact {artifact} does not exist"
@pytest.mark.reports
def test_reports(self, archiver: ArtifactsArchiver):
# Arrange
spl_build: SplBuild = SplBuild(
variant=self.variant,
build_kit="test",
build_type="Debug",
target="reports",
)
artifacts_to_be_archived = [spl_build.build_dir / "reports/html"]
for component in self.components:
artifacts_to_be_archived.append(spl_build.build_dir / component / "junit.xml")
artifacts_to_be_archived.append(spl_build.build_dir / component / "coverage.json")
archiver.register(artifacts=artifacts_to_be_archived)
# Act
result = spl_build.execute()
# Assert
assert result == 0, "Building reports failed"
expected_artifacts = spl_build.get_components_artifacts(self.components) + artifacts_to_be_archived
for artifact in expected_artifacts:
assert artifact.exists(), f"Artifact {artifact} does not exist"