1#!/bin/sh 2# 3# Copyright (C) 2022 Collabora Limited 4# Author: Guilherme Gallo <guilherme.gallo@collabora.com> 5# 6# Permission is hereby granted, free of charge, to any person obtaining a 7# copy of this software and associated documentation files (the "Software"), 8# to deal in the Software without restriction, including without limitation 9# the rights to use, copy, modify, merge, publish, distribute, sublicense, 10# and/or sell copies of the Software, and to permit persons to whom the 11# Software is furnished to do so, subject to the following conditions: 12# 13# The above copyright notice and this permission notice (including the next 14# paragraph) shall be included in all copies or substantial portions of the 15# Software. 16# 17# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23# SOFTWARE. 24 25 26copy_tests_files() ( 27 # Copy either unit test or render test files from a specific driver given by 28 # GPU VERSION variable. 29 # If there is no test file at the expected location, this function will 30 # return error_code 1 31 SKQP_BACKEND="${1}" 32 SKQP_FILE_PREFIX="${INSTALL}/${GPU_VERSION}-skqp" 33 34 if echo "${SKQP_BACKEND}" | grep -qE 'vk|gl(es)?' 35 then 36 SKQP_RENDER_TESTS_FILE="${SKQP_FILE_PREFIX}-${SKQP_BACKEND}_rendertests.txt" 37 [ -f "${SKQP_RENDER_TESTS_FILE}" ] || return 1 38 cp "${SKQP_RENDER_TESTS_FILE}" "${SKQP_ASSETS_DIR}"/skqp/rendertests.txt 39 return 0 40 fi 41 42 # The unittests.txt path is hardcoded inside assets directory, 43 # that is why it needs to be a special case. 44 if echo "${SKQP_BACKEND}" | grep -qE "unitTest" 45 then 46 SKQP_UNIT_TESTS_FILE="${SKQP_FILE_PREFIX}_unittests.txt" 47 [ -f "${SKQP_UNIT_TESTS_FILE}" ] || return 1 48 cp "${SKQP_UNIT_TESTS_FILE}" "${SKQP_ASSETS_DIR}"/skqp/unittests.txt 49 fi 50) 51 52test_vk_backend() { 53 if echo "${SKQP_BACKENDS}" | grep -qE 'vk' 54 then 55 if [ -n "$VK_DRIVER" ]; then 56 return 0 57 fi 58 59 echo "VK_DRIVER environment variable is missing." 60 VK_DRIVERS=$(ls "$INSTALL"/share/vulkan/icd.d/ | cut -f 1 -d '_') 61 if [ -n "${VK_DRIVERS}" ] 62 then 63 echo "Please set VK_DRIVER to the correct driver from the list:" 64 echo "${VK_DRIVERS}" 65 fi 66 echo "No Vulkan tests will be executed, but it was requested in SKQP_BACKENDS variable. Exiting." 67 exit 2 68 fi 69 70 # Vulkan environment is not configured, but it was not requested by the job 71 return 1 72} 73 74setup_backends() { 75 if test_vk_backend 76 then 77 export VK_ICD_FILENAMES="$INSTALL"/share/vulkan/icd.d/"$VK_DRIVER"_icd."${VK_CPU:-$(uname -m)}".json 78 fi 79} 80 81set -ex 82 83# Needed so configuration files can contain paths to files in /install 84ln -sf "$CI_PROJECT_DIR"/install /install 85INSTALL=${PWD}/install 86 87if [ -z "$GPU_VERSION" ]; then 88 echo 'GPU_VERSION must be set to something like "llvmpipe" or 89"freedreno-a630" (it will serve as a component to find the path for files 90residing in src/**/ci/*.txt)' 91 exit 1 92fi 93 94LD_LIBRARY_PATH=$INSTALL:$LD_LIBRARY_PATH 95setup_backends 96 97SKQP_ASSETS_DIR=/skqp/assets 98SKQP_RESULTS_DIR="${SKQP_RESULTS_DIR:-$PWD/results}" 99 100mkdir -p "${SKQP_ASSETS_DIR}"/skqp 101 102SKQP_EXITCODE=0 103for SKQP_BACKEND in ${SKQP_BACKENDS} 104do 105 set -e 106 if ! copy_tests_files "${SKQP_BACKEND}" 107 then 108 echo "No override test file found for ${SKQP_BACKEND}. Using the default one." 109 fi 110 111 set +e 112 SKQP_BACKEND_RESULTS_DIR="${SKQP_RESULTS_DIR}"/"${SKQP_BACKEND}" 113 mkdir -p "${SKQP_BACKEND_RESULTS_DIR}" 114 /skqp/skqp "${SKQP_ASSETS_DIR}" "${SKQP_BACKEND_RESULTS_DIR}" "${SKQP_BACKEND}_" 115 BACKEND_EXITCODE=$? 116 117 if [ ! $BACKEND_EXITCODE -eq 0 ] 118 then 119 echo "skqp failed on ${SKQP_BACKEND} tests with ${BACKEND_EXITCODE} exit code." 120 fi 121 122 # Propagate error codes to leverage the final job result 123 SKQP_EXITCODE=$(( SKQP_EXITCODE | BACKEND_EXITCODE )) 124done 125 126set +x 127 128# Unit tests produce empty HTML reports, guide the user to check the TXT file. 129if echo "${SKQP_BACKENDS}" | grep -qE "unitTest" 130then 131 # Remove the empty HTML report to avoid confusion 132 rm -f "${SKQP_RESULTS_DIR}"/unitTest/report.html 133 134 echo "See skqp unit test results at:" 135 echo "https://$CI_PROJECT_ROOT_NAMESPACE.pages.freedesktop.org/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/${SKQP_RESULTS_DIR}/unitTest/unit_tests.txt" 136fi 137 138REPORT_FILES=$(mktemp) 139find "${SKQP_RESULTS_DIR}"/**/report.html -type f > "${REPORT_FILES}" 140while read -r REPORT 141do 142 BACKEND_NAME=$(echo "${REPORT}" | sed 's@.*/\([^/]*\)/report.html@\1@') 143 echo "See skqp ${BACKEND_NAME} render tests report at:" 144 echo "https://$CI_PROJECT_ROOT_NAMESPACE.pages.freedesktop.org/-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/${REPORT}" 145done < "${REPORT_FILES}" 146 147# If there is no report available, tell the user that something is wrong. 148if [ ! -s "${REPORT_FILES}" ] 149then 150 echo "No skqp report available. Probably some fatal error has occured during the skqp execution." 151fi 152 153exit $SKQP_EXITCODE 154