Skip to content

Commit a52eff3

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

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

tests/tool/test_vcs.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
from hamcrest import assert_that, equal_to
10+
11+
from dvsim.tool.utils import get_sim_tool_plugin
12+
13+
__all__ = ("TestVCSToolPlugin",)
14+
15+
16+
def fake_log(sim_time: int = 10, sim_time_units: str = "units") -> Sequence[str]:
17+
"""Fabricate a log."""
18+
return [
19+
"Other",
20+
"log",
21+
"content",
22+
"",
23+
" V C S S i m u l a t i o n R e p o r t ",
24+
f"Time: {sim_time} {sim_time_units}",
25+
]
26+
27+
28+
class TestVCSToolPlugin:
29+
"""Test the VCS tool plug-in."""
30+
31+
@staticmethod
32+
def test_get_simulated_time() -> None:
33+
"""Test that sim plugins can be retrieved correctly."""
34+
plugin = get_sim_tool_plugin("vcs")
35+
36+
assert_that(
37+
plugin.get_simulated_time(
38+
log_text=fake_log(
39+
sim_time=12345,
40+
sim_time_units="squids",
41+
)
42+
),
43+
equal_to((12345, "squids")),
44+
)

0 commit comments

Comments
 (0)