From 0b9e08a798f74fde6fd39a258bf5111614c05bbc Mon Sep 17 00:00:00 2001 From: Sandro Bonazzola Date: Thu, 24 Aug 2023 14:43:29 +0200 Subject: [PATCH] tests: add functional test Also switches the CI to using rawhide for now to avoid building gtk4 ourselves until fedora 39 is released Signed-off-by: Sandro Bonazzola --- .gitlab-ci.yml | 32 ++++++++++++++++++++++++++++---- tests/functional.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 4 deletions(-) create mode 100755 tests/functional.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4063f86..eb02c6f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,6 +7,30 @@ stages: - docs - 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: variables: BUNDLE: "mks-test-widget-dev.flatpak" @@ -17,13 +41,13 @@ flatpak: extends: ".flatpak" reference: - image: fedora:38 + image: fedora:rawhide stage: docs - needs: [] 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: - - 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: - mkdir -p pfx/ - meson ${MESON_FLAGS} --prefix=${PWD}/pfx -Ddocs=true _build diff --git a/tests/functional.sh b/tests/functional.sh new file mode 100755 index 0000000..e1acd05 --- /dev/null +++ b/tests/functional.sh @@ -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