1*** Variables ***
2${URI}                                   @https://dl.antmicro.com/projects/renode
3${PROMPT}                                zynq>
4${SCRIPT}                                ${CURDIR}/../../../scripts/single-node/zynq_verilated_fastvdma.resc
5${UART}                                  sysbus.uart1
6${FASTVDMA_DRIVER}                       /lib/modules/5.10.0-xilinx/kernel/drivers/dma/fastvdma/fastvdma.ko
7${FASTVDMA_DEMO_DRIVER}                  /lib/modules/5.10.0-xilinx/kernel/drivers/dma/fastvdma/fastvdma-demo.ko
8${FASTVDMA_NATIVE_LINUX}                 ${URI}/libVfastvdma-Linux-x86_64-12904733885.so-s_2104432-8ec57bdee00c76a044024158525d4130af0afc1a
9${FASTVDMA_NATIVE_WINDOWS}               ${URI}/libVfastvdma-Windows-x86_64-12904733885.dll-s_3265828-0e1691527cfb633cf5d8865f3445529708e73f8f
10${FASTVDMA_NATIVE_MACOS}                 ${URI}/libVfastvdma-macOS-x86_64-12904733885.dylib-s_239144-ebd397eb4d74c08be26cec08c022e90b78f0e020
11
12*** Keywords ***
13Create Machine
14    Execute Command                      \$dmaLinux?=${FASTVDMA_NATIVE_LINUX}
15    Execute Command                      \$dmaWindows?=${FASTVDMA_NATIVE_WINDOWS}
16    Execute Command                      \$dmaMacOS?=${FASTVDMA_NATIVE_MACOS}
17    Execute Script                       ${SCRIPT}
18    Create Terminal Tester               ${UART}
19
20Compare Parts Of Images
21    [Arguments]                          ${img0}    ${img1}    ${count}    ${skip0}    ${skip1}
22
23    Write Line To Uart                   dd if=${img0} of=test.rgba bs=128 count=${count} skip=${skip0}
24    Wait For Prompt On Uart              ${PROMPT}
25    Write Line To Uart                   dd if=${img1} of=otest.rgba bs=128 count=${count} skip=${skip1}
26    Wait For Prompt On Uart              ${PROMPT}
27
28    Write Line To Uart                   cmp test.rgba otest.rgba
29    Wait For Prompt On Uart              ${PROMPT}
30
31# Check if exit status is 0 (the input files are the same)
32    Write Line To Uart                   echo $?
33    Wait For Line On Uart                0
34    Wait For Prompt On Uart              ${PROMPT}
35
36*** Test Cases ***
37Should Boot Linux
38    [Documentation]                      Boots Linux on the Zynq 7000-based Zedboard platform in co-simulation with FastVDMA.
39    [Tags]                          skip_host_arm
40
41    Create Machine
42    Start Emulation
43    Wait For Prompt On Uart              ${PROMPT}  timeout=300
44
45    # Serialization on verilated platforms isn't working porperly at the moment. We use the old method instead
46    Provides                             booted-linux  Reexecution
47
48Should Load Drivers
49    [Documentation]                      Loads fastvdma.ko and fastvdma-demo.ko and performs image transfer via FastVDMA.
50    [Tags]                          skip_host_arm
51    Requires                             booted-linux
52
53# Suppress messages from kernel space; don't wait for echo because a kernel log might be printed in the middle of writing.
54    Write Line To Uart                   echo 0 > /proc/sys/kernel/printk  waitForEcho=false
55
56# Write Line To Uart for some reason breaks this line into two.
57    Write To Uart                        insmod ${FASTVDMA_DRIVER} ${\n}
58    Wait For Prompt On Uart              ${PROMPT}
59
60    Write To Uart                        insmod ${FASTVDMA_DEMO_DRIVER} ${\n}
61    Wait For Prompt On Uart              ${PROMPT}
62
63    Write Line To Uart                   lsmod
64    Wait For Line On Uart                Module
65    Wait For Line On Uart                fastvdma_demo
66    Wait For Line On Uart                fastvdma
67
68    Write Line To Uart                   ./demo
69    Wait For Prompt On Uart              ${PROMPT}
70
71    Write Line To Uart                   chmod +rw out.rgba
72    Wait For Prompt On Uart              ${PROMPT}
73
74    # Serialization on verilated platforms isn't working porperly at the moment. We use the old method instead
75    Provides                             output  Reexecution
76
77Verify Image
78    [Documentation]                      Verifies whether the image has been transferred correctly.
79    [Tags]                          skip_host_arm
80    Requires                             output
81
82# The output image (out.rgba) should consist of img1.rgba (256x256px) in the middle of img0.rgba (512x512px)
83# Verify if that's correct by comparing corresponding bytes.
84
85    Compare Parts Of Images              img0.rgba    out.rgba    2048    0    0
86
87    FOR    ${i}    IN RANGE    255
88        Compare Parts Of Images          img0.rgba    out.rgba    4    ${2048 + ${i} * 16}    ${2048 + ${i} * 16}
89        Compare Parts Of Images          img1.rgba    out.rgba    8    ${${i} * 8}    ${2052 + ${i} * 16}
90        Compare Parts Of Images          img0.rgba    out.rgba    4    ${2060 + ${i} * 16}    ${2060 + ${i} * 16}
91    END
92
93    Compare Parts Of Images              img0.rgba    out.rgba    2052    6140    6140
94