1*** Keywords **
2
3Create Platform
4             Execute Command          mach create
5             Execute Command          using sysbus
6             Execute Command          machine LoadPlatformDescriptionFromString "cpu: CPU.RiscV32 @ sysbus { cpuType: \\"rv32gc\\"; timeProvider: empty }"
7             Execute Command          machine LoadPlatformDescriptionFromString "mem: Memory.MappedMemory @ sysbus 0x0 { size: 0x1000 }"
8             Execute Command          machine LoadPlatformDescriptionFromString "uart: UART.LiteX_UART @ sysbus 0x2000"
9             Execute Command          machine LoadPlatformDescriptionFromString "radio: Wireless.NRF52840_Radio @ sysbus 0x3000"
10
11Should Throw Python Syntax Exception
12             [Arguments]    ${command}
13    ${out}=  Run Keyword And Expect Error  KeywordException:*
14             ...                      Execute Command          ${command}
15             Should Contain           ${out}      [FatalError] unexpected EOF while parsing (Line 1, Column 9)
16
17Read Should Be Equal
18             [Arguments]    ${type}    ${address}    ${value}
19
20    ${res}=  Execute Command              sysbus Read${type} ${address}
21             Should Be Equal As Integers  ${res}  ${value}
22
23*** Test Cases ***
24
25Should Return Syntax Error
26             [Tags]                   skip_windows
27             Create Platform
28
29             # BlockPythonEngine
30             Should Throw Python Syntax Exception
31             ...                      cpu AddHook 0xC0FFEE "if error"
32
33             # InterruptPythonEngine
34             Should Throw Python Syntax Exception
35             ...                      cpu AddHookAtInterruptBegin "if error"
36
37             # BusPeripheralsHooksPythonEngine
38             Should Throw Python Syntax Exception
39             ...                      sysbus SetHookAfterPeripheralRead uart "if error"
40
41             # WatchpointHookPythonEngine
42             Should Throw Python Syntax Exception
43             ...                      sysbus AddWatchpointHook 0xC0FFEE Byte Read "if error"
44
45             # PacketInterceptionPythonEngine
46             Execute Command          emulation CreateIEEE802_15_4Medium "wireless"
47             Should Throw Python Syntax Exception
48             ...                      wireless SetPacketHookFromScript radio "if error"
49
50             # UartPythonEngine
51             Should Throw Python Syntax Exception
52             ...                      uart AddLineHook "foobar" "if error"
53
54             # UserStatePythonEngine
55             Should Throw Python Syntax Exception
56             ...                      machine AddUserStateHook "foobar" "if error"
57
58Should Abort On Runtime Error
59             [Tags]                   skip_windows
60             Create Platform
61             Create Log Tester        1
62
63             Execute Command          logLevel -1 cpu
64             Execute Command          cpu InstallCustomInstructionHandlerFromString "11111111111111111111111100001011" "a = b"
65             Execute Command          sysbus WriteDoubleWord 0x00000000 0xffffff0b
66             Execute Command          cpu PC 0x00000000
67
68             Execute Command          cpu Step
69             Wait For Log Entry       Python runtime error: name 'b' is not defined
70             Wait For Log Entry       CPU abort detected, halting.
71
72PyDev Should Handle QuadWord Accesses
73             [Tags]                   skip_windows
74             Execute Command          mach create
75             Execute Command          numbersMode Hexadecimal
76
77    ${init_value} =     Set Variable  0x1234567890abcdef
78    ${init_value_32} =  Evaluate      ${init_value} & 0xFFFFFFFF
79    ${pydev_script} =   Catenate      SEPARATOR=\n
80             ...                      """
81             ...                      if request.isInit:
82             ...                      \ \ value = ${init_value}
83             ...                      elif request.isRead:
84             ...                      \ \ request.value = value
85             ...                      elif request.isWrite:
86             ...                      \ \ value = request.value
87             ...                      """
88    ${pydev_address} =  Set Variable  0x8
89
90             Execute Command          machine PyDevFromString ${pydev_script} ${pydev_address} 8 True
91             Read Should Be Equal     QuadWord  ${pydev_address}  ${init_value}
92             Read Should Be Equal     DoubleWord  ${pydev_address}  ${init_value_32}
93
94    ${new_value} =      Set Variable  0xfedcba0987654321
95             Execute Command          sysbus WriteQuadWord ${pydev_address} ${new_value}
96             Read Should Be Equal     QuadWord  ${pydev_address}  ${new_value}
97
98Should Handle Unsupported Variable Types
99             [Tags]                   skip_windows
100             Execute Command          $a=1
101
102    ${out}=  Run Keyword And Expect Error  KeywordException:*
103             ...                      Execute Command          py $a
104             Should Contain           ${out}      There was an error when executing command 'py $a': Variable type has to be a string.
105