1*** Variables ***
2${LINUX_UART}                                   sysbus.uart1
3${UBOOT_UART}                                   sysbus.uart1
4${ZEPHYR_UART}                                  sysbus.uart0
5${OPENAMP_UART}                                 sysbus.uart0
6${LINUX_PROMPT}                                 \#${SPACE}
7${ZEPHYR_PROMPT}                                uart:~$
8${UBOOT_PROMPT}                                 ZynqMP r5>
9${I2C_ECHO_ADDRESS}                             0x10
10
11${URL_BASE}                                     https://dl.antmicro.com/projects/renode
12${ZEPHYR_BASIC_SYS_HEAP}                        @${URL_BASE}/zephyr-basic_sys_heap-xilinx_zynqmp_r5.elf-s_438388-8991d33506751fe196ee3eb488144583ba0ccbd7
13${ZEPHYR_COMPRESSION_LZ4}                       @${URL_BASE}/zephyr-compression_lz4-xilinx_zynqmp_r5.elf-s_862900-fbcf30b0880cabd5e807d9b166edb30af6292724
14${ZEPHYR_CPP_SYNCHRONIZATION}                   @${URL_BASE}/zephyr-cpp_cpp_synchronization-xilinx_zynqmp_r5.elf-s_493632-f7cd8210dde1935690ba706dd4d56f51c369be37
15${ZEPHYR_HELLO_WORLD}                           @${URL_BASE}/zephyr-hello_world-xilinx_zynqmp_r5.elf-s_388044-7673bd83fa331e9cab9281a0c000d9774479d4c4
16${ZEPHYR_KERNEL_CONDITION_VARIABLES_CONDVAR}    @${URL_BASE}/zephyr-kernel_condition_variables_condvar-xilinx_zynqmp_r5.elf-s_495360-20c5dc4d6c886c51fde9ce2d4057966762d410c9
17${ZEPHYR_KERNEL_CONDITION_VARIABLES_SIMPLE}     @${URL_BASE}/zephyr-kernel_condition_variables_simple-xilinx_zynqmp_r5.elf-s_493588-ff54eafc5f0aca434358a5c715058ad77166346b
18${ZEPHYR_KERNEL_METAIRQ_DISPATCH}               @${URL_BASE}/zephyr-kernel_metairq_dispatch-xilinx_zynqmp_r5.elf-s_551952-d4792b65f1cb6e172cd4d653d4b373abd1366b92
19${ZEPHYR_PHILOSOPHERS}                          @${URL_BASE}/zephyr-philosophers-xilinx_zynqmp_r5.elf-s_515508-f1bcfa0adcf29714365ae53609420644614298c9
20${ZEPHYR_SYNCHRONIZATION}                       @${URL_BASE}/zephyr-synchronization-xilinx_zynqmp_r5.elf-s_409936-c67fa8fb36a0318e82a45e57f0c8436c6af4740d
21${ZEPHYR_SHELL}                                 @${URL_BASE}/zephyr-subsys_shell_shell_module-xilinx_zynqmp_r5.elf-s_1310204-e0e970d25e7c5d471c1d2d308e3f30944c414490
22${ZEPHYR_USERSPACE_HELLO_WORLD_NO_MPU}          @${URL_BASE}/zephyr-userspace_hello_world_user-xilinx_zynqmp_r5-no_mpu.elf-s_411848-1b3bc43849411db05745b5226bb64350ece53500
23${ZEPHYR_TESTS_KERNEL_FPU_SHARING}              @${URL_BASE}/zephyr-kernel_fpu_sharing_generic-xilinx_zynqmp_r5.elf-s_515064-6f0345a25b12e1e8e5c130266ddd2568e3e7138f
24${ZEPHYR_USERSPACE_HELLO_WORLD}                 @${URL_BASE}/zephyr-userspace_hello_world_user-xilinx_zynqmp_r5.elf-s_1032888-0009042615539a30dbe799896b96501d0f90ae84
25${ZEPHYR_MPU_TEST}                              @${URL_BASE}/zephyr-arch_mpu_mpu_test-xilinx_zynqmp_r5.elf-s_1149568-ae2c8f6e5e8219564e4640c47cfef5e33fcf2ea4
26${ZEPHYR_USERSPACE_PROD_CONSUMER}               @${URL_BASE}/zephyr-userspace_prod_consumer-xilinx_zynqmp_r5.elf-s_1343804-9f7520160bb347a15f01e1a25bd94c87007335af
27${ZEPHYR_USERSPACE_SHARED_MEM}                  @${URL_BASE}/zephyr-userspace_shared_mem-xilinx_zynqmp_r5.elf-s_1081056-a43ec0a1353e21c55908bbed997d6a52b8d031fb
28${LINUX_32BIT_ROOTFS}                           @${URL_BASE}/zynq--interface-tests-rootfs.ext2-s_16777216-191638e3b3832a81bebd21d555f67bf3a4d7882a
29${UBOOT}                                        @${URL_BASE}/xilinx_zynqmp_r5--u-boot.elf-s_2227172-4d77b9622e19b3dcf205efffde87321422b5294c
30
31*** Keywords ***
32Create Linux Machine
33    Execute Command                 include @scripts/single-node/zynqmp_linux.resc
34    Execute Command                 machine SetSerialExecution True
35    ${linux_tester}=                Create Terminal Tester          ${LINUX_UART}  defaultPauseEmulation=true
36
37Create Linux Remoteproc Machine
38    Execute Command                 include @scripts/single-node/zynqmp_remoteproc.resc
39    Execute Command                 machine SetSerialExecution True
40    ${linux_tester}=                Create Terminal Tester          ${LINUX_UART}  defaultPauseEmulation=true
41    ${zephyr_tester}=               Create Terminal Tester          ${ZEPHYR_UART}  defaultPauseEmulation=true
42    RETURN                          ${linux_tester}  ${zephyr_tester}
43
44Create Linux OpenAMP Machine
45    Execute Command                 include @scripts/single-node/zynqmp_openamp.resc
46    Execute Command                 machine SetSerialExecution True
47    ${linux_tester}=                Create Terminal Tester         ${LINUX_UART}    defaultPauseEmulation=true
48    ${openamp_tester}=              Create Terminal Tester         ${OPENAMP_UART}  defaultPauseEmulation=true
49    RETURN                          ${linux_tester}  ${openamp_tester}
50
51Create Linux Docker Machine
52    Execute Command                 include @scripts/single-node/zynqmp_docker.resc
53    ${linux_tester}=                Create Terminal Tester          ${LINUX_UART}  defaultPauseEmulation=true
54
55Create Linux 32-Bit Userspace Machine
56    Execute Command                 $rootfs=${LINUX_32BIT_ROOTFS}
57    Create Linux Machine
58
59Create Zephyr Machine
60    [Arguments]                     ${elf}  ${uart}=${ZEPHYR_UART}
61    Execute Command                 set bin ${elf}
62    Execute Command                 include @scripts/single-node/zynqmp_zephyr.resc
63    Execute Command                 machine SetSerialExecution True
64    ${zephyr_tester}=               Create Terminal Tester          ${uart}  defaultPauseEmulation=true
65
66Boot U-Boot And Launch Linux
67    Wait For Line On Uart           U-Boot 2023.01
68    Wait For Line On Uart           Starting kernel ...
69
70Boot Linux And Login
71    [Arguments]                     ${testerId}=0
72    # Verify that the GIC system register interface is not enabled
73    # Wait for a message that gets logged early in boot, before any CPU features are printed
74    Wait For Line On Uart           Booting Linux on physical CPU           testerId=${testerId}
75    # Then run for a while looking for `CPU features: detected: GIC system register CPU interface`
76    Should Not Be On Uart           GIC system register CPU interface       testerId=${testerId}  timeout=2
77    # By waiting for the messages that follow all CPU feature printing with `timeout=0` we ensure
78    # that the previous "Should Not Be On Uart" covered the printing of all of the CPU features
79    # (all prints occurred before we finished waiting for completion of `Should Not Be On Uart`).
80    # This also verifies SMP support.
81    Wait For Line On Uart           SMP: Total of 4 processors activated    testerId=${testerId}  timeout=0
82    Wait For Line On Uart           CPU: All CPU(s) started at EL2          testerId=${testerId}  timeout=0
83    Wait For Prompt On Uart         buildroot login:                        testerId=${testerId}  timeout=50
84    Write Line To Uart              root                                    testerId=${testerId}
85    Wait For Prompt On Uart         ${LINUX_PROMPT}                         testerId=${testerId}
86
87Check Exit Code
88    [Arguments]                     ${testerId}=0
89    Write Line To Uart              echo $?                                 testerId=${testerId}
90    Wait For Line On Uart           0                                       testerId=${testerId}
91    Wait For Prompt On Uart         ${LINUX_PROMPT}                         testerId=${testerId}
92
93Execute Linux Command
94    [Arguments]                     ${command}  ${testerId}=0  ${timeout}=5
95    Write Line To Uart              ${command}                              testerId=${testerId}
96    Wait For Prompt On Uart         ${LINUX_PROMPT}                         testerId=${testerId}  timeout=${timeout}
97    Check Exit Code                 testerId=${testerId}
98
99Execute Linux Command Non Blocking
100    [Arguments]                     ${command}  ${testerId}=0
101    Write Line To Uart              ${command}                              testerId=${testerId}
102
103Should Pass Zephyr Test Suite
104    [Arguments]                     ${testerId}=0
105    Wait For Line On Uart           SUITE PASS - 100.00%                    testerId=${testerId}  timeout=40
106
107*** Test Cases ***
108Should Boot And Login
109    Create Linux Machine
110
111    Boot U-Boot And Launch Linux
112    Boot Linux And Login
113
114    # Check if we see the other CPUs
115    Write Line To Uart              nproc
116    Wait For Line On Uart           4
117
118Should Detect I2C Peripherals
119    Create Linux Machine
120
121    Execute Command                 machine LoadPlatformDescriptionFromString "i2cEcho: Mocks.EchoI2CDevice @ i2c1 ${I2C_ECHO_ADDRESS}"
122
123    Boot U-Boot And Launch Linux
124    Boot Linux And Login
125
126    # Suppress messages from the kernel space
127    Execute Linux Command           echo 0 > /proc/sys/kernel/printk
128
129    Write Line To Uart              i2cdetect -yar 1
130    Wait For Line On Uart           10: 10 --
131    Wait For Prompt On Uart         ${LINUX_PROMPT}
132    Check Exit Code
133
134Should Communicate With I2C Echo Peripheral
135    Create Linux Machine
136
137    Execute Command                 machine LoadPlatformDescriptionFromString "i2cEcho: Mocks.EchoI2CDevice @ i2c1 ${I2C_ECHO_ADDRESS}"
138
139    Boot U-Boot And Launch Linux
140    Boot Linux And Login
141
142    # Suppress messages from the kernel space
143    Execute Linux Command           echo 0 > /proc/sys/kernel/printk
144
145    Write Line To Uart              i2ctransfer -ya 1 w3@${I2C_ECHO_ADDRESS} 0x01 0x23 0x45 r2
146    Wait For Line On Uart           0x01 0x23
147    Wait For Prompt On Uart         ${LINUX_PROMPT}
148    Check Exit Code
149
150Should Communicate With I2C Echo Peripheral From 32-Bit Userspace On 64-Bit Kernel
151    Create Linux 32-Bit Userspace Machine
152
153    Execute Command                 machine LoadPlatformDescriptionFromString "i2cEcho: Mocks.EchoI2CDevice @ i2c1 ${I2C_ECHO_ADDRESS}"
154
155    Boot U-Boot And Launch Linux
156    Boot Linux And Login
157
158    # Suppress messages from the kernel space
159    Execute Linux Command           echo 0 > /proc/sys/kernel/printk
160
161    Write Line To Uart              i2ctransfer -ya 1 w3@${I2C_ECHO_ADDRESS} 0x01 0x23 0x45 r2
162    Wait For Line On Uart           0x01 0x23
163    Wait For Prompt On Uart         ${LINUX_PROMPT}
164    Check Exit Code
165
166    # Assert that the kernel is 64-bit
167    Execute Linux Command           [ $(uname -m) = aarch64 ]
168
169    # Assert that some binaries are 32-bit (ehdr.e_machine == EM_ARM, or 0x28)
170    Execute Linux Command           [ $(dd if=/bin/busybox bs=1 skip=18 count=2 | xxd -p) = 2800 ]
171    Execute Linux Command           [ $(dd if=/usr/bin/v4l2-compliance bs=1 skip=18 count=2 | xxd -p) = 2800 ]
172    Execute Linux Command           [ $(dd if=/usr/sbin/i2ctransfer bs=1 skip=18 count=2 | xxd -p) = 2800 ]
173
174Should Support RTC
175    Create Linux Machine
176
177    Boot U-Boot And Launch Linux
178    Boot Linux And Login
179
180    # Suppress messages from the kernel space
181    Execute Linux Command           echo 0 > /proc/sys/kernel/printk
182
183    Write Line To Uart              date; hwclock
184    ${d}=                           Wait For Line On Uart  Thu Jan${SPACE*2}1 00:00:(\\d+) UTC 1970  treatAsRegex=true
185    ${h}=                           Wait For Line On Uart  Thu Jan${SPACE*2}1 00:00:(\\d+) 1970${SPACE*2}0.000000 seconds  treatAsRegex=true
186
187    # Allow for 1 second of difference between the hwclock and the kernel's view
188    ${diff}=                        Evaluate  abs(int(${d.groups[0]}) - int(${h.groups[0]}))
189    Should Be True                  ${diff} <= 1
190
191Should Display Output on GPIO
192    Create Linux Machine
193
194    Execute Command                 machine LoadPlatformDescriptionFromString "gpio: { 7 -> heartbeat@0 }; heartbeat: Miscellaneous.LED @ gpio 7"
195    Create LED Tester               sysbus.gpio.heartbeat  defaultTimeout=2
196
197    Boot U-Boot And Launch Linux
198    Boot Linux And Login
199
200    # Suppress messages from the kernel space
201    Execute Linux Command           echo 0 > /proc/sys/kernel/printk
202
203    Write Line To Uart              echo none > /sys/class/leds/heartbeat/trigger
204    Write Line To Uart              echo 1 > /sys/class/leds/heartbeat/brightness
205    Assert LED State                true
206    Write Line To Uart              echo 0 > /sys/class/leds/heartbeat/brightness
207    Assert LED State                false
208
209Should Boot Zephyr
210    Create Zephyr Machine           ${ZEPHYR_HELLO_WORLD}
211
212    Wait For Line On Uart           *** Booting Zephyr OS build${SPACE*2}***
213
214Should Print Hello World
215    Create Zephyr Machine           ${ZEPHYR_HELLO_WORLD}
216
217    Wait For Line On Uart           Hello World! qemu_cortex_r5
218
219Should Decompress Lorem Ipsum
220    Create Zephyr Machine           ${ZEPHYR_COMPRESSION_LZ4}
221
222    Wait For Line On Uart           Original Data size: 1160
223    Wait For Line On Uart           Compressed Data size : 895
224    Wait For Line On Uart           Successfully decompressed some data
225    Wait For Line On Uart           Validation done. The string we ended up with is:
226    Wait For Line On Uart           Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque sodales lorem lorem, sed congue enim vehicula a. Sed finibus diam sed odio ultrices pharetra. Nullam dictum arcu ultricies turpis congue,vel venenatis turpis venenatis. Nam tempus arcu eros, ac congue libero tristique congue. Proin velit lectus, euismod sit amet quam in, maximus condimentum urna. Cras vel erat luctus, mattis orci ut, varius urna. Nam eu lobortis velit.
227    Wait For Line On Uart           Nullam sit amet diam vel odio sodales cursus vehicula eu arcu. Proin fringilla, enim nec consectetur mollis, lorem orci interdum nisi, vitae suscipit nisi mauris eu mi. Proin diam enim, mollis ac rhoncus vitae, placerat et eros. Suspendisse convallis, ipsum nec rhoncus aliquam, ex augue ultrices nisl, id aliquet mi diam quis ante. Pellentesque venenatis ornare ultrices. Quisque et porttitor lectus. Ut venenatis nunc et urna imperdiet porttitor non laoreet massa.Donec eleifend eros in mi sagittis egestas. Sed et mi nunc. Nunc vulputate,mauris non ullamcorper viverra, lorem nulla vulputate diam, et congue dui velit non erat. Duis interdum leo et ipsum tempor consequat. In faucibus enim quis purus vulputate nullam.
228
229Should Run System Heap Sample
230    Create Zephyr Machine           ${ZEPHYR_BASIC_SYS_HEAP}
231
232    Wait For Line On Uart           System heap sample
233    Wait For Line On Uart           allocated 0, free 196, max allocated 0, heap size 256
234    Wait For Line On Uart           allocated 156, free 36, max allocated 156, heap size 256
235    Wait For Line On Uart           allocated 100, free 92, max allocated 156, heap size 256
236    Wait For Line On Uart           allocated 0, free 196, max allocated 156, heap size 256
237
238Should Complete MetaIRQ Test
239    Create Zephyr Machine           ${ZEPHYR_KERNEL_METAIRQ_DISPATCH}
240
241    Wait For Line On Uart           I: Starting Thread0 at priority -2
242    Wait For Line On Uart           I: Starting Thread1 at priority -1
243    Wait For Line On Uart           I: Starting Thread2 at priority 0
244    Wait For Line On Uart           I: Starting Thread3 at priority 1
245
246    Wait For Line On Uart           I: M0 T[0-3] mirq \\d+ disp \\d+ proc \\d+ real \\d+            treatAsRegex=true
247    Wait For Line On Uart           I: M7 T[0-3] mirq \\d+ disp \\d+ proc \\d+ real \\d+            treatAsRegex=true
248    Wait For Line On Uart           I: M15 T[0-3] mirq \\d+ disp \\d+ proc \\d+ real \\d+           treatAsRegex=true
249
250    Wait For Line On Uart           I:${SPACE*9}---------- Latency (cyc) ----------
251    Wait For Line On Uart           I:${SPACE*13}Best${SPACE*4}Worst${SPACE*5}Mean${SPACE*4}Stdev
252    Wait For Line On Uart           I: MetaIRQ +\\d+ +\\d+ +\\d+ +\\d+                              treatAsRegex=true
253    Wait For Line On Uart           I: Thread0 +\\d+ +\\d+ +\\d+ +\\d+                              treatAsRegex=true
254    Wait For Line On Uart           I: Thread1 +\\d+ +\\d+ +\\d+ +\\d+                              treatAsRegex=true
255    Wait For Line On Uart           I: Thread2 +\\d+ +\\d+ +\\d+ +\\d+                              treatAsRegex=true
256    Wait For Line On Uart           I: Thread3 +\\d+ +\\d+ +\\d+ +\\d+                              treatAsRegex=true
257    Wait For Line On Uart           I: MetaIRQ Test Complete
258
259Should Interleave Main And Cooperative Thread
260    Create Zephyr Machine           ${ZEPHYR_CPP_SYNCHRONIZATION}
261
262    Wait For Line On Uart           Create semaphore 0x[a-f0-9]+                                    treatAsRegex=true
263    Wait For Line On Uart           Create semaphore 0x[a-f0-9]+                                    treatAsRegex=true
264    Wait For Line On Uart           main: Hello World!
265    Wait For Line On Uart           coop_thread_entry: Hello World!
266    Wait For Line On Uart           main: Hello World!
267    Wait For Line On Uart           coop_thread_entry: Hello World!
268    Wait For Line On Uart           main: Hello World!
269    Wait For Line On Uart           coop_thread_entry: Hello World!
270    Wait For Line On Uart           main: Hello World!
271    Wait For Line On Uart           coop_thread_entry: Hello World!
272    Wait For Line On Uart           main: Hello World!
273    Wait For Line On Uart           coop_thread_entry: Hello World!
274
275Should Interleave Concurrent Threads
276    Create Zephyr Machine           ${ZEPHYR_SYNCHRONIZATION}
277
278    Wait For Line On Uart           thread_a: Hello World from cpu 0 on qemu_cortex_r5!
279    Wait For Line On Uart           thread_b: Hello World from cpu 0 on qemu_cortex_r5!
280    Wait For Line On Uart           thread_a: Hello World from cpu 0 on qemu_cortex_r5!
281    Wait For Line On Uart           thread_b: Hello World from cpu 0 on qemu_cortex_r5!
282    Wait For Line On Uart           thread_a: Hello World from cpu 0 on qemu_cortex_r5!
283    Wait For Line On Uart           thread_b: Hello World from cpu 0 on qemu_cortex_r5!
284    Wait For Line On Uart           thread_a: Hello World from cpu 0 on qemu_cortex_r5!
285    Wait For Line On Uart           thread_b: Hello World from cpu 0 on qemu_cortex_r5!
286    Wait For Line On Uart           thread_a: Hello World from cpu 0 on qemu_cortex_r5!
287    Wait For Line On Uart           thread_b: Hello World from cpu 0 on qemu_cortex_r5!
288
289Should Run Kernel Condition Variables Condvar Sample
290    Create Zephyr Machine           ${ZEPHYR_KERNEL_CONDITION_VARIABLES_CONDVAR}
291
292    Wait For Line On Uart           Starting watch_count: thread 1
293    Wait For Line On Uart           watch_count: thread 1 Count= 0. Going into wait...
294    Wait For Line On Uart           inc_count: thread 2, count = 1, unlocking mutex
295    Wait For Line On Uart           inc_count: thread 3, count = 2, unlocking mutex
296    Wait For Line On Uart           inc_count: thread 2, count = 3, unlocking mutex
297    Wait For Line On Uart           inc_count: thread 3, count = 4, unlocking mutex
298    Wait For Line On Uart           inc_count: thread 2, count = 5, unlocking mutex
299    Wait For Line On Uart           inc_count: thread 3, count = 6, unlocking mutex
300    Wait For Line On Uart           inc_count: thread 2, count = 7, unlocking mutex
301    Wait For Line On Uart           inc_count: thread 3, count = 8, unlocking mutex
302    Wait For Line On Uart           inc_count: thread 2, count = 9, unlocking mutex
303    Wait For Line On Uart           inc_count: thread 3, count = 10, unlocking mutex
304    Wait For Line On Uart           inc_count: thread 2, count = 11, unlocking mutex
305    Wait For Line On Uart           inc_count: thread 3, count = 12${SPACE*2}Threshold reached.Just sent signal.
306    Wait For Line On Uart           inc_count: thread 3, count = 12, unlocking mutex
307    Wait For Line On Uart           watch_count: thread 1 Condition signal received. Count= 12
308    Wait For Line On Uart           watch_count: thread 1 Updating the value of count...
309    Wait For Line On Uart           watch_count: thread 1 count now = 137.
310    Wait For Line On Uart           watch_count: thread 1 Unlocking mutex.
311    Wait For Line On Uart           inc_count: thread 2, count = 138, unlocking mutex
312    Wait For Line On Uart           inc_count: thread 3, count = 139, unlocking mutex
313    Wait For Line On Uart           inc_count: thread 2, count = 140, unlocking mutex
314    Wait For Line On Uart           inc_count: thread 3, count = 141, unlocking mutex
315    Wait For Line On Uart           inc_count: thread 2, count = 142, unlocking mutex
316    Wait For Line On Uart           inc_count: thread 3, count = 143, unlocking mutex
317    Wait For Line On Uart           inc_count: thread 2, count = 144, unlocking mutex
318    Wait For Line On Uart           inc_count: thread 3, count = 145, unlocking mutex
319    Wait For Line On Uart           Main(): Waited and joined with 3 threads. Final value of count = 145. Done.
320
321Should Run Kernel Condition Variables Simple Sample
322    Create Zephyr Machine           ${ZEPHYR_KERNEL_CONDITION_VARIABLES_SIMPLE}
323
324    FOR  ${i}  IN RANGE  0  1
325        FOR  ${t}  IN RANGE  0  19
326            Wait For Line On Uart   [thread ${t}] working (${i}/5)
327        END
328    END
329
330    Wait For Line On Uart           [thread main] done is 0 which is < 20 so waiting on cond
331
332    FOR  ${i}  IN RANGE  2  4
333        FOR  ${t}  IN RANGE  0  19
334            Wait For Line On Uart   [thread ${t}] working (${i}/5)
335        END
336    END
337
338    FOR  ${t}  IN RANGE  0  18
339        Wait For Line On Uart       [thread ${t}] done is now ${t + 1}. Signalling cond.
340        Wait For Line On Uart       [thread main] wake - cond was signalled.
341        Wait For Line On Uart       [thread main] done is ${t + 1} which is < 20 so waiting on cond
342    END
343    Wait For Line On Uart           [thread 19] done is now 20. Signalling cond.
344    Wait For Line On Uart           [thread main] wake - cond was signalled.
345    Wait For Line On Uart           [thread main] done == 20 so everyone is done
346
347Should Run Philosophers Sample
348    Create Zephyr Machine           ${ZEPHYR_PHILOSOPHERS}
349
350    FOR  ${p}  IN RANGE  0  5
351            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE*7}STARVING${SPACE*7}                                    treatAsRegex=true
352            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE*3}HOLDING ONE FORK${SPACE*3}                            treatAsRegex=true
353            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE*2}EATING${SPACE*2}\\[ ${SPACE}?\\d{1,3} ms \\]${SPACE}  treatAsRegex=true
354            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE*3}DROPPED ONE FORK${SPACE*3}                            treatAsRegex=true
355            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE}THINKING \\[ ${SPACE}?\\d{1,3} ms \\]${SPACE}           treatAsRegex=true
356    END
357
358Should Interact Via Shell
359    Create Zephyr Machine           ${ZEPHYR_SHELL}
360
361    Wait For Prompt On Uart         ${ZEPHYR_PROMPT}
362    Write Line To Uart              version
363    Wait For Line On Uart           Zephyr version \\d+.\\d+.\\d+                                   treatAsRegex=true
364
365    Wait For Prompt On Uart         ${ZEPHYR_PROMPT}
366    Write Line To Uart              device list
367    Wait For Line On Uart           devices:
368    Wait For Line On Uart           - uart@ff000000 (READY)
369
370    Wait For Prompt On Uart         ${ZEPHYR_PROMPT}
371    Write Line To Uart              demo ping
372    Wait For Line On Uart           pong
373
374    Wait For Prompt On Uart         ${ZEPHYR_PROMPT}
375    Write Line To Uart              history
376    Wait For Line On Uart           [${SPACE*2}0] history
377    Wait For Line On Uart           [${SPACE*2}1] demo ping
378    Wait For Line On Uart           [${SPACE*2}2] device list
379    Wait For Line On Uart           [${SPACE*2}3] version
380
381    Wait For Prompt On Uart         ${ZEPHYR_PROMPT}
382    Write Line To Uart              log_test start demo
383    FOR  ${i}  IN RANGE  0  7
384        Wait For Line On Uart           <inf> app: Timer expired.          treatAsRegex=true
385        Wait For Line On Uart           <inf> app_test: info message       treatAsRegex=true
386        Wait For Line On Uart           <wrn> app_test: warning message    treatAsRegex=true
387        Wait For Line On Uart           <err> app_test: err message        treatAsRegex=true
388    END
389    Write Line To Uart              log_test stop
390
391    Wait For Prompt On Uart         ${ZEPHYR_PROMPT}
392    Write Line To Uart              date get
393    Wait For Line On Uart           1970-01-01 \\d{2}:\\d{2}:\\d{2} UTC                             treatAsRegex=true
394    Write Line To Uart              date set 2023-12-31 12:00:59
395    Write Line To Uart              date get
396    Wait For Line On Uart           2023-12-31 12:\\d{2}:\\d{2} UTC                                 treatAsRegex=true
397
398Should Fail To Enter Userspace Without MPU
399    Create Zephyr Machine           ${ZEPHYR_USERSPACE_HELLO_WORLD_NO_MPU}
400
401    Wait For Line On Uart           Hello World from privileged mode. (qemu_cortex_r5)
402    Wait For Line On Uart           ASSERTION FAIL [k_is_user_context()]
403    Wait For Line On Uart           User mode execution was expected
404    Wait For Line On Uart           E: >>> ZEPHYR FATAL ERROR 4: Kernel panic on CPU 0
405    Wait For Line On Uart           E: Halting system
406
407Should Print Hello World From Userspace
408    Create Zephyr Machine           ${ZEPHYR_USERSPACE_HELLO_WORLD}
409
410    Wait For Line On Uart           Hello World from UserSpace! (qemu_cortex_r5)
411
412Should Pass Zephyr FPU Sharing Test
413    Create Zephyr Machine           ${ZEPHYR_TESTS_KERNEL_FPU_SHARING}
414
415    Should Pass Zephyr Test Suite
416
417Should Rise Permission Fault On MPU Test Read
418    Create Zephyr Machine           ${ZEPHYR_MPU_TEST}
419
420    Wait For Prompt On Uart         ${ZEPHYR_PROMPT}
421    Write Line To Uart              mpu write
422    Wait For Line On Uart           write address: 0xc0004000
423
424    Wait For Line On Uart           <err> os: ***** DATA ABORT *****
425    Wait For Line On Uart           <err> os: Permission Fault @ 0xc0004000
426    Wait For Line On Uart           <err> os: r0/a1:${SPACE*2}0x00000000${SPACE*2}r1/a2:${SPACE*2}0x0000000e${SPACE*2}r2/a3:${SPACE*2}0x00010538
427    Wait For Line On Uart           <err> os: r3/a4:${SPACE*2}0x0badc0de r12/ip:${SPACE*2}0x[a-f0-9]+ r14/lr:${SPACE*2}0x00000f8f                  treatAsRegex=true
428    Wait For Line On Uart           <err> os:${SPACE*2}xpsr:${SPACE*2}0x6000013f
429    Wait For Line On Uart           <err> os: fpscr:${SPACE*2}0x00000000
430    Wait For Line On Uart           <err> os: Faulting instruction address (r15/pc): 0x00000f90
431    Wait For Line On Uart           <err> os: >>> ZEPHYR FATAL ERROR 48: Unknown error on CPU 0
432    Wait For Line On Uart           <err> os: Current thread: 0x10538 (shell_uart)
433    Wait For Line On Uart           <err> os: Halting system
434
435Should Rise Background Fault On MPU Test Write
436    Create Zephyr Machine           ${ZEPHYR_MPU_TEST}
437
438    Wait For Prompt On Uart         ${ZEPHYR_PROMPT}
439    Write Line To Uart              mpu read
440    Wait For Line On Uart           <err> os: ***** DATA ABORT *****
441    Wait For Line On Uart           <err> os: Background Fault @ 0x04000000
442    Wait For Line On Uart           <err> os: r0/a1:${SPACE*2}0x0000a3bc${SPACE*2}r1/a2:${SPACE*2}0x00000008${SPACE*2}r2/a3:${SPACE*2}0x0000ace5
443    Wait For Line On Uart           <err> os: r3/a4:${SPACE*2}0x04000000 r12/ip:${SPACE*2}0x[a-f0-9]+ r14/lr:${SPACE*2}0x0000371b                 treatAsRegex=true
444    Wait For Line On Uart           <err> os:${SPACE*2}xpsr:${SPACE*2}0x2000013f
445    Wait For Line On Uart           <err> os: fpscr:${SPACE*2}0x00000000
446    Wait For Line On Uart           <err> os: Faulting instruction address (r15/pc): 0x00000fae
447    Wait For Line On Uart           <err> os: >>> ZEPHYR FATAL ERROR 47: Unknown error on CPU 0
448    Wait For Line On Uart           <err> os: Current thread: 0x10538 (shell_uart)
449    Wait For Line On Uart           <err> os: Halting system
450
451Should Successfully Run Producer Consumer Sample In Userspace
452    Create Zephyr Machine           ${ZEPHYR_USERSPACE_PROD_CONSUMER}
453
454    Wait For Line On Uart           I: SUCCESS
455
456Should Pass Messages Between Threads
457    Create Zephyr Machine           ${ZEPHYR_USERSPACE_SHARED_MEM}
458
459    Wait For Line On Uart           ENC Thread Created 0x104e0
460    Wait For Line On Uart           Partitions added to enc_domain
461    Wait For Line On Uart           enc_domain Created
462    Wait For Line On Uart           PT Thread Created 0x103e0
463    Wait For Line On Uart           pt_domain Created
464    Wait For Line On Uart           CT Thread Created 0x102e0
465    Wait For Line On Uart           ct partitions installed
466    Wait For Line On Uart           blk partitions installed
467    Wait For Line On Uart           ENC thread started
468    Wait For Line On Uart           PT thread started
469
470    FOR  ${i}  IN RANGE  0  3
471        Wait For Line On Uart           PT Sending Message 1
472        Wait For Line On Uart           ENC Thread Received Data
473        Wait For Line On Uart           ENC PT MSG: PT: message to encrypt
474
475        Wait For Line On Uart           CT Thread Received Message
476        Wait For Line On Uart           CT MSG: ofttbhfspgmeqzos
477
478        Wait For Line On Uart           PT Sending Message 1'
479        Wait For Line On Uart           ENC Thread Received Data
480        Wait For Line On Uart           ENC PT MSG: ofttbhfspgmeqzos
481
482        Wait For Line On Uart           CT Thread Received Message
483        Wait For Line On Uart           CT MSG: messagetoencrypt
484    END
485
486    Provides                        userspace_shared_mem-zephyr
487
488Should Pass Messages Between Threads From Serialized State
489    Requires                        userspace_shared_mem-zephyr
490    Clear Terminal Tester Report
491
492    Wait For Line On Uart           PT Sending Message 1
493    Wait For Line On Uart           ENC Thread Received Data
494    Wait For Line On Uart           ENC PT MSG: PT: message to encrypt
495
496    Wait For Line On Uart           CT Thread Received Message
497    Wait For Line On Uart           CT MSG: ofttbhfspgmeqzos
498
499    Wait For Line On Uart           PT Sending Message 1'
500    Wait For Line On Uart           ENC Thread Received Data
501    Wait For Line On Uart           ENC PT MSG: ofttbhfspgmeqzos
502
503    Wait For Line On Uart           CT Thread Received Message
504    Wait For Line On Uart           CT MSG: messagetoencrypt
505
506Should Provide Booted U-Boot And Run Version Command
507    Create Zephyr Machine           ${UBOOT}  ${UBOOT_UART}
508
509    Wait For Prompt On Uart         ${UBOOT_PROMPT}
510
511    Provides                        booted-uboot
512
513    Write Line To Uart              version
514    Wait For Line On Uart           U-Boot
515
516    Wait For Prompt On Uart         ${UBOOT_PROMPT}
517
518Should Run Version Command On Provided U-Boot
519    Requires                        booted-uboot
520
521    Write Line To Uart              version
522    Wait For Line On Uart           U-Boot
523
524    Wait For Prompt On Uart         ${UBOOT_PROMPT}
525
526Should Start And Stop Remoteproc
527    ${linux_tester}  ${zephyr_tester}=  Create Linux Remoteproc Machine
528    Boot Linux And Login                testerId=${linux_tester}
529
530    # Load remoteproc kernel module and start demo
531    Execute Linux Command               modprobe zynqmp_r5_remoteproc                                       testerId=${linux_tester}
532    Execute Linux Command               mkdir /lib/firmware                                                 testerId=${linux_tester}
533    Execute Linux Command               cp /elfs/philosophers.elf /lib/firmware                             testerId=${linux_tester}
534    Execute Linux Command               echo philosophers.elf > /sys/class/remoteproc/remoteproc0/firmware  testerId=${linux_tester}
535    Execute Linux Command               echo start > /sys/class/remoteproc/remoteproc0/state                testerId=${linux_tester}
536
537    # Check if demo works correctly
538    FOR  ${p}  IN RANGE  0  5
539            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE*7}STARVING${SPACE*7}                                    testerId=${zephyr_tester}  treatAsRegex=true
540            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE*3}HOLDING ONE FORK${SPACE*3}                            testerId=${zephyr_tester}  treatAsRegex=true
541            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE*2}EATING${SPACE*2}\\[ ${SPACE}?\\d{1,3} ms \\]${SPACE}  testerId=${zephyr_tester}  treatAsRegex=true
542            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE*3}DROPPED ONE FORK${SPACE*3}                            testerId=${zephyr_tester}  treatAsRegex=true
543            Wait For Line On Uart   Philosopher ${p} \\[[PC]:[ -]\\d\\] ${SPACE}THINKING \\[ ${SPACE}?\\d{1,3} ms \\]${SPACE}           testerId=${zephyr_tester}  treatAsRegex=true
544    END
545
546    # Stop demo
547    Execute Linux Command               echo stop > /sys/class/remoteproc/remoteproc0/state                 testerId=${linux_tester}
548    Sleep                               1s
549    ${is_halted}=  Execute Command      rpu0 IsHalted
550    Should Contain                      ${is_halted}    True
551
552Should Run OpenAMP Echo Sample
553    ${linux_tester}  ${openamp_tester}=     Create Linux OpenAMP Machine
554    Boot Linux And Login                    testerId=${linux_tester}
555
556    # Load remoteproc kernel module and start demo
557    Execute Linux Command                   modprobe zynqmp_r5_remoteproc                                       testerId=${linux_tester}
558    Execute Linux Command                   echo rpmsg-echo.out > /sys/class/remoteproc/remoteproc0/firmware    testerId=${linux_tester}
559    Execute Linux Command                   echo start > /sys/class/remoteproc/remoteproc0/state                testerId=${linux_tester}
560    Execute Linux Command Non Blocking      ./echo_test                                                         testerId=${linux_tester}
561
562    # Check if demo works correctly
563    Wait For Line On Uart                   Echo Test Round 0                                                   testerId=${linux_tester}
564    FOR  ${i}  IN RANGE  0  471
565            Wait For Line On Uart           sending payload number ${i} of size ${i + 17}                       testerId=${linux_tester}
566            Wait For Line On Uart           echo test: sent : ${i + 17}                                         testerId=${linux_tester}
567            Wait For Line On Uart           received payload number ${i} of size ${i + 17}                      testerId=${linux_tester}
568    END
569    Wait For Line On Uart                   Echo Test Round 0 Test Results: Error count = 0                     testerId=${linux_tester}
570
571Should Run Web Server In Docker
572    Create Linux Docker Machine
573    Boot Linux And Login
574
575    # The Docker daemon is not ready to accept connections as soon as the
576    # init script finishes; give it a while to warm up.
577    Execute Linux Command                   until docker ps; do sleep 1; done                                   timeout=10
578    Execute Linux Command                   docker load < /docker/webserver.tar
579    Execute Linux Command                   docker run --name webserver -d -p 80:80 localhost/webserver
580
581    Execute Linux Command Non Blocking      wget -O - http://localhost
582    Wait For Line On Uart                   <html><body><h1>Hello, world!</h1></body></html>
583
584    Execute Linux Command Non Blocking      docker logs webserver
585    Wait For Line On Uart                   response:200
586