# Run the test
rm -f smoke.serial
set +e
-timeout -k 1 720 \
-qemu-system-x86_64 \
+export QEMU_CMD="qemu-system-x86_64 \
-cpu qemu64,+svm \
-m 2G -smp 2 \
-monitor none -serial stdio \
-nographic \
-device virtio-net-pci,netdev=n0 \
- -netdev user,id=n0,tftp=binaries,bootfile=/pxelinux.0 |& \
- # Remove carriage returns from the stdout output, as gitlab
- # interface chokes on them
- tee smoke.serial | sed 's/\r//'
+ -netdev user,id=n0,tftp=binaries,bootfile=/pxelinux.0"
-set -e
-(grep -q "Domain-0" smoke.serial && grep -q "BusyBox" smoke.serial) || exit 1
-exit 0
+export QEMU_LOG="smoke.serial"
+export LOG_MSG="Domain-0"
+export PASSED="BusyBox"
+
+./automation/scripts/qemu-key.exp
--- /dev/null
+#!/usr/bin/expect -f
+
+set timeout $env(QEMU_TIMEOUT)
+
+log_file -a $env(QEMU_LOG)
+
+match_max 10000
+
+eval spawn $env(QEMU_CMD)
+
+expect_after {
+ -re "(.*)\r" {
+ exp_continue
+ }
+ timeout {send_error "ERROR-Timeout!\n"; exit 1}
+ eof {send_error "ERROR-EOF!\n"; exit 1}
+}
+
+if {[info exists env(UBOOT_CMD)]} {
+ expect "=>"
+
+ send "$env(UBOOT_CMD)\r"
+}
+
+if {[info exists env(LOG_MSG)]} {
+ expect {
+ "$env(PASSED)" {
+ expect "$env(LOG_MSG)"
+ exit 0
+ }
+ "$env(LOG_MSG)" {
+ expect "$env(PASSED)"
+ exit 0
+ }
+ }
+}
+
+expect {
+ "$env(PASSED)" {
+ exit 0
+ }
+}
+
+expect eof
+
rm -f ${serial_log}
set +e
-echo " virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"| \
-timeout -k 1 720 \
-./qemu-system-arm \
+export QEMU_CMD="./qemu-system-arm \
-machine virt \
-machine virtualization=true \
-smp 4 \
-no-reboot \
-device virtio-net-pci,netdev=n0 \
-netdev user,id=n0,tftp=./ \
- -bios /usr/lib/u-boot/qemu_arm/u-boot.bin |& \
- tee ${serial_log} | sed 's/\r//'
+ -bios /usr/lib/u-boot/qemu_arm/u-boot.bin"
+
+export UBOOT_CMD="virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"
+export QEMU_LOG="${serial_log}"
+export LOG_MSG="Domain-0"
+export PASSED="/ #"
-set -e
-(grep -q "Domain-0" ${serial_log} && grep -q "^/ #" ${serial_log}) || exit 1
-exit 0
+../automation/scripts/qemu-key.exp
# Run the test
rm -f smoke.serial
set +e
-echo " virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"| \
-timeout -k 1 720 \
-./binaries/qemu-system-aarch64 \
+export QEMU_CMD="./binaries/qemu-system-aarch64 \
-machine virtualization=true \
-cpu cortex-a57 -machine type=virt \
-m 2048 -monitor none -serial stdio \
-no-reboot \
-device virtio-net-pci,netdev=n0 \
-netdev user,id=n0,tftp=binaries \
- -bios /usr/lib/u-boot/qemu_arm64/u-boot.bin |& \
- tee smoke.serial | sed 's/\r//'
+ -bios /usr/lib/u-boot/qemu_arm64/u-boot.bin"
+
+export UBOOT_CMD="virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"
+export QEMU_LOG="smoke.serial"
+export LOG_MSG="Domain-0"
+export PASSED="BusyBox"
-set -e
-(grep -q "Domain-0" smoke.serial && grep -q "BusyBox" smoke.serial) || exit 1
-exit 0
+./automation/scripts/qemu-key.exp
test_variant=$1
# Prompt to grep for to check if dom0 booted successfully
-dom0_prompt="^/ #"
+dom0_prompt="/ #"
serial_log="$(pwd)/smoke.serial"
# Run the test
rm -f ${serial_log}
set +e
-echo " virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"| \
-timeout -k 1 240 \
-./qemu-system-arm \
+export QEMU_CMD="./qemu-system-arm \
-machine virt \
-machine virtualization=true \
-smp 4 \
-no-reboot \
-device virtio-net-pci,netdev=n0 \
-netdev user,id=n0,tftp=./ \
- -bios /usr/lib/u-boot/qemu_arm/u-boot.bin |& \
- tee ${serial_log} | sed 's/\r//'
+ -bios /usr/lib/u-boot/qemu_arm/u-boot.bin"
+
+export UBOOT_CMD="virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"
+export QEMU_LOG="${serial_log}"
+export LOG_MSG="${dom0_prompt}"
+export PASSED="${passed}"
-set -e
-(grep -q "${dom0_prompt}" ${serial_log} && grep -q "${passed}" ${serial_log}) || exit 1
-exit 0
+../automation/scripts/qemu-key.exp
# Run the test
rm -f smoke.serial
set +e
-echo " virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"| \
-timeout -k 1 240 \
-./binaries/qemu-system-aarch64 \
+export QEMU_CMD="./binaries/qemu-system-aarch64 \
-machine virtualization=true \
-cpu cortex-a57 -machine type=virt,gic-version=$gic_version \
-m 2048 -monitor none -serial stdio \
-no-reboot \
-device virtio-net-pci,netdev=n0 \
-netdev user,id=n0,tftp=binaries \
- -bios /usr/lib/u-boot/qemu_arm64/u-boot.bin |& \
- tee smoke.serial | sed 's/\r//'
+ -bios /usr/lib/u-boot/qemu_arm64/u-boot.bin"
+
+export UBOOT_CMD="virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"
+export QEMU_LOG="smoke.serial"
+export LOG_MSG="Welcome to Alpine Linux"
+export PASSED="${passed}"
-set -e
-(grep -q "^Welcome to Alpine Linux" smoke.serial && grep -q "${passed}" smoke.serial) || exit 1
-exit 0
+./automation/scripts/qemu-key.exp
rm -f ${serial_log}
set +e
-timeout -k 1 20 \
-qemu-system-ppc64 \
+export QEMU_CMD="qemu-system-ppc64 \
-bios skiboot.lid \
-M $machine \
-m 2g \
-monitor none \
-nographic \
-serial stdio \
- -kernel binaries/xen \
- |& tee ${serial_log} | sed 's/\r//'
+ -kernel binaries/xen"
-set -e
-(grep -q "Hello, ppc64le!" ${serial_log}) || exit 1
-exit 0
+export QEMU_LOG="${serial_log}"
+export PASSED="Hello, ppc64le!"
+
+./automation/scripts/qemu-key.exp
rm -f smoke.serial
set +e
-timeout -k 1 2 \
-qemu-system-riscv64 \
+export QEMU_CMD="qemu-system-riscv64 \
-M virt \
-smp 1 \
-nographic \
-m 2g \
- -kernel binaries/xen \
- |& tee smoke.serial | sed 's/\r//'
+ -kernel binaries/xen"
-set -e
-(grep -q "All set up" smoke.serial) || exit 1
-exit 0
+export QEMU_LOG="smoke.serial"
+export PASSED="All set up"
+
+./automation/scripts/qemu-key.exp
rm -f smoke.serial
set +e
-timeout -k 1 30 \
-qemu-system-x86_64 -nographic -kernel binaries/xen \
+export QEMU_CMD="qemu-system-x86_64 -nographic -kernel binaries/xen \
-initrd xtf/tests/example/$k \
- -append "loglvl=all console=com1 noreboot console_timestamps=boot $extra" \
- -m 512 -monitor none -serial file:smoke.serial
-set -e
-grep -q 'Test result: SUCCESS' smoke.serial || exit 1
-exit 0
+ -append \"loglvl=all console=com1 noreboot console_timestamps=boot $extra\" \
+ -m 512 -monitor none -serial stdio"
+
+export QEMU_LOG="smoke.serial"
+export PASSED="Test result: SUCCESS"
+
+./automation/scripts/qemu-key.exp
# Run the test
rm -f smoke.serial
set +e
-echo " virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"| \
-timeout -k 1 120 \
-./binaries/qemu-system-aarch64 \
+export QEMU_CMD="./binaries/qemu-system-aarch64 \
-machine virtualization=true \
-cpu cortex-a57 -machine type=virt \
-m 2048 -monitor none -serial stdio \
-no-reboot \
-device virtio-net-pci,netdev=n0 \
-netdev user,id=n0,tftp=binaries \
- -bios /usr/lib/u-boot/qemu_arm64/u-boot.bin |& \
- tee smoke.serial | sed 's/\r//'
+ -bios /usr/lib/u-boot/qemu_arm64/u-boot.bin"
+
+export UBOOT_CMD="virtio scan; dhcp; tftpb 0x40000000 boot.scr; source 0x40000000"
+export QEMU_LOG="smoke.serial"
+export PASSED="${passed}"
-set -e
-(grep -q "${passed}" smoke.serial) || exit 1
-exit 0
+./automation/scripts/qemu-key.exp