CIRCT 23.0.0git
Loading...
Searching...
No Matches
test_esitester.py
Go to the documentation of this file.
1# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2# See https://llvm.org/LICENSE.txt for license information.
3# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5from __future__ import annotations
6
7from esiaccel.cosim.pytest import cosim_test
8
9from .conftest import HW_DIR, check_lines, require_tool, run_cmd
10
11
12@cosim_test(HW_DIR / "esitester.py", args=("{tmp_dir}", "cosim"))
14
15 def setup_method(self) -> None:
16 require_tool("esitester")
17 require_tool("esiquery")
18
19 def test_callback(self, host: str, port: int) -> None:
20 conn = f"{host}:{port}"
21 stdout = run_cmd(["esitester", "-v", "cosim", conn, "callback", "-i", "5"])
22 check_lines(stdout, [
23 "[CONNECT] connecting to backend",
24 ])
25 # The callback loop should print values 0 through 4.
26 for i in range(5):
27 assert f"callback: {i}" in stdout, \
28 f"Expected 'callback: {i}' in stdout"
29
30 def test_streaming_add(self, host: str, port: int) -> None:
31 conn = f"{host}:{port}"
32 stdout = run_cmd(["esitester", "cosim", conn, "streaming_add"])
33 check_lines(stdout, [
34 "Streaming add test results:",
35 "input[0]=222709 + 5 = 222714 (expected 222714)",
36 "input[1]=894611 + 5 = 894616 (expected 894616)",
37 "input[2]=772894 + 5 = 772899 (expected 772899)",
38 "input[3]=429150 + 5 = 429155 (expected 429155)",
39 "input[4]=629806 + 5 = 629811 (expected 629811)",
40 "Streaming add test passed",
41 ])
42
43 def test_streaming_add_quiet(self, host: str, port: int) -> None:
44 conn = f"{host}:{port}"
45 stdout = run_cmd(["esitester", "cosim", conn, "streaming_add", "-t"])
46 check_lines(stdout, [
47 "Streaming add test results:",
48 "Streaming add test passed",
49 ])
50
51 def test_translate_coords(self, host: str, port: int) -> None:
52 conn = f"{host}:{port}"
53 stdout = run_cmd(["esitester", "cosim", conn, "translate_coords"])
54 check_lines(stdout, [
55 "Coord translate test results:",
56 "coord[0]=(222709,894611) + (10,20) = (222719,894631)",
57 "coord[1]=(772894,429150) + (10,20) = (772904,429170)",
58 "coord[2]=(629806,138727) + (10,20) = (629816,138747)",
59 "coord[3]=(218516,390276) + (10,20) = (218526,390296)",
60 "coord[4]=(750021,423525) + (10,20) = (750031,423545)",
61 "Coord translate test passed",
62 ])
63
64 def test_serial_coords(self, host: str, port: int) -> None:
65 conn = f"{host}:{port}"
66 stdout = run_cmd(
67 ["esitester", "cosim", conn, "serial_coords", "-n", "40", "-b", "33"])
68 check_lines(stdout, [
69 "Serial coord translate test results:",
70 "coord[0]=",
71 "Serial coord translate test passed",
72 ])
73
74 def test_telemetry(self, host: str, port: int) -> None:
75 conn = f"{host}:{port}"
76 stdout = run_cmd(["esiquery", "cosim", conn, "telemetry"])
77 check_lines(stdout, [
78 "* Telemetry",
79 "fromhostdma[32].fromHostCycles: 0",
80 "readmem[32].addrCmdCycles: 0",
81 "readmem[32].addrCmdIssued: 0",
82 "readmem[32].addrCmdResponses: 0",
83 "readmem[32].lastReadLSB: 0",
84 "tohostdma[32].toHostCycles: 0",
85 "tohostdma[32].totalWrites: 0",
86 "writemem[32].addrCmdCycles: 0",
87 "writemem[32].addrCmdIssued: 0",
88 "writemem[32].addrCmdResponses: 0",
89 ])
90
91
92@cosim_test(HW_DIR / "esitester.py", args=("{tmp_dir}", "cosim_dma"))
94
95 def setup_method(self) -> None:
96 require_tool("esitester")
97 require_tool("esiquery")
98
99 def test_hostmem(self, host: str, port: int) -> None:
100 conn = f"{host}:{port}"
101 run_cmd(["esitester", "cosim", conn, "hostmem"])
102
103 def test_dma(self, host: str, port: int) -> None:
104 conn = f"{host}:{port}"
105 run_cmd(["esitester", "cosim", conn, "dma", "-w", "-r"])
106
107 def test_telemetry(self, host: str, port: int) -> None:
108 conn = f"{host}:{port}"
109 stdout = run_cmd(["esiquery", "cosim", conn, "telemetry"])
110 check_lines(stdout, [
111 "* Telemetry",
112 "fromhostdma[32].fromHostCycles: 0",
113 "tohostdma[32].toHostCycles: 0",
114 ])
None test_streaming_add_quiet(self, str host, int port)
None test_translate_coords(self, str host, int port)
None test_streaming_add(self, str host, int port)
None test_serial_coords(self, str host, int port)