From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id DE9681382C5 for ; Thu, 28 May 2020 11:41:32 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 0036FE0839; Thu, 28 May 2020 11:41:31 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id AD33DE081E for ; Thu, 28 May 2020 11:41:31 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 8871634EF25 for ; Thu, 28 May 2020 11:41:30 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 66DC8268 for ; Thu, 28 May 2020 11:41:27 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1590666080.dba4f2113f6cfa539246acdad25459a479d7f434.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/tests/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/tests/llvm.sh X-VCS-Directories: eclass/tests/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: dba4f2113f6cfa539246acdad25459a479d7f434 X-VCS-Branch: master Date: Thu, 28 May 2020 11:41:27 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 4d36fff2-1d16-4905-91fa-f42e198a9a46 X-Archives-Hash: 85ac61b70f33816ef944f003aef4a423 commit: dba4f2113f6cfa539246acdad25459a479d7f434 Author: Michał Górny gentoo org> AuthorDate: Tue May 26 07:25:56 2020 +0000 Commit: Michał Górny gentoo org> CommitDate: Thu May 28 11:41:20 2020 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dba4f211 llvm.eclass: Add initial tests Signed-off-by: Michał Górny gentoo.org> eclass/tests/llvm.sh | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/eclass/tests/llvm.sh b/eclass/tests/llvm.sh new file mode 100755 index 00000000000..bb8d5fc998e --- /dev/null +++ b/eclass/tests/llvm.sh @@ -0,0 +1,138 @@ +#!/bin/bash +# Copyright 1999-2020 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 +source tests-common.sh + +inherit llvm + +# llvm_check_deps override to disable has_version use. +# in: ${LLVM_SLOT} +# returns 0 if installed (i.e. == LLVM_INSTALLED_SLOT), 1 otherwise +llvm_check_deps() { + [[ ${LLVM_SLOT} == ${LLVM_INSTALLED_SLOT} ]] +} + +# check_prefix [...] +# Check output of `get_llvm_prefix ...`. +check_prefix() { + local expected=${1} + shift + + tbegin "get_llvm_prefix ${*}; inst=${LLVM_INSTALLED_SLOT} -> ${expected}" + prefix=$(get_llvm_prefix "${@}") + [[ ${prefix} == ${expected} ]] || + eerror "got: ${prefix} != exp: ${expected}" + tend ${?} +} + +# check_setup_path +# Check PATH after pkg_setup. +check_setup_path() { + local expected=${1} + shift + + tbegin "pkg_setup; max=${LLVM_MAX_SLOT}; inst=${LLVM_INSTALLED_SLOT} -> PATH=${expected}" + path=$(llvm_pkg_setup; echo "${PATH}") + [[ ${path} == ${expected} ]] || + eerror "got: ${path} != exp: ${expected}" + tend ${?} +} + + +EAPI=7 +BROOT=/broot +SYSROOT=/sysroot +ESYSROOT=/sysroot/eprefix +ROOT=/root +EROOT=/root/eprefix + +ebegin "Testing check_setup_path without max slot" +eindent + LLVM_INSTALLED_SLOT=11 \ + check_prefix /sysroot/eprefix/usr/lib/llvm/11 + LLVM_INSTALLED_SLOT=10 \ + check_prefix /sysroot/eprefix/usr/lib/llvm/10 +eoutdent + +ebegin "Testing check_setup_path with max slot" +eindent + LLVM_INSTALLED_SLOT=1* \ + check_prefix /sysroot/eprefix/usr/lib/llvm/11 11 + LLVM_INSTALLED_SLOT=1* \ + check_prefix /sysroot/eprefix/usr/lib/llvm/10 10 + LLVM_INSTALLED_SLOT=10 \ + check_prefix /sysroot/eprefix/usr/lib/llvm/10 11 +eoutdent + +ebegin "Testing check_setup_path option switches" +eindent + LLVM_INSTALLED_SLOT=11 \ + check_prefix /broot/usr/lib/llvm/11 -b + LLVM_INSTALLED_SLOT=11 \ + check_prefix /sysroot/eprefix/usr/lib/llvm/11 -d +eoutdent + +ebegin "Testing check_setup_path EAPI 6 API" +eindent + EAPI=6 \ + LLVM_INSTALLED_SLOT=11 \ + check_prefix /usr/lib/llvm/11 -d +eoutdent + +BASEPATH=/usr/lib/ccache/bin:/usr/bin:/usr/sbin:/bin:/sbin + +# TODO: cross support? +ESYSROOT= + +ebegin "Testing pkg_setup with all installed LLVM versions in PATH" +eindent + LLVM_MAX_SLOT=11 \ + LLVM_INSTALLED_SLOT=1* \ + PATH=${BASEPATH}:/usr/lib/llvm/11/bin \ + check_setup_path "/usr/lib/llvm/11/bin:${BASEPATH}:/usr/lib/llvm/11/bin" + + LLVM_MAX_SLOT=10 \ + LLVM_INSTALLED_SLOT=1* \ + PATH=${BASEPATH}:/usr/lib/llvm/11/bin:/usr/lib/llvm/10/bin \ + check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}:/usr/lib/llvm/11/bin:/usr/lib/llvm/10/bin" + + LLVM_MAX_SLOT=11 \ + LLVM_INSTALLED_SLOT=10 \ + PATH=${BASEPATH}:/usr/lib/llvm/10/bin \ + check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}:/usr/lib/llvm/10/bin" +eoutdent + +ebegin "Testing pkg_setup with the other LLVM version in PATH" +eindent + LLVM_MAX_SLOT=11 \ + LLVM_INSTALLED_SLOT=1* \ + PATH=${BASEPATH}:/usr/lib/llvm/10/bin \ + check_setup_path "/usr/lib/llvm/11/bin:${BASEPATH}:/usr/lib/llvm/10/bin" + + LLVM_MAX_SLOT=10 \ + LLVM_INSTALLED_SLOT=1* \ + PATH=${BASEPATH}:/usr/lib/llvm/11/bin \ + check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}:/usr/lib/llvm/11/bin" +eoutdent + +ebegin "Testing pkg_setup with LLVM missing from PATH" +eindent + LLVM_MAX_SLOT=11 \ + LLVM_INSTALLED_SLOT=1* \ + PATH=${BASEPATH} \ + check_setup_path "/usr/lib/llvm/11/bin:${BASEPATH}" + + LLVM_MAX_SLOT=10 \ + LLVM_INSTALLED_SLOT=1* \ + PATH=${BASEPATH} \ + check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}" + + LLVM_MAX_SLOT=11 \ + LLVM_INSTALLED_SLOT=10 \ + PATH=${BASEPATH} \ + check_setup_path "/usr/lib/llvm/10/bin:${BASEPATH}" +eoutdent + +texit