1*** Variables *** 2${URI} @https://dl.antmicro.com/projects/renode 3${BIN} uartlite--custom_uart_demo--zephyr.elf-s_184340-129eb92404f437a466cd8700f6743b1c5b0da912 4${UARTLITE_NATIVE_LINUX} ${URI}/libVuartlite-Linux-x86_64-12904733885.so-s_2087832-2d689c6c42723282e927d1b21140476d001b9db9 5${UARTLITE_NATIVE_WINDOWS} ${URI}/libVuartlite-Windows-x86_64-12904733885.dll-s_3250805-26fbac48b0f6e366e6d2efd53bcafe899cfe3bed 6${UARTLITE_NATIVE_MACOS} ${URI}/libVuartlite-macOS-x86_64-12904733885.dylib-s_222512-aa60e4266c82f43805fc2bd4c023daa3f666fdf0 7${UARTLITE_SOCKET_LINUX} ${URI}/Vuartlite-Linux-x86_64-12904733885-s_1634440-1fca77dcce5b8d477afe39d588e2b15d58408faf 8${UARTLITE_SOCKET_WINDOWS} ${URI}/Vuartlite-Windows-x86_64-12904733885.exe-s_3244916-368deeb3e38ff16907f89f71142a26c245f6ee41 9${UARTLITE_SOCKET_MACOS} ${URI}/Vuartlite-macOS-x86_64-12904733885-s_222576-005efcfa289330c23a3eb67058ef1d204d901f63 10${UARTLITE_WRONG_PORTS_LINUX} ${URI}/Vuartlite_wrong_ports-Linux-x86_64-12904733885-s_1634440-4fbae470afd67def8c5561afcd3981155b34bebf 11${UARTLITE_WRONG_PORTS_WINDOWS} ${URI}/Vuartlite_wrong_ports-Windows-x86_64-12904733885.exe-s_3244916-911bee45eb4e21227ccd1c2581f5d77ae96eaf56 12${UARTLITE_WRONG_PORTS_MACOS} ${URI}/Vuartlite_wrong_ports-macOS-x86_64-12904733885-s_222576-7f0a02b68b87328b836291dd3afb21c6fa17d3e1 13${UARTLITE_SLEEP_AFTER_1000_ITERS_SOCKET_LINUX} ${URI}/Vuartlite_sleep_after_1000_iters-Linux-x86_64-12904733885-s_1634488-1f4f250dd973f0f5e67c4b2e222856acdf011781 14${UARTLITE_SLEEP_AFTER_1000_ITERS_SOCKET_WINDOWS} ${URI}/Vuartlite_sleep_after_1000_iters-Windows-x86_64-12904733885.exe-s_3245968-4d0307f72d0293defa20516ad60517a307421d25 15${UARTLITE_SLEEP_AFTER_1000_ITERS_SOCKET_MACOS} ${URI}/Vuartlite_sleep_after_1000_iters-macOS-x86_64-12904733885-s_222616-590a3b5a44836bb8a6e7b27d53e677ce7f406fd0 16${UARTLITE_WRONG_SECOND_PORT_LINUX} ${URI}/Vuartlite_wrong_second_port-Linux-x86_64-12904733885-s_1634440-9555b3643f1399aac5278c72404b97dbea14e250 17${UARTLITE_WRONG_SECOND_PORT_WINDOWS} ${URI}/Vuartlite_wrong_second_port-Windows-x86_64-12904733885.exe-s_3244916-c2d450fff739bbb6ba43d56a42f1f444733a9dc6 18${UARTLITE_WRONG_SECOND_PORT_MACOS} ${URI}/Vuartlite_wrong_second_port-macOS-x86_64-12904733885-s_222576-fa829c3e617c9506c178ef4d2c5388b1cd9fc2d1 19${LOCAL_FILENAME} uartlite 20${UART} sysbus.uart 21${UARTLITE_SCRIPT} scripts/single-node/riscv_verilated_uartlite.resc 22${LOG_TIMEOUT} 1 # virtual seconds 23 24# same as riscv_verilated_uartlite.repl, but adds address for uart 25${PLATFORM}= SEPARATOR=${\n} 26... """ 27... cpu: CPU.RiscV32 @ sysbus 28... ${SPACE*4}cpuType: "rv32g" 29... ${SPACE*4}privilegedArchitecture: PrivilegedArchitecture.Priv1_09 30... ${SPACE*4}timeProvider: clint 31... 32... plic: IRQControllers.PlatformLevelInterruptController @ sysbus 0x40000000 33... ${SPACE*4}0 -> cpu@11 34... ${SPACE*4}numberOfSources: 31 35... ${SPACE*4}numberOfContexts: 1 36... ${SPACE*4}prioritiesEnabled : false 37... 38... clint: IRQControllers.CoreLevelInterruptor @ sysbus 0x44000000 39... ${SPACE*4}frequency: 66000000 40... ${SPACE*4}\[0, 1\] -> cpu@\[3, 7\] 41... 42... ram: Memory.MappedMemory @ sysbus 0x60000000 43... ${SPACE*4}size: 0x06400000 44... 45... uart: CoSimulated.CoSimulatedUART @ sysbus <0x70000000, +0x100> 46... ${SPACE*4}frequency: 100000000 47... ${SPACE*4}address: "127.0.0.1" 48... """ 49 50*** Keywords *** 51Create Machine With Socket Based Communication 52 [Arguments] ${vuartlite_linux} ${vuartlite_windows} ${vuartlite_macos} 53 Execute Command using sysbus 54 Execute Command mach create 55 Execute Command machine LoadPlatformDescriptionFromString ${PLATFORM} 56 Execute Command sysbus LoadELF ${URI}/${BIN} 57 Execute Command cpu PC `sysbus GetSymbolAddress "vinit"` 58 Execute Command uart SimulationFilePathLinux ${vuartlite_linux} 59 Execute Command uart SimulationFilePathWindows ${vuartlite_windows} 60 Execute Command uart SimulationFilePathMacOS ${vuartlite_macos} 61 62*** Test Cases *** 63Should Run UARTLite Binary From Script 64 [Tags] skip_osx skip_host_arm 65 66 Execute Command \$uartLinux?=${UARTLITE_NATIVE_LINUX} 67 Execute Command \$uartWindows?=${UARTLITE_NATIVE_WINDOWS} 68 Execute Script ${UARTLITE_SCRIPT} 69 Create Terminal Tester ${UART} 70 Start Emulation 71 Wait For Line On Uart I'm alive! counter = 10 72 73# Starting emulation without SimulationFilePath(Linux|MacOS|Windows) set 74Should Handle Empty UARTLite Binary 75 [Tags] skip_host_arm 76 Create Log Tester ${LOG_TIMEOUT} 77 Execute Command mach create 78 Execute Command machine LoadPlatformDescription @platforms/cpus/verilated/riscv_verilated_uartlite.repl 79 Execute Command showAnalyzer sysbus.uart 80 Execute Command sysbus LoadELF ${URI}/${BIN} 81 Execute Command sysbus.cpu PC `sysbus GetSymbolAddress "vinit"` 82 Wait For Log Entry Set SimulationFilePath or connect to a simulator first! 83 84# File Doesn't Exist 85Should Handle Nonexistent UARTLite Binary 86 [Tags] skip_osx skip_host_arm 87 88 Execute Command $uartLinux = @nonexistent-uart-binary 89 Execute Command $uartWindows = @nonexistent-uart-binary 90 Execute Command $uartMacOS = @nonexistent-uart-binary 91 Create Log Tester ${LOG_TIMEOUT} 92 Run Keyword And Expect Error *Error starting cosimulated peripheral!* Execute Script ${UARTLITE_SCRIPT} 93 94 95# Following tests use socket based communication 96 97Should Run UARTLite Binary Using Socket 98 [Tags] skip_host_arm 99 Create Machine With Socket Based Communication ${UARTLITE_SOCKET_LINUX} ${UARTLITE_SOCKET_WINDOWS} ${UARTLITE_SOCKET_MACOS} 100 Create Terminal Tester ${UART} 101 Start Emulation 102 Wait For Line On Uart I'm alive! counter = 10 103 104# Sleep after 1000 iterations in "simulate" loop (renode.cpp) 105Should Handle Connection Timeout 106 [Tags] skip_host_arm 107 Set Test Variable ${uartLinux} ${UARTLITE_SLEEP_AFTER_1000_ITERS_SOCKET_LINUX} 108 Set Test Variable ${uartWindows} ${UARTLITE_SLEEP_AFTER_1000_ITERS_SOCKET_WINDOWS} 109 Set Test Variable ${uartMacOS} ${UARTLITE_SLEEP_AFTER_1000_ITERS_SOCKET_MACOS} 110 Create Machine With Socket Based Communication ${uartLinux} ${uartWindows} ${uartMacOS} 111 Create Log Tester ${LOG_TIMEOUT} 112 Create Terminal Tester ${UART} 113 Start Emulation 114 Wait For Line On Uart I'm alive! counter = 9 115 Wait For Log Entry Receive error! 116 117# Both ports wrong when calling "simulate" (sim_main.cpp) 118Should Handle UARTLite Binary Not Connecting 119 [Tags] skip_host_arm 120 Set Test Variable ${uartLinux} ${UARTLITE_WRONG_PORTS_LINUX} 121 Set Test Variable ${uartWindows} ${UARTLITE_WRONG_PORTS_WINDOWS} 122 Set Test Variable ${uartMacOS} ${UARTLITE_WRONG_PORTS_MACOS} 123 Create Log Tester ${LOG_TIMEOUT} 124 Run Keyword And Expect Error *Connection to the cosimulated peripheral failed!* Create Machine With Socket Based Communication ${uartLinux} ${uartWindows} ${uartMacOS} 125 126# Wrong "second" port when calling "simulate" (sim_main.cpp) 127Should Handle UARTLite Binary Partly Connecting 128 [Tags] skip_host_arm 129 Set Test Variable ${uartLinux} ${UARTLITE_WRONG_SECOND_PORT_LINUX} 130 Set Test Variable ${uartWindows} ${UARTLITE_WRONG_SECOND_PORT_WINDOWS} 131 Set Test Variable ${uartMacOS} ${UARTLITE_WRONG_SECOND_PORT_MACOS} 132 Create Log Tester ${LOG_TIMEOUT} 133 Run Keyword And Expect Error *Connection to the cosimulated peripheral failed!* Create Machine With Socket Based Communication ${uartLinux} ${uartWindows} ${uartMacOS} 134 135# Starting emulation without SimulationFilePath(Linux|MacOS|Windows) set 136Should Handle Empty UARTLite Binary With Socket Based Communication 137 [Tags] skip_host_arm 138 Create Log Tester ${LOG_TIMEOUT} 139 Execute Command mach create 140 Execute Command machine LoadPlatformDescriptionFromString ${PLATFORM} 141 Execute Command sysbus LoadELF ${URI}/${BIN} 142 Execute Command sysbus.cpu PC `sysbus GetSymbolAddress "vinit"` 143 Wait For Log Entry Set SimulationFilePath or connect to a simulator first! 144 145# File Doesn't Exist 146Should Handle Nonexistent UARTLite Binary With Socket Based Communication 147 Create Log Tester ${LOG_TIMEOUT} 148 Run Keyword And Expect Error *Error starting cosimulated peripheral!* Create Machine With Socket Based Communication nonexistent-uart-binary nonexistent-uart-binary nonexistent-uart-binary 149