From 69e01f2650fb9a0296a277173ba47ea4986c575f Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Tue, 9 Oct 2018 14:07:11 +0200 Subject: [PATCH] CI: Add scripts to be able to enable the CI Define a CI run withing a specified docker image that uses pre-defined versions of mesa, libdrm, and VK-GL_CTS. The gitlab CI file .gitlab-ci.yml has been placed under ci/ in order to avoid enabling the Ci automatically. If the host provides a render device /dev/dri/render128D then forward this device, use it as host device and run the dEQP GLES 2, 3, and 3.1 test suites as well as piglit by using vtest, a GL and a GLES host context. If this device is not available use the llvmpipe driver as host device and run only dQEP GLES 2 with the GL and GLES host contexts. The initial work for getting the CI running on normal hardware drivers has been done by Tomeu Vizoso and Jakob Bornecrantz Getting it to work with the llvmpipe host context was done by Gert Wollny Signed-off-by: Gert Wollny Reviewed-by: Gurchetan Singh Signed-off-by: Dave Airlie --- ci/.gitlab-ci.yml | 43 ++++++++++++ ci/Dockerfile | 162 ++++++++++++++++++++++++++++++++++++++++++ ci/TODO | 7 ++ ci/run-deqp.sh | 174 ++++++++++++++++++++++++++++++++++++++++++++++ ci/run-tests.sh | 82 ++++++++++++++++++++++ 5 files changed, 468 insertions(+) create mode 100644 ci/.gitlab-ci.yml create mode 100644 ci/Dockerfile create mode 100644 ci/TODO create mode 100755 ci/run-deqp.sh create mode 100755 ci/run-tests.sh diff --git a/ci/.gitlab-ci.yml b/ci/.gitlab-ci.yml new file mode 100644 index 0000000..4e9da55 --- /dev/null +++ b/ci/.gitlab-ci.yml @@ -0,0 +1,43 @@ +image: docker:latest + +cache: + paths: + - ccache + +variables: + DOCKER_DRIVER: overlay2 + RENDER_DEVICE: /dev/dri/renderD128 +stages: + - build_and_test + +build_and_test: + stage: build_and_test + services: + - docker:dind + before_script: + - mkdir -p ccache + - mkdir -p results + script: + - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY + - time docker pull $CI_REGISTRY_IMAGE:latest || true + + - time docker build -t $CI_REGISTRY_IMAGE --cache-from $CI_REGISTRY_IMAGE:latest ci + - docker history $CI_REGISTRY_IMAGE:latest + + - time docker push $CI_REGISTRY_IMAGE:latest + + - echo core > /proc/sys/kernel/core_pattern + - echo 0 > /proc/sys/kernel/core_uses_pid + - if test -e $RENDER_DEVICE; then RD_CONFIG="--device=$RENDER_DEVICE"; fi + - echo RD_CONFIG=$RD_CONFIG + - time docker run + --ulimit core=99999999999:99999999999 + $RD_CONFIG + -v $PWD:/virglrenderer + $CI_REGISTRY_IMAGE:latest + /virglrenderer/ci/run-tests.sh 2>&1 | tee results/log.txt + + artifacts: + when: always + paths: + - results/ diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 0000000..a13dfb1 --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,162 @@ +FROM debian:testing-slim + +ENV DEBIAN_FRONTEND=noninteractive +ENV GOPATH=/usr/local/go +ENV PATH=$PATH:/usr/local/go/bin +ENV LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu +ENV PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/local/share/pkgconfig:/usr/local/lib/x86_64-linux-gnu/pkgconfig +ENV LDFLAGS="-L/usr/local/lib64 -L/usr/local/lib/ -L/usr/local/lib/x86_64-linux-gnu" +ENV CFLAGS="-g0" +ENV CXXFLAGS="-g0" +ENV GIT_DATE="`date +%Y-%m-%d -d \"1 year ago\"`" + +RUN echo 'path-exclude=/usr/share/doc/*' > /etc/dpkg/dpkg.cfg.d/99-exclude-cruft +RUN echo 'path-exclude=/usr/share/man/*' >> /etc/dpkg/dpkg.cfg.d/99-exclude-cruft +RUN echo '#!/bin/sh' > /usr/sbin/policy-rc.d +RUN echo 'exit 101' >> /usr/sbin/policy-rc.d +RUN chmod +x /usr/sbin/policy-rc.d + +RUN echo deb-src http://deb.debian.org/debian unstable main >> /etc/apt/sources.list +RUN apt-get update && \ + apt-get -y install ca-certificates && \ + apt-get -y install --no-install-recommends \ + libgbm-dev \ + libxvmc-dev \ + autoconf \ + golang-go \ + cmake \ + spirv-headers \ + xinit \ + check \ + linux-image-amd64 \ + git \ + procps \ + systemd \ + libnss-systemd \ + dbus \ + strace \ + systemd-coredump \ + time \ + busybox \ + kbd \ + ccache \ + xserver-xorg-core \ + xterm \ + wget \ + gdc-6 \ + clang-6.0 \ + lld-6.0 \ + nasm \ + waffle-utils \ + gdb \ + libcurl4-openssl-dev \ + xvfb \ + mesa-utils \ + strace \ + psmisc \ + libpng-dev \ + libxrandr-dev \ + libsm-dev \ + meson \ + ninja-build \ + zlib1g-dev \ + libwayland-dev \ + libwayland-egl-backend-dev && \ + apt-get -y build-dep --no-install-recommends \ + qemu \ + libdrm \ + mesa \ + virglrenderer \ + libepoxy \ + piglit && \ + apt-get -y remove valgrind && \ + apt-get clean + +ARG KNOWN_GOOD_FAKEMACHINE=c4752ddf3343 +RUN go get -v github.com/tomeuv/fakemachine/cmd/fakemachine +RUN go install -x github.com/tomeuv/fakemachine/cmd/fakemachine + +# To avoid this error: +# error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function. +RUN git config --global http.postBuffer 1048576000 + +ARG KNOWN_GOOD_EPOXY=737b6918703c +WORKDIR /libepoxy +RUN git clone --shallow-since="$GIT_DATE" https://github.com/anholt/libepoxy.git . && \ + git checkout ${KNOWN_GOOD_EPOXY} && \ + git log --oneline -n 1 && \ + ./autogen.sh --prefix=/usr/local && \ + make -j$(nproc) install && \ + rm -rf /libepoxy +WORKDIR / + +ARG KNOWN_GOOD_CTS=fd68124a565e +WORKDIR /VK-GL-CTS +RUN git clone --shallow-since="$GIT_DATE" https://github.com/KhronosGroup/VK-GL-CTS.git . && \ + git checkout ${KNOWN_GOOD_CTS} && \ + git log --oneline -n 1 && \ + mkdir build && \ + cd build && \ + cmake -DDEQP_TARGET=x11_egl -DCMAKE_BUILD_TYPE=Release .. && \ + make -j$(nproc) && \ + find . -name CMakeFiles | xargs rm -rf && \ + find . -name lib\*.a | xargs rm -rf && \ + mv /VK-GL-CTS/build /usr/local/VK-GL-CTS && \ + rm -rf /VK-GL-CTS +WORKDIR / + +ARG KNOWN_GOOD_PIGLIT=1a2f49f17fb45 +WORKDIR /piglit +RUN git clone --shallow-since="$GIT_DATE" https://gitlab.freedesktop.org/mesa/piglit.git . && \ + git checkout ${KNOWN_GOOD_PIGLIT} && \ + git log --oneline -n 1 && \ + cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release . && \ + make -j$(nproc) install && \ + rm -rf /usr/local/lib/piglit/generated_tests/spec/arb_vertex_attrib_64bit && \ + rm -rf /usr/local/lib/piglit/generated_tests/spec/glsl-4.20 && \ + rm -rf /piglit +WORKDIR / + +WORKDIR /battery +RUN wget https://github.com/VoltLang/Battery/releases/download/v0.1.18/battery-0.1.18-x86_64-linux.tar.gz && \ + tar xzvf battery-0.1.18-x86_64-linux.tar.gz && \ + rm battery-0.1.18-x86_64-linux.tar.gz && \ + mv battery /usr/local/bin +WORKDIR / + +WORKDIR /volt +RUN git clone --depth=1 https://github.com/VoltLang/Watt.git && \ + git clone --depth=1 https://github.com/VoltLang/Volta.git && \ + git clone --depth=1 https://github.com/Wallbraker/dEQP.git && \ + battery config --release --lto Volta Watt && \ + battery build && \ + battery config --cmd-volta Volta/volta Volta/rt Watt dEQP && \ + battery build && \ + cp dEQP/deqp /usr/local/bin && \ + rm -rf /volt +WORKDIR / + +ARG KNOWN_GOOD_DRM=4ec31fc31a4be909c8204164c844b4a18f098af7 +WORKDIR /drm +RUN git clone --shallow-since="$GIT_DATE" https://gitlab.freedesktop.org/mesa/drm.git . && \ + git checkout ${KNOWN_GOOD_DRM} && \ + git log --oneline -n 1 && \ + mkdir -p build && \ + meson build/ && \ + meson configure build/ -Dprefix=/usr/local -Dlibdir=lib && \ + ninja -C build/ install && \ + rm -rf /drm +WORKDIR / + +ARG KNOWN_GOOD_MESA=d877451b48a59ab0f9a4210fc736f51da5851c9a +WORKDIR /mesa +RUN git clone --shallow-since="$GIT_DATE" https://gitlab.freedesktop.org/mesa/mesa.git . && \ + git checkout ${KNOWN_GOOD_MESA} && \ + git log --oneline -n 1 && \ + mkdir -p build && \ + meson build/ && \ + meson configure build/ -Dprefix=/usr/local -Dplatforms=drm,x11,wayland,surfaceless -Ddri-drivers=i965 -Dgallium-drivers=swrast,virgl,radeonsi,r600 -Dbuildtype=debugoptimized -Dllvm=true -Dglx=dri -Dgallium-vdpau=false -Dgallium-va=false -Dvulkan-drivers=[] -Dlibdir=lib && \ + ninja -C build/ install && \ + rm -rf /mesa +WORKDIR / + diff --git a/ci/TODO b/ci/TODO new file mode 100644 index 0000000..721f448 --- /dev/null +++ b/ci/TODO @@ -0,0 +1,7 @@ +- Investigate using vtest instead of the full stack +- Run static checkers (syntax and maybe others) +- Run Valgrind +- Run fuzzers +- Run weston in the guest (as a systemd service) instead of X +- Run performance tests +- Publish results diff --git a/ci/run-deqp.sh b/ci/run-deqp.sh new file mode 100755 index 0000000..913503f --- /dev/null +++ b/ci/run-deqp.sh @@ -0,0 +1,174 @@ +#!/bin/bash + +set -x + +ONLY_GLES2=no + +for arg +do + case "$arg" in + --with-vtest) + WITH_VTEST=1 + ;; + --host-gl) + HOST_GL=1 + ;; + --only-gles2) + ONLY_GLES2=yes + ;; + *) + echo "Unknown argument" + exit 1 + ;; + esac +done + +export PATH=$PATH:/usr/local/go/bin +export LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu +#export MESA_GLES_VERSION_OVERRIDE=3.1 + +if [[ -n "$HOST_GL" ]]; then + echo "Running tests with GL on the host" +else + echo "Running tests with GLES on the host" +fi + +if [[ -n $WITH_VTEST ]]; then + nohup Xvfb :0 -screen 0 1024x768x24 & +else + startx & +fi + +sleep 3 +export DISPLAY=:0 + +if [[ -n "$LIBGL_ALWAYS_SOFTWARE" ]]; then + HOST_GALLIUM_DRIVER="_${GALLIUM_DRIVER}" +fi + +if [[ -n "$WITH_VTEST" ]]; then + if [[ -n "$HOST_GL" ]]; then + VTEST_USE_EGL_SURFACELESS=1 nohup /virglrenderer/vtest/virgl_test_server 2> /dev/null & + else + VTEST_USE_EGL_SURFACELESS=1 VTEST_USE_GLES=1 nohup /virglrenderer/vtest/virgl_test_server 2> /dev/null & + fi + + sleep 1 + + export LIBGL_ALWAYS_SOFTWARE=true + export GALLIUM_DRIVER=virpipe +fi + +NUM_JOBS=$(expr $(nproc) + 4) + +if [[ -n "$HOST_GL" ]]; then + RESULTS_DIR=/virglrenderer/results/gl_host${HOST_GALLIUM_DRIVER} + PREVIOUS_RESULTS_DIR=/virglrenderer/ci/previous_results/gl_host${HOST_GALLIUM_DRIVER} +else + RESULTS_DIR=/virglrenderer/results/es_host${HOST_GALLIUM_DRIVER} + PREVIOUS_RESULTS_DIR=/virglrenderer/ci/previous_results/es_host${HOST_GALLIUM_DRIVER} +fi +mkdir -p $RESULTS_DIR + + +: ' +cd /usr/local/VK-GL-CTS/modules/gles2 +MESA_DEBUG=1 ./deqp-gles2 --deqp-case=dEQP-GLES2.functional.shaders.preprocessor.semantic.correct_order_fragment +cp TestResults.qpa /virglrenderer/results/. +exit +' + +if [[ "x$ONLY_GLES2"="xyes" ]] ; then + export HOST_GALLIUM_DRIVER="-${GALLIUM_DRIVER}" + time deqp --threads=$NUM_JOBS \ + --cts-build-dir=/usr/local/VK-GL-CTS/ \ + --test-names-file=/virglrenderer/ci/deqp-gles2-list.txt \ + --print-failing \ + --results-file=$RESULTS_DIR/deqp_results.txt +else + time deqp --threads=$NUM_JOBS \ + --cts-build-dir=/usr/local/VK-GL-CTS/ \ + --test-names-file=/virglrenderer/ci/deqp-gles2-list.txt \ + --test-names-file=/virglrenderer/ci/deqp-gles3-list.txt \ + --test-names-file=/virglrenderer/ci/deqp-gles31-list.txt \ + --print-failing \ + --results-file=$RESULTS_DIR/deqp_results.txt +fi +cp -rf /tmp/dEQP/* $RESULTS_DIR/. + +# Remove header +sed -i "/#/d" $RESULTS_DIR/deqp_results.txt + +# TODO: These tests are not reliable when run on radeonsi, someone should fix them and then remove these lines +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES3.functional.fbo.msaa.2_samples.rgb8" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES3.functional.fbo.msaa.4_samples.rgb8" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES3.functional.fbo.msaa.8_samples.rgb8" + +# TODO: These tests aren't reliable either +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.singlesample_texture" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_texture_1" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_texture_2" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_texture_4" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_texture_8" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.singlesample_rbo" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_rbo_1" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_rbo_2" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_rbo_4" +FLIP_FLOPS="$FLIP_FLOPS dEQP-GLES31.functional.shaders.sample_variables.sample_pos.correctness.multisample_rbo_8" + +for TEST_NAME in $FLIP_FLOPS; do + sed -i "\:$TEST_NAME:d" $RESULTS_DIR/deqp_results.txt $PREVIOUS_RESULTS_DIR/deqp_results.txt +done + +# These warnings add too much variability +sed -i "s/QualityWarning/Pass/g" $RESULTS_DIR/deqp_results.txt $PREVIOUS_RESULTS_DIR/deqp_results.txt +sed -i "s/CompatibilityWarning/Pass/g" $RESULTS_DIR/deqp_results.txt $PREVIOUS_RESULTS_DIR/deqp_results.txt + +diff -u $PREVIOUS_RESULTS_DIR/deqp_results.txt $RESULTS_DIR/deqp_results.txt +if [ $? -ne 0 ]; then + touch /virglrenderer/results/regressions_detected +fi + + +if [[ "x$ONLY_GLES2" != "xyes" ]] ; then + + PIGLIT_TESTS="-x glx" + if [[ -z "$HOST_GL" ]]; then + PIGLIT_TESTS="$PIGLIT_TESTS -t gles2 -t gles3" + fi + + # Hits this assertion on i965: + # compiler/brw_fs_visitor.cpp:444: void fs_visitor::emit_fb_writes(): Assertion `!prog_data->dual_src_blend || key->nr_color_regions == 1` failed + PIGLIT_TESTS="$PIGLIT_TESTS -x arb_blend_func_extended-fbo-extended-blend-pattern_gles2" + + time piglit run --platform x11_egl \ + --jobs $NUM_JOBS \ + $PIGLIT_TESTS \ + gpu \ + $RESULTS_DIR/piglit + + piglit summary console $RESULTS_DIR/piglit | head -n -17 > $RESULTS_DIR/piglit/results.txt + + # TODO: These tests are not reliable when run on radeonsi, someone should fix them and then remove these lines + FLIP_FLOPS="$FLIP_FLOPS spec/arb_framebuffer_srgb/blit renderbuffer srgb_to_linear downsample enabled clear" + FLIP_FLOPS="$FLIP_FLOPS spec/arb_framebuffer_srgb/blit texture srgb_to_linear msaa enabled clear" + FLIP_FLOPS="$FLIP_FLOPS spec/arb_shader_image_load_store/shader-mem-barrier/fragment shader/'volatile' qualifier memory barrier test/modulus=" + FLIP_FLOPS="$FLIP_FLOPS spec/arb_shader_image_load_store/shader-mem-barrier/fragment shader/'coherent' qualifier memory barrier test/modulus=" + FLIP_FLOPS="$FLIP_FLOPS spec/arb_shader_image_load_store/shader-mem-barrier/tessellation control shader/'volatile' qualifier memory barrier test/modulus=" + FLIP_FLOPS="$FLIP_FLOPS spec/arb_shader_image_load_store/shader-mem-barrier/tessellation control shader/'coherent' qualifier memory barrier test/modulus=" + FLIP_FLOPS="$FLIP_FLOPS spec/ext_transform_instanced/draw-auto instanced" + for TEST_NAME in $FLIP_FLOPS; do + sed -i "\:$TEST_NAME:d" $RESULTS_DIR/piglit/results.txt + sed -i "\:$TEST_NAME:d" $PREVIOUS_RESULTS_DIR/piglit_results.txt + done + + diff -u $PREVIOUS_RESULTS_DIR/piglit_results.txt $RESULTS_DIR/piglit/results.txt + if [ $? -ne 0 ]; then + touch /virglrenderer/results/regressions_detected + fi + +fi + +cp /var/log/Xorg.0.log /virglrenderer/results/. + +killall virgl_test_server diff --git a/ci/run-tests.sh b/ci/run-tests.sh new file mode 100755 index 0000000..1ef0e77 --- /dev/null +++ b/ci/run-tests.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +set -x + +#DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends ninja-build meson + +# To prevent hitting assertions such as the below: +# sb/sb_sched.cpp:1207:schedule_alu: Assertion `!"unscheduled pending instructions"' failed. +export R600_DEBUG=nosb + +export CCACHE_BASEDIR=/virglrenderer +export CCACHE_DIR=/virglrenderer/ccache +export PATH="/usr/lib/ccache:$PATH" +mkdir -p $CCACHE_DIR +ccache -s + + +if [[ ! -c /dev/dri/renderD128 ]]; then + export LIBGL_ALWAYS_SOFTWARE=1 + export GALLIVM_PERF=no_filter_hacks + export GALLIUM_DRIVER=llvmpipe + LIMIT_TESTSET=--only-gles2 +fi + +cd /virglrenderer +if [[ ! $LOCAL_DEV ]]; then + ./autogen.sh --prefix=/usr/local --enable-debug --enable-tests + VRENDTEST_USE_EGL_SURFACELESS=1 make distcheck + if [ $? -ne 0 ]; then + touch /virglrenderer/results/regressions_detected + cp virglrenderer-0.7.0/_build/sub/tests/*.log /virglrenderer/results/ + fi +fi +make -j$(nproc) install + +if [[ $LOCAL_DEV ]]; then + cd /mesa + mkdir -p build + meson build/ + meson configure build/ -Dprefix=/usr/local -Dplatforms=drm,x11,wayland,surfaceless -Ddri-drivers=i965 -Dgallium-drivers=swrast,virgl,radeonsi,r600 -Dbuildtype=debugoptimized -Dllvm=true -Dglx=dri -Dgallium-vdpau=false -Dgallium-va=false -Dvulkan-drivers=[] -Dlibdir=lib + ninja -C build/ install +fi + +: ' +cd /qemu +make -j$(nproc) install +' + +: ' +cd /VK-GL-CTS/build +#cmake -DDEQP_TARGET=x11_egl -DCMAKE_BUILD_TYPE=Release .. +make -j$(nproc) +cp -rf * /usr/local/VK-GL-CTS/. +' + +ccache -s + +: ' +ln -s /usr/local/bin/qemu-system-x86_64 /usr/bin/qemu-system-x86_64 +echo "Starting guest for ES" +mkdir -p /virglrenderer/results/es_host +rm -f core + +fakemachine --qemuopts="-vga virtio -display egl-headless,gl=es" \ + --show-boot \ + --memory=8192 \ + -v /virglrenderer:/virglrenderer \ + -v /virglrenderer/results/es_host:/results \ + -- /virglrenderer/ci/run-deqp.sh +' + +# Cut this short if the unit tests fail + +if [ ! -f /virglrenderer/results/regressions_detected ]; then + /virglrenderer/ci/run-deqp.sh --with-vtest $LIMIT_TESTSET + /virglrenderer/ci/run-deqp.sh --host-gl --with-vtest $LIMIT_TESTSET +fi + +if [ -f /virglrenderer/results/regressions_detected ]; then + exit 1 +fi +