diff mbox series

[4/5] automation: Add the script for the FVP smoke test

Message ID 20231207135318.1912846-5-Henry.Wang@arm.com (mailing list archive)
State Superseded
Headers show
Series automation: Support running FVP Dom0 smoke test for Arm | expand

Commit Message

Henry Wang Dec. 7, 2023, 1:53 p.m. UTC
This commit adds the shell script for the FVP smoke test. Similarly
as the QEMU jobs, the shell script will firstly prepare the DomU
BusyBox image, use the ImageBuilder to arrange the binaries in memory
and generate the U-Boot script, then start the test. To provide the
TFTP service for the FVP, the shell script will also start the TFTP
service, and copy the binaries needed by test to the TFTP directory
used by the TFTP server.

Signed-off-by: Henry Wang <Henry.Wang@arm.com>
---
 .../scripts/fvp-base-smoke-dom0-arm64.sh      | 117 ++++++++++++++++++
 1 file changed, 117 insertions(+)
 create mode 100755 automation/scripts/fvp-base-smoke-dom0-arm64.sh

Comments

Stefano Stabellini Dec. 8, 2023, 1:41 a.m. UTC | #1
On Thu, 7 Dec 2023, Henry Wang wrote:
> This commit adds the shell script for the FVP smoke test. Similarly
> as the QEMU jobs, the shell script will firstly prepare the DomU
> BusyBox image, use the ImageBuilder to arrange the binaries in memory
> and generate the U-Boot script, then start the test. To provide the
> TFTP service for the FVP, the shell script will also start the TFTP
> service, and copy the binaries needed by test to the TFTP directory
> used by the TFTP server.
> 
> Signed-off-by: Henry Wang <Henry.Wang@arm.com>
> ---
>  .../scripts/fvp-base-smoke-dom0-arm64.sh      | 117 ++++++++++++++++++
>  1 file changed, 117 insertions(+)
>  create mode 100755 automation/scripts/fvp-base-smoke-dom0-arm64.sh
> 
> diff --git a/automation/scripts/fvp-base-smoke-dom0-arm64.sh b/automation/scripts/fvp-base-smoke-dom0-arm64.sh
> new file mode 100755
> index 0000000000..716a63b0a8
> --- /dev/null
> +++ b/automation/scripts/fvp-base-smoke-dom0-arm64.sh
> @@ -0,0 +1,117 @@
> +#!/bin/bash
> +
> +set -ex
> +
> +# DomU Busybox
> +cd binaries
> +mkdir -p initrd
> +mkdir -p initrd/bin
> +mkdir -p initrd/sbin
> +mkdir -p initrd/etc
> +mkdir -p initrd/dev
> +mkdir -p initrd/proc
> +mkdir -p initrd/sys
> +mkdir -p initrd/lib
> +mkdir -p initrd/var
> +mkdir -p initrd/mnt
> +cp /bin/busybox initrd/bin/busybox
> +initrd/bin/busybox --install initrd/bin
> +echo "#!/bin/sh
> +
> +mount -t proc proc /proc
> +mount -t sysfs sysfs /sys
> +mount -t devtmpfs devtmpfs /dev
> +/bin/sh" > initrd/init
> +chmod +x initrd/init
> +cd initrd
> +find . | cpio --create --format='newc' | gzip > ../initrd.cpio.gz
> +cd ..
> +
> +mkdir -p rootfs
> +cd rootfs
> +tar xvzf ../initrd.tar.gz
> +mkdir proc
> +mkdir run
> +mkdir srv
> +mkdir sys
> +rm var/run
> +cp -ar ../dist/install/* .
> +mv ../initrd.cpio.gz ./root
> +cp ../Image ./root
> +echo "name=\"test\"
> +memory=512
> +vcpus=1
> +kernel=\"/root/Image\"
> +ramdisk=\"/root/initrd.cpio.gz\"
> +extra=\"console=hvc0 root=/dev/ram0 rdinit=/bin/sh\"
> +" > root/test.cfg
> +echo "#!/bin/bash
> +
> +export LD_LIBRARY_PATH=/usr/local/lib
> +bash /etc/init.d/xencommons start
> +
> +xl list
> +
> +xl create -c /root/test.cfg
> +
> +" > etc/local.d/xen.start
> +chmod +x etc/local.d/xen.start
> +echo "rc_verbose=yes" >> etc/rc.conf
> +find . |cpio -H newc -o|gzip > ../xen-rootfs.cpio.gz
> +cd ../..
> +
> +# Start a TFTP server to provide TFTP service to FVP
> +service tftpd-hpa start
> +
> +# ImageBuilder
> +echo 'MEMORY_START="0x80000000"
> +MEMORY_END="0xFF000000"
> +
> +DEVICE_TREE="fvp-base-gicv3-psci-1t.dtb"
> +XEN="xen"
> +DOM0_KERNEL="Image"
> +DOM0_RAMDISK="xen-rootfs.cpio.gz"
> +XEN_CMD="console=dtuart dom0_mem=1024M console_timestamps=boot"
> +
> +NUM_DOMUS=0
> +
> +LOAD_CMD="tftpb"
> +UBOOT_SOURCE="boot.source"
> +UBOOT_SCRIPT="boot.scr"' > binaries/config
> +rm -rf imagebuilder
> +git clone https://gitlab.com/ViryaOS/imagebuilder
> +bash imagebuilder/scripts/uboot-script-gen -t tftp -d binaries/ -c binaries/config
> +
> +# Copy files to the TFTP directory to use
> +cp ./binaries/boot.scr /srv/tftp/
> +cp ./binaries/Image /srv/tftp/
> +cp ./binaries/xen-rootfs.cpio.gz /srv/tftp/
> +cp ./binaries/xen /srv/tftp/
> +cp ./binaries/fvp-base-gicv3-psci-1t.dtb /srv/tftp/
> +
> +# Start FVP
> +TERM0_CFG="-C bp.terminal_0.mode=telnet -C bp.terminal_0.start_telnet=0"
> +TERM1_CFG="-C bp.terminal_1.mode=telnet -C bp.terminal_1.start_telnet=0"
> +TERM2_CFG="-C bp.terminal_2.mode=telnet -C bp.terminal_2.start_telnet=0"
> +TERM3_CFG="-C bp.terminal_3.mode=telnet -C bp.terminal_3.start_telnet=0"
> +
> +VIRTIO_USER_NETWORK_CFG="-C bp.virtio_net.enabled=1 \
> +-C bp.virtio_net.hostbridge.userNetworking=1 \
> +-C bp.virtio_net.hostbridge.userNetPorts=8022=22 \
> +-C bp.virtio_net.transport=legacy"
> +
> +./automation/scripts/expect/fvp-base-smoke-dom0-arm64.exp \
> +    "/FVP/FVP_Base_RevC-2xAEMvA/Base_RevC_AEMvA_pkg/models/Linux64_armv8l_GCC-9.3/FVP_Base_RevC-2xAEMvA \
> +    -C bp.vis.disable_visualisation=1 \
> +    -C bp.ve_sysregs.exit_on_shutdown=1 \
> +    -C bp.secure_memory=0 \
> +    -C cache_state_modelled=0 \
> +    -C cluster0.has_arm_v8-4=1 \
> +    -C cluster1.has_arm_v8-4=1 \
> +    ${TERM0_CFG} ${TERM1_CFG} ${TERM2_CFG} ${TERM3_CFG} \
> +    ${VIRTIO_USER_NETWORK_CFG} \
> +    -C bp.secureflashloader.fname=$(pwd)/binaries/bl1.bin \
> +    -C bp.flashloader0.fname=$(pwd)/binaries/fip.bin" |& \
> +        tee smoke.serial

This script is clear and it is fine:

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

My only concern is that the expect checks on what booted (Xen, Dom0,
DomU) are inside the script fvp-base-smoke-dom0-arm64.exp rather than in
this script. So if in the future we are going to have multiple tests
with different configurations (for instance see
qemu-smoke-dom0less-arm64.sh) we'll have to find a way to reuse
fvp-base-smoke-dom0-arm64.exp somehow.
Henry Wang Dec. 8, 2023, 1:56 a.m. UTC | #2
Hi Stefano,

> On Dec 8, 2023, at 09:41, Stefano Stabellini <sstabellini@kernel.org> wrote:
> 
> On Thu, 7 Dec 2023, Henry Wang wrote:
>> This commit adds the shell script for the FVP smoke test. Similarly
>> as the QEMU jobs, the shell script will firstly prepare the DomU
>> BusyBox image, use the ImageBuilder to arrange the binaries in memory
>> and generate the U-Boot script, then start the test. To provide the
>> TFTP service for the FVP, the shell script will also start the TFTP
>> service, and copy the binaries needed by test to the TFTP directory
>> used by the TFTP server.
>> 
>> Signed-off-by: Henry Wang <Henry.Wang@arm.com>
>> ---
>> .../scripts/fvp-base-smoke-dom0-arm64.sh      | 117 ++++++++++++++++++
>> 1 file changed, 117 insertions(+)
>> create mode 100755 automation/scripts/fvp-base-smoke-dom0-arm64.sh
> 
> This script is clear and it is fine:
> 
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Thanks!

> 
> My only concern is that the expect checks on what booted (Xen, Dom0,
> DomU) are inside the script fvp-base-smoke-dom0-arm64.exp rather than in
> this script. So if in the future we are going to have multiple tests
> with different configurations (for instance see
> qemu-smoke-dom0less-arm64.sh) we'll have to find a way to reuse
> fvp-base-smoke-dom0-arm64.exp somehow.

We do have ways to reuse expect script, for example, we can extract the common
code (variables and test logic) to the common.tcl file and source the common.tcl file
in the expect script to reuse the code. The reason why I didn’t do that in this series
is that currently there is only one script so I feel that there is not much benefit to do
this instantly :) Let’s wait to see if there is more comments from others, and I am
definitely open to refactor if there is the need to extract the common logic (for example
when we add dom0less tests in the future).

Kind regards,
Henry
diff mbox series

Patch

diff --git a/automation/scripts/fvp-base-smoke-dom0-arm64.sh b/automation/scripts/fvp-base-smoke-dom0-arm64.sh
new file mode 100755
index 0000000000..716a63b0a8
--- /dev/null
+++ b/automation/scripts/fvp-base-smoke-dom0-arm64.sh
@@ -0,0 +1,117 @@ 
+#!/bin/bash
+
+set -ex
+
+# DomU Busybox
+cd binaries
+mkdir -p initrd
+mkdir -p initrd/bin
+mkdir -p initrd/sbin
+mkdir -p initrd/etc
+mkdir -p initrd/dev
+mkdir -p initrd/proc
+mkdir -p initrd/sys
+mkdir -p initrd/lib
+mkdir -p initrd/var
+mkdir -p initrd/mnt
+cp /bin/busybox initrd/bin/busybox
+initrd/bin/busybox --install initrd/bin
+echo "#!/bin/sh
+
+mount -t proc proc /proc
+mount -t sysfs sysfs /sys
+mount -t devtmpfs devtmpfs /dev
+/bin/sh" > initrd/init
+chmod +x initrd/init
+cd initrd
+find . | cpio --create --format='newc' | gzip > ../initrd.cpio.gz
+cd ..
+
+mkdir -p rootfs
+cd rootfs
+tar xvzf ../initrd.tar.gz
+mkdir proc
+mkdir run
+mkdir srv
+mkdir sys
+rm var/run
+cp -ar ../dist/install/* .
+mv ../initrd.cpio.gz ./root
+cp ../Image ./root
+echo "name=\"test\"
+memory=512
+vcpus=1
+kernel=\"/root/Image\"
+ramdisk=\"/root/initrd.cpio.gz\"
+extra=\"console=hvc0 root=/dev/ram0 rdinit=/bin/sh\"
+" > root/test.cfg
+echo "#!/bin/bash
+
+export LD_LIBRARY_PATH=/usr/local/lib
+bash /etc/init.d/xencommons start
+
+xl list
+
+xl create -c /root/test.cfg
+
+" > etc/local.d/xen.start
+chmod +x etc/local.d/xen.start
+echo "rc_verbose=yes" >> etc/rc.conf
+find . |cpio -H newc -o|gzip > ../xen-rootfs.cpio.gz
+cd ../..
+
+# Start a TFTP server to provide TFTP service to FVP
+service tftpd-hpa start
+
+# ImageBuilder
+echo 'MEMORY_START="0x80000000"
+MEMORY_END="0xFF000000"
+
+DEVICE_TREE="fvp-base-gicv3-psci-1t.dtb"
+XEN="xen"
+DOM0_KERNEL="Image"
+DOM0_RAMDISK="xen-rootfs.cpio.gz"
+XEN_CMD="console=dtuart dom0_mem=1024M console_timestamps=boot"
+
+NUM_DOMUS=0
+
+LOAD_CMD="tftpb"
+UBOOT_SOURCE="boot.source"
+UBOOT_SCRIPT="boot.scr"' > binaries/config
+rm -rf imagebuilder
+git clone https://gitlab.com/ViryaOS/imagebuilder
+bash imagebuilder/scripts/uboot-script-gen -t tftp -d binaries/ -c binaries/config
+
+# Copy files to the TFTP directory to use
+cp ./binaries/boot.scr /srv/tftp/
+cp ./binaries/Image /srv/tftp/
+cp ./binaries/xen-rootfs.cpio.gz /srv/tftp/
+cp ./binaries/xen /srv/tftp/
+cp ./binaries/fvp-base-gicv3-psci-1t.dtb /srv/tftp/
+
+# Start FVP
+TERM0_CFG="-C bp.terminal_0.mode=telnet -C bp.terminal_0.start_telnet=0"
+TERM1_CFG="-C bp.terminal_1.mode=telnet -C bp.terminal_1.start_telnet=0"
+TERM2_CFG="-C bp.terminal_2.mode=telnet -C bp.terminal_2.start_telnet=0"
+TERM3_CFG="-C bp.terminal_3.mode=telnet -C bp.terminal_3.start_telnet=0"
+
+VIRTIO_USER_NETWORK_CFG="-C bp.virtio_net.enabled=1 \
+-C bp.virtio_net.hostbridge.userNetworking=1 \
+-C bp.virtio_net.hostbridge.userNetPorts=8022=22 \
+-C bp.virtio_net.transport=legacy"
+
+./automation/scripts/expect/fvp-base-smoke-dom0-arm64.exp \
+    "/FVP/FVP_Base_RevC-2xAEMvA/Base_RevC_AEMvA_pkg/models/Linux64_armv8l_GCC-9.3/FVP_Base_RevC-2xAEMvA \
+    -C bp.vis.disable_visualisation=1 \
+    -C bp.ve_sysregs.exit_on_shutdown=1 \
+    -C bp.secure_memory=0 \
+    -C cache_state_modelled=0 \
+    -C cluster0.has_arm_v8-4=1 \
+    -C cluster1.has_arm_v8-4=1 \
+    ${TERM0_CFG} ${TERM1_CFG} ${TERM2_CFG} ${TERM3_CFG} \
+    ${VIRTIO_USER_NETWORK_CFG} \
+    -C bp.secureflashloader.fname=$(pwd)/binaries/bl1.bin \
+    -C bp.flashloader0.fname=$(pwd)/binaries/fip.bin" |& \
+        tee smoke.serial
+
+exit 0