2020-06-03 16:02:34 +03:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# folders that are necessary to run Weston tests
|
|
|
|
mkdir -p /tmp/tests
|
|
|
|
mkdir -p /tmp/.X11-unix
|
|
|
|
chmod -R 0700 /tmp
|
|
|
|
|
|
|
|
# set environment variables to run Weston tests
|
|
|
|
export XDG_RUNTIME_DIR=/tmp/tests
|
2021-04-15 23:38:06 +03:00
|
|
|
export LIBSEAT_BACKEND=seatd
|
2022-02-08 03:26:59 +03:00
|
|
|
# In our test suite, we use VKMS to run DRM-backend tests. The order in which
|
|
|
|
# devices are loaded is not predictable, so the DRM node that VKMS takes can
|
|
|
|
# change across each boot. That's why we have this one-liner shell script to get
|
|
|
|
# the appropriate node for VKMS.
|
|
|
|
export WESTON_TEST_SUITE_DRM_DEVICE=$(basename /sys/devices/platform/vkms/drm/card*)
|
|
|
|
# To run tests in the CI that exercise the zwp_linux_dmabuf_v1 implementation in
|
|
|
|
# Weston, we use VGEM to allocate buffers.
|
|
|
|
export WESTON_TEST_SUITE_ALLOC_DEVICE=$(basename /sys/devices/platform/vgem/drm/card*)
|
2020-06-03 16:02:34 +03:00
|
|
|
|
|
|
|
# ninja test depends on meson, and meson itself looks for its modules on folder
|
|
|
|
# $HOME/.local/lib/pythonX.Y/site-packages (the Python version may differ).
|
2021-09-12 14:49:12 +03:00
|
|
|
# build-deps.sh installs dependencies to /usr/local.
|
2020-06-03 16:02:34 +03:00
|
|
|
# virtme starts with HOME=/tmp/roothome, but as we installed meson on user root,
|
|
|
|
# meson can not find its modules. So we change the HOME env var to fix that.
|
|
|
|
export HOME=/root
|
2021-05-17 14:19:26 +03:00
|
|
|
export PATH=$HOME/.local/bin:$PATH
|
2021-09-12 14:49:12 +03:00
|
|
|
export PATH=/usr/local/bin:$PATH
|
2021-04-15 23:38:06 +03:00
|
|
|
|
2021-11-29 21:41:20 +03:00
|
|
|
export SEATD_LOGLEVEL=debug
|
2021-09-13 12:11:39 +03:00
|
|
|
|
CI: Never unload llvmpipe DSO whilst testing
This commit is truly horrible.
We want to run ASan with leak checking enabled in CI so we can catch
memory leaks before they're introduced. This works well with Pixman, and
with NIR-only drivers like iris or Panfrost.
But when we run under llvmpipe - which we do under CI - we start failing
because:
- Mesa pulls in llvmpipe via dlopen
- llvmpipe pulls in LLVM itself via DT_NEEDED
- initialising LLVM's global type/etc systems performs thread-local
allocations
- llvmpipe can't free those allocations since the application might
also be using LLVM
- Weston stops using GL and destroys all GL objects, leading to Mesa
unloading llvmpipe like it should
- with everything disappearing from the process's vmap, ASan can no
longer keep track of still-reachable pointers
- tests fail because LLVM is 'leaking'
Usually, an alternative is to LD_PRELOAD a shim which overrides
dlclose() to be a no-op. This is not usable here, because when
$LD_PRELOAD is not empty and ASan is not first in it, ASan immediately
errors out. Prepending ASan doesn't work, because we run our tests
through Meson (which also invokes Ninja), leading to LSan exploding
over CPython and Ninja, which is not what we're interested in.
It would be possible to inject _both_ ASan and a dlclose-does-nothing
shim DSO into the LD_PRELOAD environment for every test, but that seems
even worse, especially as Meson strongly discourages globbing for random
files in the root.
So, here we are, doing what we can: finding where swrast_dri.so (aka
llvmpipe) lives, stashing that in an environment variable, and
deliberately leaking a dlopen handle which we never close to ensure that
neither llvmpipe nor LLVM leave our process's address space before we
exit.
Signed-off-by: Daniel Stone <daniels@collabora.com>
2022-06-25 06:59:52 +03:00
|
|
|
# Terrible hack, per comment in weston-test-runner.c's main(): find Mesa's
|
|
|
|
# llvmpipe driver module location
|
|
|
|
export WESTON_CI_LEAK_DL_HANDLE=$(find /usr/local -name swrast_dri.so -print 2>/dev/null || true)
|
|
|
|
|
2020-06-03 16:02:34 +03:00
|
|
|
# run the tests and save the exit status
|
2021-05-17 14:19:26 +03:00
|
|
|
# we give ourselves a very generous timeout multiplier due to ASan overhead
|
2021-11-29 21:41:20 +03:00
|
|
|
echo 0x1f > /sys/module/drm/parameters/debug
|
2022-06-25 21:53:41 +03:00
|
|
|
seatd-launch -- meson test --no-rebuild --timeout-multiplier 4 \
|
|
|
|
--wrapper $(pwd)/../.gitlab-ci/virtme-scripts/per-test-asan.sh
|
2021-12-13 14:45:36 +03:00
|
|
|
# note that we need to store the return value from the tests in order to
|
|
|
|
# determine if the test suite ran successfully or not.
|
|
|
|
TEST_RES=$?
|
2021-11-29 21:41:20 +03:00
|
|
|
dmesg &> dmesg.log
|
|
|
|
echo 0x00 > /sys/module/drm/parameters/debug
|
2020-06-03 16:02:34 +03:00
|
|
|
|
|
|
|
# create a file to keep the result of this script:
|
|
|
|
# - 0 means the script succeeded
|
|
|
|
# - 1 means the tests failed, so the job itself should fail
|
|
|
|
TESTS_RES_PATH=$(pwd)/tests-res.txt
|
|
|
|
echo $TEST_RES > $TESTS_RES_PATH
|
|
|
|
|
|
|
|
# shutdown virtme
|
|
|
|
sync
|
|
|
|
poweroff -f
|