From 53fc8d5e3947ee09015be9e231d998af919a8308 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:26:16 +0100 Subject: [PATCH] CI: add simple runtime test --- .github/workflows/build.yml | 43 ++++++++++++++++++++++++++++--- scripts/ci/autostart | 1 + scripts/ci/ci_autostart.sh | 13 ++++++++++ scripts/ci/smoke-test.sh | 51 +++++++++++++++++++++++++++++++++++++ 4 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 scripts/ci/autostart create mode 100755 scripts/ci/ci_autostart.sh create mode 100755 scripts/ci/smoke-test.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5cdea187..ce83bb1a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -70,7 +70,8 @@ jobs: pacman-key --init pacman -Syu --noconfirm pacman -S --noconfirm git meson clang wlroots libdrm libinput \ - wayland-protocols cairo pango libxml2 xorg-xwayland librsvg libdisplay-info + wayland-protocols cairo pango libxml2 xorg-xwayland librsvg \ + libdisplay-info - name: Install Debian Testing dependencies if: matrix.name == 'Debian' @@ -78,7 +79,7 @@ jobs: sed -i '/^Types/ s/deb/& deb-src/' /etc/apt/sources.list.d/debian.sources apt-get update apt-get upgrade -y - apt-get install -y git gcc clang + apt-get install -y git gcc clang gdb xwayland apt-get build-dep -y labwc - name: Install FreeBSD dependencies @@ -104,8 +105,9 @@ jobs: xbps-install -Syu xbps-install -y git meson gcc clang pkg-config scdoc \ cairo-devel glib-devel libpng-devel librsvg-devel libxml2-devel \ - pango-devel wlroots0.17-devel + pango-devel wlroots0.17-devel gdb bash xorg-server-xwayland + # These build are executed on all runners - name: Build with gcc run: | echo ' @@ -152,6 +154,7 @@ jobs: meson compile -C build-gcc-release ' | $TARGET + # Runtime tests, these run on Debian and Void only (the later due to libmusl being used) - name: Build with clang - release run: | echo ' @@ -161,3 +164,37 @@ jobs: -Dbuildtype=release -Db_ndebug=true --werror meson compile -C build-clang-release ' | $TARGET + + - name: Build with gcc - runtime test + if: matrix.name == 'Debian' + run: | + echo ' + cd "$GITHUB_WORKSPACE" + export CC=gcc + meson setup build-gcc-ci -Dxwayland=enabled -Db_sanitize=undefined --werror + meson compile -C build-gcc-ci + scripts/ci/smoke-test.sh build-gcc-ci + ' | $TARGET + + - name: Build with clang - runtime test + if: matrix.name == 'Debian' + run: | + echo ' + cd "$GITHUB_WORKSPACE" + export CC=clang + meson setup build-clang-ci -Dxwayland=enabled -Db_sanitize=undefined --werror + meson compile -C build-clang-ci + scripts/ci/smoke-test.sh build-clang-ci + ' | $TARGET + + # Void-musl doesn't support sanitizer + - name: Build with gcc - runtime test w/o sanitizer + if: matrix.name == 'Void-musl' + run: | + echo ' + cd "$GITHUB_WORKSPACE" + export CC=gcc + meson setup build-gcc-ci -Dxwayland=enabled --werror + meson compile -C build-gcc-ci + scripts/ci/smoke-test.sh build-gcc-ci + ' | $TARGET diff --git a/scripts/ci/autostart b/scripts/ci/autostart new file mode 100644 index 00000000..1f29a499 --- /dev/null +++ b/scripts/ci/autostart @@ -0,0 +1 @@ +scripts/ci/ci_autostart.sh diff --git a/scripts/ci/ci_autostart.sh b/scripts/ci/ci_autostart.sh new file mode 100755 index 00000000..4aa1c7f9 --- /dev/null +++ b/scripts/ci/ci_autostart.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +if test -z "$LABWC_PID"; then + echo "LABWC_PID not set" >&2 + exit 1 +fi + +echo "Running with pid $LABWC_PID" + +# Could add runtime tests here + +echo "killing labwc" +kill -s TERM $LABWC_PID diff --git a/scripts/ci/smoke-test.sh b/scripts/ci/smoke-test.sh new file mode 100755 index 00000000..89981af6 --- /dev/null +++ b/scripts/ci/smoke-test.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +if ! test -x "$1/labwc"; then + echo "$1/labwc not found" + exit 1 +fi + +args=( + "$1/labwc" + -C scripts/ci + -d +) + +export XDG_RUNTIME_DIR=$(mktemp -d) +export WLR_BACKENDS=headless + +echo "Starting ${args[@]}" +output=$("${args[@]}" 2>&1) +ret=$? + +if test $ret -ge 128; then + # Not using -Db_sanitize=address,undefined + # because it slows down the usual execution + # way too much and spams pages over pages + # of irrelevant memory-still-in-use logs + # for external libraries. + # + # Not using coredumps either because they + # are a pain to setup on GH actions and + # just running labwc again is a lot faster + # anyway. + + echo + echo "labwc crashed, restarting under gdb" + echo + gdb --batch \ + -ex run \ + -ex 'bt full' \ + -ex 'echo \n' \ + -ex 'echo "Local vars:\n' \ + -ex 'info locals' \ + -ex 'echo \n' \ + -ex 'set listsize 50' \ + -ex list \ + --args "${args[@]}" +else + echo "$output" +fi + +echo "labwc terminated with return code $ret" +exit $ret