Merge branch 'libmks-functional_test' into 'main'

tests: add functional test

See merge request GNOME/libmks!41
This commit is contained in:
Bilal Elmoussaoui 2023-09-07 19:35:19 +00:00
commit 058c1f4fb0
4 changed files with 66 additions and 6 deletions

View File

@ -7,6 +7,30 @@ stages:
- docs - docs
- deploy - deploy
tests:
image: fedora:rawhide
stage: test
variables:
MESON_FLAGS: "-Db_coverage=true -Ddocs=false -Dvapi=false -Dintrospection=disabled"
before_script:
- sudo dnf install -y git gtk4-devel libepoxy-devel meson gcc lcov wget
qemu-system-x86 qemu-ui-dbus qemu-ui-opengl
dbus-x11 xorg-x11-server-Xvfb
script:
- meson setup _build
- meson configure ${MESON_FLAGS} _build
- meson compile -C _build
- meson test -C _build --suit "libmks"
- cd tests
- BUILDDIR=_build xvfb-run ./functional.sh
- cd ..
- rm -rf _build/subprojects
- ninja coverage-html -C _build
artifacts:
paths:
- _build/meson-logs/coveragereport
flatpak: flatpak:
variables: variables:
BUNDLE: "mks-test-widget-dev.flatpak" BUNDLE: "mks-test-widget-dev.flatpak"
@ -17,13 +41,13 @@ flatpak:
extends: ".flatpak" extends: ".flatpak"
reference: reference:
image: fedora:38 image: fedora:rawhide
stage: docs stage: docs
needs: []
variables: variables:
MESON_FLAGS: "--buildtype=release -Dgtk:gtk_doc=false -Dgtk:introspection=disabled -Dgtk:build-examples=false -Dgtk:build-tests=false -Dgtk:demos=false -Dgtk:media-gstreamer=disabled -Dlibepoxy:tests=false" MESON_FLAGS: "--buildtype=release -Ddocs=true -Dintrospection=enabled"
before_script: before_script:
- sudo dnf install -y git gtk4-devel meson gcc gcc-c++ gi-docgen gobject-introspection-devel vala - sudo dnf install -y git gtk4-devel libepoxy-devel meson gcc
gi-docgen gobject-introspection-devel vala
script: script:
- mkdir -p pfx/ - mkdir -p pfx/
- meson ${MESON_FLAGS} --prefix=${PWD}/pfx -Ddocs=true _build - meson ${MESON_FLAGS} --prefix=${PWD}/pfx -Ddocs=true _build

View File

@ -153,7 +153,7 @@ pkg.generate(
install_dir: join_paths(get_option('libdir'), 'pkgconfig') install_dir: join_paths(get_option('libdir'), 'pkgconfig')
) )
if get_option('introspection').allowed() if get_option('introspection').enabled()
libmks_gir_extra_args = [ libmks_gir_extra_args = [
'--c-include=libmks.h', '--c-include=libmks.h',
'--quiet', '--quiet',

View File

@ -164,7 +164,7 @@ if have_tests
endif endif
summary('Enabled', have_tests, section: 'Tests') summary('Enabled', have_tests, section: 'Tests')
if get_option('docs') and get_option('introspection').allowed() if get_option('docs') and get_option('introspection').enabled()
subdir('docs') subdir('docs')
endif endif

36
tests/functional.sh Executable file
View File

@ -0,0 +1,36 @@
#!/usr/bin/bash
test -e 512-byte-vm.raw || wget https://github.com/oVirt/512-byte-vm/releases/download/2.0.0/512-byte-vm.raw
QEMU=""
ARCH="$(uname -m)"
test -x "/usr/bin/qemu-system-$ARCH" && QEMU="/usr/bin/qemu-system-$ARCH"
test -x /usr/libexec/qemu-kvm && QEMU=/usr/libexec/qemu-kvm
if [ -z "$QEMU" ]
then
echo "Missing QEMU executable"
exit 1
fi
echo -e "Using $QEMU\n"
${QEMU} \
-drive file=512-byte-vm.raw,format=raw \
-display dbus -device virtio-vga \
-serial mon:stdio \
-enable-kvm &
QEMUPID=$!
sleep 1
BUILDDIR=${BUILDDIR:="builddir"}
"../${BUILDDIR}/tools/mks-connect"
"../${BUILDDIR}/tools/mks" &
MKSPID=$!
sleep 1
kill -SIGTERM $QEMUPID
kill -SIGTERM $MKSPID