From: Marc Orr <marcorr@xxxxxxxxxx> Make several fixes so that run_tests.sh can run the test cases when the repo is configured to run under UEFI. Specifically: 1. The scripts are enlighted to run the .efi test cases rather than the .flat test cases. 2. The scripts are enlighted to run an empty file, _NO_FILE_4Uhere_, which is used to sanity check QEMU and QEMU flags. 3. The scripts are updated to always run with `-smp 1`, since SMP is not yet supported under UEFI. Notably, QEMU's `-append` flag still does not work. This will need to be fixed in future commits. For now, test cases that use `-append` are marked `SKIP`. Signed-off-by: Marc Orr <marcorr@xxxxxxxxxx> --- scripts/common.bash | 4 ++-- scripts/runtime.bash | 15 +++++++++++++-- x86/efi/run | 24 ++++++++++++++++++++---- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/scripts/common.bash b/scripts/common.bash index 6f45843..c42df95 100644 --- a/scripts/common.bash +++ b/scripts/common.bash @@ -26,7 +26,7 @@ function for_each_unittest() if [[ "$line" =~ ^\[(.*)\]$ ]]; then rematch=${BASH_REMATCH[1]} if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" "$(running_under_efi)" fi testname=$rematch smp=1 @@ -56,7 +56,7 @@ function for_each_unittest() fi done if [ -n "${testname}" ]; then - $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" + $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$opts" "$arch" "$check" "$accel" "$timeout" "$(running_under_efi)" fi exec {fd}<&- } diff --git a/scripts/runtime.bash b/scripts/runtime.bash index 132389c..9c89a74 100644 --- a/scripts/runtime.bash +++ b/scripts/runtime.bash @@ -81,6 +81,11 @@ function run() local check="${CHECK:-$7}" local accel="$8" local timeout="${9:-$TIMEOUT}" # unittests.cfg overrides the default + local running_under_efi="${10}" + + if [ "$running_under_efi" ]; then + kernel=$(basename $kernel .flat) + fi if [ -z "$testname" ]; then return @@ -127,8 +132,14 @@ function run() fi last_line=$(premature_failure > >(tail -1)) && { - print_result "SKIP" $testname "" "$last_line" - return 77 + skip=true + if [ "${running_under_efi}" ] && [[ "${last_line}" =~ "Reset" ]]; then + skip=false + fi + if [ ${skip} == true ]; then + print_result "SKIP" $testname "" "$last_line" + return 77 + fi } cmdline=$(get_cmdline $kernel) diff --git a/x86/efi/run b/x86/efi/run index aacc691..e6486ed 100755 --- a/x86/efi/run +++ b/x86/efi/run @@ -34,16 +34,27 @@ shift 1 # This host dir will be loaded by QEMU as a FAT32 image # - Make UEFI startup script that runs the .efi on boot mkdir -p "$EFI_TEST/$EFI_CASE/" -cp "$EFI_SRC/$EFI_CASE.efi" "$EFI_TEST/$EFI_CASE/" +if [ $EFI_CASE != "_NO_FILE_4Uhere_" ]; then + cp "$EFI_SRC/$EFI_CASE.efi" "$EFI_TEST/$EFI_CASE/" +else + touch "$EFI_TEST/$EFI_CASE/$EFI_CASE.efi" +fi pushd "$EFI_TEST/$EFI_CASE" || exit 2 # 'startup.nsh' is the default script executed by UEFI on boot # Use this script to run the test binary automatically -cat << EOF >startup.nsh +if [ $EFI_CASE != "_NO_FILE_4Uhere_" ]; then + cat << EOF >startup.nsh @echo -off fs0: "$EFI_CASE.efi" EOF +else + cat << EOF >startup.nsh +@echo -off +reset -s +EOF +fi popd || exit 2 # Run test case with 256MiB QEMU memory. QEMU default memory size is 128MiB. @@ -52,11 +63,16 @@ popd || exit 2 # run in UEFI, some test cases, e.g. `x86/pmu.c`, require more free memory. A # simple fix is to increase the QEMU default memory size to 256MiB so that # UEFI's largest allocatable memory region is large enough. +# +# Also, pass in an EFI-specific smp count (i.e., `-smp 1`) as the last argument +# to x86/run. This `smp` flag overrides any previous `smp` flags (e.g., +# `-smp 4`). This is necessary because KVM-Unit-Tests do not currently support +# SMP under UEFI. This last flag should be removed when this issue is resolved. "$TEST_DIR/run" \ -drive file="$EFI_UEFI",format=raw,if=pflash,readonly=on \ -drive file.dir="$EFI_TEST/$EFI_CASE/",file.driver=vvfat,file.rw=on,format=raw,if=virtio \ -net none \ -nographic \ - -smp "$EFI_SMP" \ -m 256 \ - "$@" + "$@" \ + -smp "$EFI_SMP" -- 2.33.0