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 E598F138350 for ; Fri, 27 Mar 2020 23:55:04 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 572CEE0D5C; Fri, 27 Mar 2020 23:54:53 +0000 (UTC) Received: from smtp.gentoo.org (smtp.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 AFABCE0D5C for ; Fri, 27 Mar 2020 23:54:52 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (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 E2F4834F99F for ; Fri, 27 Mar 2020 23:54:51 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 956AC104 for ; Fri, 27 Mar 2020 23:54:48 +0000 (UTC) From: "Sergei Trofimovich" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sergei Trofimovich" Message-ID: <1585353280.ba0d4bc94f655ff82d69276d79f9d85e8e8e01eb.slyfox@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/tests/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/tests/multilib.sh X-VCS-Directories: eclass/tests/ X-VCS-Committer: slyfox X-VCS-Committer-Name: Sergei Trofimovich X-VCS-Revision: ba0d4bc94f655ff82d69276d79f9d85e8e8e01eb X-VCS-Branch: master Date: Fri, 27 Mar 2020 23:54:48 +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: 90445ebc-e834-485d-b5e7-e710ef344063 X-Archives-Hash: b4e145bf28dfea7a471b2772b8e3fdb4 commit: ba0d4bc94f655ff82d69276d79f9d85e8e8e01eb Author: Sergei Trofimovich gentoo org> AuthorDate: Fri Mar 27 23:42:03 2020 +0000 Commit: Sergei Trofimovich gentoo org> CommitDate: Fri Mar 27 23:54:40 2020 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ba0d4bc9 eclass/tests: add basic tests for multilib_env() expansion Signed-off-by: Sergei Trofimovich gentoo.org> eclass/tests/multilib.sh | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/eclass/tests/multilib.sh b/eclass/tests/multilib.sh new file mode 100755 index 00000000000..308c456b98d --- /dev/null +++ b/eclass/tests/multilib.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# Copyright 1999-2020 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +source tests-common.sh + +inherit multilib + +# Run 'multilib_env' and check what variables it expands to +test-multilib_env() { + local target=$1 exp_abi=$2 exp_vars=" $3" + tbegin "expand-target $1" + + # Reset default + unset MULTILIB_ABIS + unset DEFAULT_ABI + CFLAGS_default= + LDFLAGS_default= + LIBDIR_default=lib + CHOST_default=${target} + CTARGET_default=${CHOST_default} + LIBDIR_default=lib + + multilib_env ${target} + + local actual_abi="${DEFAULT_ABI}:${MULTILIB_ABIS}" + + local actual_vars="" + local abi var v + for abi in ${MULTILIB_ABIS}; do + actual_vars+=" ${abi}? (" + for var in CHOST LIBDIR CFLAGS LDFLAGS; do + v=${var}_${abi} + actual_vars+=" ${var}=${!v}" + done + actual_vars+=" )" + done + + [[ "${exp_abi}" == "${actual_abi}" && "${exp_vars}" == "${actual_vars}" ]] + + if ! tend $? ; then + printf '### EXPECTED ABI: %s\n' "${exp_abi}" + printf '### ACTUAL ABI: %s\n' "${actual_abi}" + printf '### EXPECTED VARS: %s\n' "${exp_vars}" + printf '### ACTUAL VARS: %s\n' "${actual_vars}" + fi +} + +# Pick a few interesting gargets from: +# $ grep -h -o -R 'CHOST=.*' ../../profiles/ | sort -u + +test-multilib_env \ + "x86_64-pc-linux-gnu" \ + "amd64:amd64 x86" \ + "amd64? ( CHOST=x86_64-pc-linux-gnu LIBDIR=lib64 CFLAGS=-m64 LDFLAGS= ) x86? ( CHOST=i686-pc-linux-gnu LIBDIR=lib CFLAGS=-m32 LDFLAGS= )" +test-multilib_env \ + "x86_64-pc-linux-gnux32" \ + "x32:x32 amd64 x86" \ + "x32? ( CHOST=x86_64-pc-linux-gnux32 LIBDIR=libx32 CFLAGS=-mx32 LDFLAGS= ) amd64? ( CHOST=x86_64-pc-linux-gnu LIBDIR=lib64 CFLAGS=-m64 LDFLAGS= ) x86? ( CHOST=i686-pc-linux-gnu LIBDIR=lib CFLAGS=-m32 LDFLAGS= )" + +texit