mutter/src/tests/kvm/build-linux.sh
Jonas Ådahl 06eb27d503 tests: Run KMS tests inside a QEMU virtual machine
This commit makes it possible to run test executables in a test
environment constructed of a virtual machine running the Linux kernel
with the virtual KMS driver enabled, and a mocked system environment
using meta-dbus-runner.py/python-dbusmock.

The qemu machine is configured to use 256M of memory, as the default
128M was not enough for the tests to pass.

Using qemu is also only made possible on x86_64; more changes are needed
for it to be runnable on aarch64, so add a warning if it was enabled on
any other architecture.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2151>
2022-01-14 09:16:09 +00:00

75 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
#
# Script for building the Linux kernel from git. It aims to build a kernel image
# that is suitable for running in a virtual machine and is aimed to used for
# testing.
#
# Usage: build-linux.sh [REPO-URL] [BRANCH|TAG] [OUTPUT-FILE] [...CONFIGS]
#
# Where [..CONFIGS] can be any number of configuration options, e.g.
# --enable CONFIG_DRM_VKMS
set -e
# From scripts/subarch.include in linux
function get-subarch()
{
uname -m | sed -e s/i.86/x86/ \
-e s/x86_64/x86/ \
-e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ \
-e s/riscv.*/riscv/
}
REPO="$1"
BRANCH_OR_TAG="$(cat $2)"
IMAGE="$3"
ARCH=$(uname -m)
SUBARCH=$(get-subarch)
shift
shift
shift
# ./scripts/config --enable CONFIG_DRM_VKMS
CONFIGS=()
while [[ "x$1" != "x" ]]; do
CONFIGS+=( "$1" )
shift
done
echo Building Linux for $ARCH \($SUBARCH\)...
set -x
if [ -d linux ]; then
pushd linux
git fetch $REPO $BRANCH_OR_TAG
git checkout FETCH_HEAD
else
git clone --depth=1 --branch=$BRANCH_OR_TAG $REPO linux
pushd linux
fi
make defconfig
sync
make kvm_guest.config
echo Enabling ${CONFIGS[@]}...
./scripts/config ${CONFIGS[@]/#/--enable }
make oldconfig
make -j8
popd
TARGET_DIR="$(dirname "$IMAGE")"
mkdir -p "$TARGET_DIR"
mv linux/arch/$SUBARCH/boot/bzImage "$IMAGE"
mv linux/.config $TARGET_DIR/.config
#rm -rf linux