From 22ce2d05b223d0b5fabb790ef6eb0751322e7d49 Mon Sep 17 00:00:00 2001 From: Philip Li Date: Fri, 14 Jun 2024 15:09:15 +0800 Subject: [PATCH] programs: add kvm-unit-tests-qemu Signed-off-by: Philip Li --- programs/kvm-unit-tests-qemu/meta.yaml | 16 ++++++ programs/kvm-unit-tests-qemu/parse | 1 + programs/kvm-unit-tests-qemu/pkg/PKGBUILD | 1 + programs/kvm-unit-tests-qemu/pkg/addon | 1 + programs/kvm-unit-tests-qemu/pkg/depends | 36 ++++++++++++++ programs/kvm-unit-tests-qemu/run | 59 +++++++++++++++++++++++ 6 files changed, 114 insertions(+) create mode 100644 programs/kvm-unit-tests-qemu/meta.yaml create mode 120000 programs/kvm-unit-tests-qemu/parse create mode 120000 programs/kvm-unit-tests-qemu/pkg/PKGBUILD create mode 120000 programs/kvm-unit-tests-qemu/pkg/addon create mode 100644 programs/kvm-unit-tests-qemu/pkg/depends create mode 100755 programs/kvm-unit-tests-qemu/run diff --git a/programs/kvm-unit-tests-qemu/meta.yaml b/programs/kvm-unit-tests-qemu/meta.yaml new file mode 100644 index 000000000..d98426feb --- /dev/null +++ b/programs/kvm-unit-tests-qemu/meta.yaml @@ -0,0 +1,16 @@ +short_description: > + The kvm-unit-tests are a set of tests which can be used to verify virtualized CPUs + (like KVM and others), emulated CPUs (like TCG from QEMU) or even real CPU behavior. + + This test suite with -qemu suffix won't use the qemu binary provided in + distribution, but will clone official qemu git tree and build qemu from + source code. + +homepage: https://gitlab.com/kvm-unit-tests/kvm-unit-tests + +parameters: + qemu_branch: qemu/master + qemu_commit: + qemu_config: x86_64-softmmu + +results: diff --git a/programs/kvm-unit-tests-qemu/parse b/programs/kvm-unit-tests-qemu/parse new file mode 120000 index 000000000..7d84f0213 --- /dev/null +++ b/programs/kvm-unit-tests-qemu/parse @@ -0,0 +1 @@ +../kvm-unit-tests/parse \ No newline at end of file diff --git a/programs/kvm-unit-tests-qemu/pkg/PKGBUILD b/programs/kvm-unit-tests-qemu/pkg/PKGBUILD new file mode 120000 index 000000000..037d392d0 --- /dev/null +++ b/programs/kvm-unit-tests-qemu/pkg/PKGBUILD @@ -0,0 +1 @@ +../../kvm-unit-tests/pkg/PKGBUILD \ No newline at end of file diff --git a/programs/kvm-unit-tests-qemu/pkg/addon b/programs/kvm-unit-tests-qemu/pkg/addon new file mode 120000 index 000000000..f945df50f --- /dev/null +++ b/programs/kvm-unit-tests-qemu/pkg/addon @@ -0,0 +1 @@ +../../kvm-unit-tests/pkg/addon \ No newline at end of file diff --git a/programs/kvm-unit-tests-qemu/pkg/depends b/programs/kvm-unit-tests-qemu/pkg/depends new file mode 100644 index 000000000..0e4a84166 --- /dev/null +++ b/programs/kvm-unit-tests-qemu/pkg/depends @@ -0,0 +1,36 @@ +acpica-tools +build-essential +git +info2man +libaio-dev +libasound2-dev +libcap-dev +libcap-ng-dev +libfdt-dev +libfdt1 +libglib2.0-0 +libglib2.0-dev +libnfs-dev +libpipewire-0.3-dev +libpixman-1-0 +libpixman-1-dev +libpulse-dev +libsdl1.2debian +libsdl2-dev +libseccomp-dev +libslirp-dev +libspice-protocol-dev +libspice-server-dev +liburing-dev +libvdeplug-dev +libxen-dev +libxkbcommon-dev +ninja-build +pkg-config +psmisc +python-csvkit +python-pip +python-tomli +python-venv +virt-what +zlib1g-dev diff --git a/programs/kvm-unit-tests-qemu/run b/programs/kvm-unit-tests-qemu/run new file mode 100755 index 000000000..f0e319c78 --- /dev/null +++ b/programs/kvm-unit-tests-qemu/run @@ -0,0 +1,59 @@ +#!/bin/bash + +. $LKP_SRC/lib/mount.sh +. $LKP_SRC/lib/debug.sh +. $LKP_SRC/lib/upload.sh +. $LKP_SRC/lib/tests/kvm-unit-tests.sh +. $LKP_SRC/lib/git.sh +. $LKP_SRC/lib/misc-base.sh +. $LKP_SRC/lib/reproduce-log.sh + +## Tests for x86 architecture are run as kernel images for qemu +## that supports multiboot format. Tests uses an infrastructure +## called from the bios code. The infrastructure initialize the +## system/cpu's, switch to long-mode and calls the 'main' function +## of the individual test. Tests uses a qemu's virtual test device, +## named testdev, for services like printing, exiting, query memory size etc. + +build_qemu() +{ + [ -n "$qemu_config" ] || die "can not find qemu_config" + [ -n "$qemu_commit" ] || die "can not find qemu_commit" + [ -n "$qemu_branch" ] || die "can not find qemu_branch" + + qemu_remote=${qemu_branch%%/*} + + git_clone_update --recursive https://gitlab.com/qemu-project/$qemu_remote.git "$QEMU_REPO_ROOT" 2>&1 || die "failed clone qemu tree $qemu_remote" + + cd "$QEMU_REPO_ROOT" || die "fail to enter $QEMU_REPO_ROOT" + log_cmd git checkout -q $qemu_commit || die "failed to checkout qemu commit $qemu_commit" + + log_cmd ./configure --target-list="$qemu_config" --disable-docs || die "failed to run ./configure" + + unset LDFLAGS + log_cmd make -j $nr_cpu 2>&1 || die "failed to make" + + $QEMU --help >/dev/null || die "QEMU Emulator can not work normally." +} + +QEMU_REPO_ROOT="$BENCHMARK_ROOT/qemu" +QEMU="$QEMU_REPO_ROOT/build/qemu-system-x86_64" + +build_qemu +$QEMU --version + +cd $BENCHMARK_ROOT/kvm-unit-tests || die "no $BENCHMARK_ROOT/kvm-unit-tests" + +export QEMU + +fixup_tests +setup_test_environment || die "failed to setup test environment" + +run_tests +exit_code=$? + +upload_test_results + +[ $exit_code -ne 0 ] && dump_qemu + +exit $exit_code