Skip to content

Commit

Permalink
[guest-test] Test Enhance: tab format unified across all source code
Browse files Browse the repository at this point in the history
all tab format unified to 2 spaces across all source code

[Test Components] tdx
[Test Types] func
[Supported Devices] spr,emr,gnr.srf

Signed-off-by: Hongyu Ning <[email protected]>
  • Loading branch information
hongyuni authored and ysun committed Oct 26, 2023
1 parent 24ee6ed commit c96cd27
Show file tree
Hide file tree
Showing 6 changed files with 232 additions and 232 deletions.
62 changes: 31 additions & 31 deletions guest-test/guest.test_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ EOF
}

guest_kernel_reboot() {
sshpass -e ssh -p "$PORT" -o StrictHostKeyChecking=no root@localhost << EOF
sshpass -e ssh -p "$PORT" -o StrictHostKeyChecking=no root@localhost << EOF
systemctl reboot --reboot-argument=now
EOF
}
Expand All @@ -86,11 +86,11 @@ source ../.env

## PART 0: prepare test prerequisites ##
if [ ! "$(which sshpass)" ]; then
dnf install -y sshpass > /dev/null
apt install -y sshpass > /dev/null
dnf install -y sshpass > /dev/null
apt install -y sshpass > /dev/null
else
test_print_trc "sshpass prerequisites is ready for use"
test_print_trc "VM test is starting now..."
test_print_trc "sshpass prerequisites is ready for use"
test_print_trc "VM test is starting now..."
fi

## PART 1: get params from qemu.cfg.json and script args ##
Expand Down Expand Up @@ -142,7 +142,7 @@ while getopts :v:s:m:d:t:x:c:p:g:h arg; do
GCOV=$OPTARG
echo GCOV="\"$GCOV\"" >> "$SCRIPT_DIR"/test_params.py
;;
h)
h)
usage && exit 0
;;
:)
Expand Down Expand Up @@ -205,13 +205,13 @@ export GCOV
cd "$SCRIPT_DIR" || die "fail to switch to $SCRIPT_DIR"
rm -rf /root/.ssh/known_hosts
while read -r line; do
echo "[${VM_TYPE}_vm]: $line"
echo "[${VM_TYPE}_vm]: $line"
# within $TIMEOUT but bypass the very first 2 seconds to avoid unexpected $BOOT_PATTERN match (from parameter handling logic)
if [[ $SECONDS -lt $TIMEOUT ]] && [[ $SECONDS -ge 2 ]]; then
if [[ $line == $BOOT_PATTERN ]] && [[ $EXEC_FLAG -ne 0 ]]; then
test_print_trc "VM_TYPE: $VM_TYPE, VCPU: $VCPU, SOCKETS: $SOCKETS, MEM: $MEM, DEBUG: $DEBUG, PMU: $PMU, CMDLINE: $CMDLINE, TESTCASE: $TESTCASE, SECONDS: $SECONDS"
if [[ $SECONDS -lt $TIMEOUT ]] && [[ $SECONDS -ge 2 ]]; then
if [[ $line == $BOOT_PATTERN ]] && [[ $EXEC_FLAG -ne 0 ]]; then
test_print_trc "VM_TYPE: $VM_TYPE, VCPU: $VCPU, SOCKETS: $SOCKETS, MEM: $MEM, DEBUG: $DEBUG, PMU: $PMU, CMDLINE: $CMDLINE, TESTCASE: $TESTCASE, SECONDS: $SECONDS"
EXEC_FLAG=0
if ! ./guest.test_executor.sh; then EXEC_FLAG=1 && break; fi # break while read loop in case of TD VM test failure
if ! ./guest.test_executor.sh; then EXEC_FLAG=1 && break; fi # break while read loop in case of TD VM test failure
# err_handlers string matching
elif [[ $line == $ERR_STR1 ]]; then
test_print_err "There is $ERR_STR1, test is not fully PASS"
Expand All @@ -228,11 +228,11 @@ while read -r line; do
elif [[ $line == $ERR_STR5 ]]; then
test_print_wrg "There is $ERR_STR5, please check"
ERR_FLAG5=1
fi
fi
# end of err_handlers string matching
elif [[ $SECONDS -ge $TIMEOUT ]]; then # break while read loop in case of TD VM boot timeout (no $BOOT_PATTERN found)
break
fi
elif [[ $SECONDS -ge $TIMEOUT ]]; then # break while read loop in case of TD VM boot timeout (no $BOOT_PATTERN found)
break
fi
done < <(if [ "$GCOV" == "off" ]; then timeout "$TIMEOUT" ./guest.qemu_runner.sh; \
else test_print_trc "${VM_TYPE}vm_$PORT keep alive for gcov data collection" && ./guest.qemu_runner.sh; fi)

