仿真平台内核初版 -tlib库 包含<sparc arm riscv powerPC>

This commit is contained in:
liuwb
2026-02-07 20:43:43 +08:00
parent de61f9e2b0
commit b3117648be
9748 changed files with 4309137 additions and 0 deletions

View File

@@ -0,0 +1,18 @@
*** Settings ***
Library telnet_library.py
*** Variables ***
${READ_END_MARKER} TEST
*** Test Cases ***
Should Attach To Server Socket Terminal
Execute Command mach create
${RENODE_LOG_PORT}= Find Free Port
Execute Command logNetwork ${RENODE_LOG_PORT}
Telnet Connect ${RENODE_LOG_PORT}
Execute Command log "${READ_END_MARKER}"
${log_data}= Telnet Read Until ${READ_END_MARKER}
Should Contain ${log_data} ${READ_END_MARKER}

View File

@@ -0,0 +1,35 @@
import socket
import asyncio
from telnetlib3 import open_connection, TelnetReader
ENCODING = "utf-8"
reader: TelnetReader
def find_free_port() -> int:
# Return open port number
s = socket.socket()
s.bind(('localhost', 0))
port = s.getsockname()[1]
s.close()
return port
def telnet_connect(port: int) -> None:
global reader
loop = asyncio.get_event_loop()
# Coroutines with event loop required for robot tests
coro = open_connection('localhost', port)
reader, _ = loop.run_until_complete(coro)
def telnet_read_until(until_string: str, timeout: int = 15) -> str:
global reader
loop = asyncio.get_event_loop()
# Wrap the readuntil coroutine with wait_for to add timeout
coro = asyncio.wait_for(reader.readuntil(until_string.encode(ENCODING)), timeout=timeout)
data = loop.run_until_complete(coro)
return data.decode(ENCODING)