[#50762] VirtIO: Add VirtIOFSDevice, add VirtIO tests for Linux
diff --git a/src/Infrastructure b/src/Infrastructure index cf2dfa2..b391d50 160000 --- a/src/Infrastructure +++ b/src/Infrastructure
@@ -1 +1 @@ -Subproject commit cf2dfa24f38eec30a7e1257a72000234f9fc3234 +Subproject commit b391d5008643ed6faa92f02ec0d7a74772ec7e57
diff --git a/tests/peripherals/VirtIO.robot b/tests/peripherals/VirtIO.robot index b27f6b7..443b183 100644 --- a/tests/peripherals/VirtIO.robot +++ b/tests/peripherals/VirtIO.robot
@@ -1,28 +1,64 @@ +*** Settings *** +Suite Setup Custom Suite Setup +Suite Teardown Custom Suite Teardown +Library OperatingSystem + *** Variables *** ${UART} sysbus.uart0 ${DRIVE} https://dl.antmicro.com/projects/renode/empty-ext4-filesystem.img-s_33554432-1eb65a808612389cc35a69b81178fbad5708a863 -${SCRIPT} ${CURDIR}/../../scripts/single-node/hifive_unleashed.resc +${FS} https://dl.antmicro.com/projects/renode/virtio-filesystem-passthrough_hp_uds-s_7318728-f7b60ce9b60c82cede19e798e81971663e1c0ad2 +${SCRIPT_BLK} ${CURDIR}/../../scripts/single-node/hifive_unleashed.resc +${SCRIPT_FS} ${CURDIR}/../../tests/peripherals/virtio-litex.resc ${INPUT} Quick Brown Fox Jumps Over the Lazy Dog ${PROMPT} # +${SOCK_FILE} ${CURDIR}/fs.sock +${SHARED_FILE} testfile +${SHARED_DIR} shareddir +${VIRTIOFS_TAG} "tag0" +${SYSTEM}= Evaluate platform.system() modules=platform *** Keywords *** -Create Machine - Execute Command \$fdt?=@https://dl.antmicro.com/projects/renode/virtio-hifive_unleashed.dtb-s_10640-08834542504afb748827fdca52515f156e971d5f - Execute Script ${SCRIPT} - Execute Command machine LoadPlatformDescriptionFromString 'virtio: Storage.VirtIOBlockDevice @ sysbus 0x100d0000 { IRQ -> plic@50 }' +Custom Suite Setup + Setup -Prepare Drive - ${TEMP_DRIVE}= Download File ${DRIVE} - Set Suite Variable ${DRIVE_PATH} ${TEMP_DRIVE} + ${TEMP_DRIVE}= Download File ${DRIVE} + ${DIR} ${FILE_NAME}= Split Path ${TEMP_DRIVE} + Copy File ${TEMP_DRIVE} ${TEMPDIR} + Set Suite Variable ${DRIVE_PATH} ${TEMPDIR}${/}${FILE_NAME} + Set Suite Variable ${SOCK_PATH} ${SOCK_FILE} + ${TEMP_FS}= Download File ${FS} + ${DIR} ${FILE_NAME}= Split Path ${TEMP_FS} + Copy File ${TEMP_FS} ${TEMPDIR} + Set Suite Variable ${FS_PATH} ${TEMPDIR}${/}${FILE_NAME} + Run Process chmod +x ${FS_PATH} -Setup Machine +Custom Suite Teardown + Remove File ${DRIVE_PATH} + Remove File ${FS_PATH} + Teardown + +Create Machine VirtIOBlock + Execute Command $fdt=@https://dl.antmicro.com/projects/renode/virtio-hifive_unleashed.dtb-s_10640-08834542504afb748827fdca52515f156e971d5f + Execute Script ${SCRIPT_BLK} + Execute Command machine LoadPlatformDescriptionFromString 'virtioblk: Storage.VirtIOBlockDevice @ sysbus 0x100d0000 { IRQ -> plic@50 }' + +Create Machine VirtIOFS + Execute Command $platform=@tests/peripherals/virtio-platform.repl + Execute Command $img=@https://dl.antmicro.com/projects/renode/virtio-filesystem-image-s_8448188-414604e8f64c41ebdbffe0f9ae7525c20bb1b124 + Execute Command $dtb=@https://dl.antmicro.com/projects/renode/virtio-filesystem-rv32.dtb-s_1806-b2ad3ecaf517c6a6781d1cbb48eff6fca7972094 + Execute Command $osbi=@https://dl.antmicro.com/projects/renode/litex_vexriscv_smp--opensbi.bin-s_45360-dcfe5f7b149bd1e0232609d87fb698f95f5e33c4 + Execute Command $rootfs=@https://dl.antmicro.com/projects/renode/virtio-filesystem-rootfs.cpio-s_39962112-95a3591d189699f21b988b036a9843c882d8e42f + Execute Script ${SCRIPT_FS} + Execute Command machine LoadPlatformDescriptionFromString 'virtiofs: Storage.VirtIOFSDevice @ sysbus 0x100d0000 { IRQ -> plic@2 }' + Execute Command virtiofs Create @${SOCK_PATH} ${VIRTIOFS_TAG} + +Setup Machine VirtIOBlock Wait For Prompt On Uart buildroot login: Write Line To Uart root Wait For Prompt On Uart Password: Write Line To Uart root waitForEcho=false Wait For Prompt On Uart ${PROMPT} - - Execute Command virtio LoadImage @${DRIVE_PATH} true + Execute Command virtioblk LoadImage @${DRIVE_PATH} true Wait For Prompt On Uart ${PROMPT} Write Line To Uart dmesg -n 1 Wait For Prompt On Uart ${PROMPT} @@ -31,14 +67,47 @@ Write Line To Uart mount /dev/vda /mnt/drive Wait For Prompt On Uart ${PROMPT} +Setup Machine VirtIOFS + Wait For Prompt On Uart buildroot login: + Write Line To Uart root + Wait For Line On Uart root login on 'console' + Wait For Prompt On Uart ${PROMPT} + Write Line To Uart mkdir ${SHARED_DIR} + Wait For Prompt On Uart ${PROMPT} + Write Line To Uart mount -t virtiofs ${VIRTIOFS_TAG} ${SHARED_DIR} + Wait For Prompt On Uart ${PROMPT} + +Setup Shared Directory + Create Directory ${SHARED_DIR} + Create File ${SHARED_DIR}/${SHARED_FILE} ${INPUT} + *** Test Cases *** -Should Boot - Prepare Drive - Create Machine +Read Shared Directory + [Tags] skip_windows skip_osx + # Unix domain sockets + + Setup Shared Directory + ${FS_PROCESS}= Start Process ${FS_PATH} ${SHARED_DIR} --socket ${SOCK_PATH} + + Create Machine VirtIOFS Create Terminal Tester ${UART} Start Emulation - Setup Machine + Setup Machine VirtIOFS + Write Line To Uart ls -al ${SHARED_DIR} + Wait For Prompt On Uart ${PROMPT} + Write Line To Uart cat ${SHARED_DIR}/${SHARED_FILE} + Wait For Prompt On Uart ${INPUT} + Sleep 5s + Terminate Process ${FS_PROCESS} kill=true + Run Process rm ${SOCK_PATH} + +Should Boot + Create Machine VirtIOBlock + Create Terminal Tester ${UART} + Start Emulation + + Setup Machine VirtIOBlock Write Line To Uart echo ${INPUT} > /mnt/drive/file Wait For Prompt On Uart ${PROMPT} Write Line To Uart cat /mnt/drive/file @@ -53,11 +122,11 @@ Sleep 5s Should Be Persistent - Create Machine + Create Machine VirtIOBlock Create Terminal Tester ${UART} Start Emulation - Setup Machine + Setup Machine VirtIOBlock Write Line To Uart cat /mnt/drive/file Wait For Line On Uart ${INPUT} Wait For Prompt On Uart ${PROMPT}
diff --git a/tests/peripherals/virtio-litex.resc b/tests/peripherals/virtio-litex.resc new file mode 100644 index 0000000..f61d720 --- /dev/null +++ b/tests/peripherals/virtio-litex.resc
@@ -0,0 +1,15 @@ +using sysbus +mach create + +machine LoadPlatformDescription $platform + +showAnalyzer uart0 + +sysbus LoadBinary $img 0x40000000 +sysbus LoadBinary $dtb 0x40ef0000 +sysbus LoadBinary $osbi 0x40f00000 +sysbus LoadBinary $rootfs 0x42000000 + +cpu PC 0x40f00000 + +machine StartGdbServer 3333
diff --git a/tests/peripherals/virtio-platform.repl b/tests/peripherals/virtio-platform.repl new file mode 100644 index 0000000..dbfb6ab --- /dev/null +++ b/tests/peripherals/virtio-platform.repl
@@ -0,0 +1,41 @@ +rom: Memory.MappedMemory @ sysbus 0x0 + size: 0x10000 + +sram: Memory.MappedMemory @ sysbus 0x10000000 + size: 0x2000 + +main_ram: Memory.MappedMemory @ sysbus 0x40000000 + size: 0x10000000 + +spiflash: Memory.MappedMemory @ sysbus 0xd0000000 + size: 0x1000000 + +clint: IRQControllers.CoreLevelInterruptor @ sysbus 0xf0010000 + frequency: 100000000 + [0, 1] -> cpu@[3, 7] + +plic: IRQControllers.PlatformLevelInterruptController @ sysbus 0xf0c00000 + [0, 1, 2] -> cpu@[11, 9, 13] + numberOfSources: 32 + numberOfContexts: 3 + prioritiesEnabled: false + +cpu: CPU.VexRiscv @ sysbus + cpuType: "rv32imac_zicsr_zifencei" + builtInIrqController: false + privilegeArchitecture: PrivilegeArchitecture.Priv1_10 + timeProvider: clint + +ctrl: Miscellaneous.LiteX_SoC_Controller @ sysbus 0xf0000000 + +uart0: UART.LiteX_UART @ sysbus 0xf0001000 + +timer0: Timers.LiteX_Timer @ sysbus 0xf0001800 + frequency: 100000000 + +litespi0: SPI.LiteX_SPI @ sysbus 0xf0007000 + +sysbus: + init add: + SilenceRange <4026544128 0x200> # ddrphy + SilenceRange <4026546176 0x200> # sdram
diff --git a/tests/tests.yaml b/tests/tests.yaml index 8804495..171eabd 100644 --- a/tests/tests.yaml +++ b/tests/tests.yaml
@@ -150,3 +150,4 @@ - tests/peripherals/S32K3XX_FlexCAN.robot - tests/platforms/BeagleV-StarLight.robot - tests/unit-tests/virtual-time.robot +- tests/peripherals/VirtIO.robot