Expand Down Expand Up @@ -278,28 +278,28 @@ sleep 3
# time count less or qual than 3 is case b
# - handling: nothing to do, die for TDVM boot early failure, likely qemu config issue
if ! guest_kernel_check; then
if [ "$SECONDS" -gt 3 ] && [ "$SECONDS" -lt "$TIMEOUT" ] && [ "$EXEC_FLAG" -eq 0 ]; then
test_print_trc "$VM_TYPE VM test complete..."
elif [ "$SECONDS" -ge "$TIMEOUT" ] && [ "$GCOV" == "on" ]; then
pkill "${VM_TYPE}vm_$PORT"
die "TEST TIMEOUT!!!!!!!!!!!!"
elif [ "$GCOV" == "off" ] && [ "$EXEC_FLAG" -eq 1 ]; then
if [ "$SECONDS" -gt 3 ] && [ "$SECONDS" -lt "$TIMEOUT" ] && [ "$EXEC_FLAG" -eq 0 ]; then
test_print_trc "$VM_TYPE VM test complete..."
elif [ "$SECONDS" -ge "$TIMEOUT" ] && [ "$GCOV" == "on" ]; then
pkill "${VM_TYPE}vm_$PORT"
die "TEST TIMEOUT!!!!!!!!!!!!"
elif [ "$GCOV" == "off" ] && [ "$EXEC_FLAG" -eq 1 ]; then
pkill "${VM_TYPE}vm_$PORT"
die "$VM_TYPE VM test seems fail at beginning, please check test log"
fi
die "$VM_TYPE VM test seems fail at beginning, please check test log"
fi
# guest_kernel_kernel function zero return value shows TDVM is still accessible handling
# handling: no matter why it's still accessible, close it by guest_kernel_reboot function
elif [ "$GCOV" == "off" ]; then
if ! guest_kernel_reboot; then
test_print_trc "$VM_TYPE VM is still up"
test_print_trc "time: $SECONDS"
test_print_trc "SSHPASS: $SSHPASS"
test_print_trc "PORT: $PORT"
test_print_trc "$VM_TYPE VM closed"
if ! guest_kernel_reboot; then
test_print_trc "$VM_TYPE VM is still up"
test_print_trc "time: $SECONDS"
test_print_trc "SSHPASS: $SSHPASS"
test_print_trc "PORT: $PORT"
test_print_trc "$VM_TYPE VM closed"
# must die here since TDVM should be closed and not accessible if test complete all correctly
# else it's due to test die before reaching final close point td_test_close function
die "$VM_TYPE VM test fail, please check test log"
fi
die "$VM_TYPE VM test fail, please check test log"
fi
else # [ $GCOV == "on" ] || [ guest_kernel_check return 0 ]
test_print_trc "${VM_TYPE}vm_$PORT keep alive for gcov data collection"
test_print_trc "'ssh -p $PORT root@localhost' with PASSWORD '$SSHPASS' to login and get data"
Expand Down
88 changes: 44 additions & 44 deletions guest-test/qemu.config.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
{
"common": {
"kernel_img": "/boot/vmlinuz-xxx-yyy",
"initrd_img": "/boot/initramfs-xxx-yyy",
"bios_img": "/path/to/EDKII/OVMF.fd or other virtual BIOS",
"qemu_img": "/path/to/qemu-kvm with proper capabilty of VM test",
"guest_img": "/path/to/prepared/guest_os_image, in qcow2 or raw image format",
"guest_img_format": "raw",
"boot_pattern": "*Kernel*on*an*x86_64*",
"guest_root_passwd": "123456",
"vm_type": "tdx",
"pmu": "off",
"cpus": "4",
"sockets": "1",
"mem": "16",
"cmdline": "accept_memory=lazy",
"debug": "on"
},
"common": {
"kernel_img": "/boot/vmlinuz-xxx-yyy",
"initrd_img": "/boot/initramfs-xxx-yyy",
"bios_img": "/path/to/EDKII/OVMF.fd or other virtual BIOS",
"qemu_img": "/path/to/qemu-kvm with proper capabilty of VM test",
"guest_img": "/path/to/prepared/guest_os_image, in qcow2 or raw image format",
"guest_img_format": "raw",
"boot_pattern": "*Kernel*on*an*x86_64*",
"guest_root_passwd": "123456",
"vm_type": "tdx",
"pmu": "off",
"cpus": "4",
"sockets": "1",
"mem": "16",
"cmdline": "accept_memory=lazy",
"debug": "on"
},

"vm": {
"cfg_1": "-accel kvm -no-reboot -nographic -vga none -device virtio-net-pci,netdev=mynet0,mac=DE:AD:BE:EF:AB:CD,romfile= ",
"cfg_2": "-chardev stdio,id=mux,mux=on,signal=off -device virtio-serial,romfile= -device virtconsole,chardev=mux ",
"cfg_3": "-serial chardev:mux -monitor chardev:mux -monitor pty -no-hpet -nodefaults ",
"cfg_var_1": "-name process=$VM_TYPEVM_$PORT,debug-threads=on ",
"cfg_var_2": "-cpu host,host-phys-bits,pmu=$PMU ",
"cfg_var_3": "-smp cpus=$VCPU,sockets=$SOCKETS ",
"cfg_var_4": "-m $MEMG ",
"cfg_var_5": "-kernel $KERNEL_IMG ",
"cfg_var_6": "-initrd $INITRD_IMG",
"cfg_var_7": "-netdev user,id=mynet0,hostfwd=tcp::$PORT-:22 ",
"cfg_var_8": "-drive file=$GUEST_IMG,if=virtio,format=$IMG_FORMAT ",
"cfg_var_9": "-append \"root=/dev/vda3 ro console=hvc0 earlyprintk=ttyS0 ignore_loglevel debug earlyprintk l1tf=off initcall_debug log_buf_len=200M nokaslr tsc=reliable efi=debug mce=off efi=debug $CMDLINE\" ",
"cfg_var_10": "-bios $BIOS_IMG "
},
"vm": {
"cfg_1": "-accel kvm -no-reboot -nographic -vga none -device virtio-net-pci,netdev=mynet0,mac=DE:AD:BE:EF:AB:CD,romfile= ",
"cfg_2": "-chardev stdio,id=mux,mux=on,signal=off -device virtio-serial,romfile= -device virtconsole,chardev=mux ",
"cfg_3": "-serial chardev:mux -monitor chardev:mux -monitor pty -no-hpet -nodefaults ",
"cfg_var_1": "-name process=$VM_TYPEVM_$PORT,debug-threads=on ",
"cfg_var_2": "-cpu host,host-phys-bits,pmu=$PMU ",
"cfg_var_3": "-smp cpus=$VCPU,sockets=$SOCKETS ",
"cfg_var_4": "-m $MEMG ",
"cfg_var_5": "-kernel $KERNEL_IMG ",
"cfg_var_6": "-initrd $INITRD_IMG",
"cfg_var_7": "-netdev user,id=mynet0,hostfwd=tcp::$PORT-:22 ",
"cfg_var_8": "-drive file=$GUEST_IMG,if=virtio,format=$IMG_FORMAT ",
"cfg_var_9": "-append \"root=/dev/vda3 ro console=hvc0 earlyprintk=ttyS0 ignore_loglevel debug earlyprintk l1tf=off initcall_debug log_buf_len=200M nokaslr tsc=reliable efi=debug mce=off efi=debug $CMDLINE\" ",
"cfg_var_10": "-bios $BIOS_IMG "
},

"tdx": {
"cfg_1": "-machine q35,kernel_irqchip=split,confidential-guest-support=tdx,memory-backend=ram1 ",
"cfg_var_1": "-object tdx-guest,id=tdx,debug=$DEBUG,sept-ve-disable=on,quote-generation-service=vsock:2:4050 ",
"cfg_var_2": "-object memory-backend-memfd-private,id=ram1,size=$MEMG "
},
"tdx": {
"cfg_1": "-machine q35,kernel_irqchip=split,confidential-guest-support=tdx,memory-backend=ram1 ",
"cfg_var_1": "-object tdx-guest,id=tdx,debug=$DEBUG,sept-ve-disable=on,quote-generation-service=vsock:2:4050 ",
"cfg_var_2": "-object memory-backend-memfd-private,id=ram1,size=$MEMG "
},

"tdxio": {
"cfg_1": "-object iommufd,id=iommufd0 ",
"cfg_2": "-device vfio-pci,host=tee_bdf1,id=hostdev2,addr=0x3,x-secure-mode=on ",
"cfg_3": "-device vfio-pci,host=tee_bdf2,id=hostdev3,addr=0x4,x-secure-mode=on ",
"cfg_4": "-device vfio-pci,host=tee_bdf3,id=hostdev4,addr=0x5,x-secure-mode=on ",
"cfg_5": "-device vfio-pci,host=tee_bdf4,id=hostdev5,addr=0x6,x-secure-mode=on "
}
"tdxio": {
"cfg_1": "-object iommufd,id=iommufd0 ",
"cfg_2": "-device vfio-pci,host=tee_bdf1,id=hostdev2,addr=0x3,x-secure-mode=on ",
"cfg_3": "-device vfio-pci,host=tee_bdf2,id=hostdev3,addr=0x4,x-secure-mode=on ",
"cfg_4": "-device vfio-pci,host=tee_bdf3,id=hostdev4,addr=0x5,x-secure-mode=on ",
"cfg_5": "-device vfio-pci,host=tee_bdf4,id=hostdev5,addr=0x6,x-secure-mode=on "
}
}
Loading

0 comments on commit c96cd27

Please sign in to comment.