Skip to content

Commit 72c67a1

Browse files
committed
test: add initial tests for the VCS tool plugin.
Signed-off-by: James McCorrie <[email protected]>
1 parent edd52b2 commit 72c67a1

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

tests/tool/test_vcs.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# copyright lowrisc contributors (opentitan project).
2+
# licensed under the apache license, version 2.0, see license for details.
3+
# spdx-license-identifier: apache-2.0
4+
5+
"""Test the VCS tool plugin."""
6+
7+
from collections.abc import Sequence
8+
9+
import pytest
10+
from hamcrest import assert_that, equal_to
11+
12+
from dvsim.tool.utils import get_sim_tool_plugin
13+
14+
__all__ = ("TestVCSToolPlugin",)
15+
16+
17+
def fake_log(sim_time: float = 1, sim_time_units: str = "s") -> Sequence[str]:
18+
"""Fabricate a log."""
19+
return [
20+
"Other",
21+
"log",
22+
"content",
23+
"",
24+
" V C S S i m u l a t i o n R e p o r t ",
25+
f"Time: {sim_time} {sim_time_units}",
26+
]
27+
28+
29+
class TestVCSToolPlugin:
30+
"""Test the VCS tool plug-in."""
31+
32+
@staticmethod
33+
@pytest.mark.parametrize(
34+
("time", "units"),
35+
[
36+
(1.2, "s"),
37+
(2.12, "ps"),
38+
(3.73, "S"),
39+
(4.235, "pS"),
40+
(5.5134, "PS"),
41+
],
42+
)
43+
def test_get_simulated_time(time: int, units: str) -> None:
44+
"""Test that sim plugins can be retrieved correctly."""
45+
plugin = get_sim_tool_plugin("vcs")
46+
47+
assert_that(
48+
plugin.get_simulated_time(
49+
log_text=fake_log(
50+
sim_time=time,
51+
sim_time_units=units,
52+
)
53+
),
54+
equal_to((time, units.lower())),
55+
)

0 commit comments

Comments
 (0)