public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: sys-libs/netbsd-csu/
Date: Wed, 14 Jun 2017 17:04:33 +0000 (UTC)	[thread overview]
Message-ID: <1497459868.437e37bbdbaa7623f9efda4464818568f5ea1e01.mgorny@gentoo> (raw)

commit:     437e37bbdbaa7623f9efda4464818568f5ea1e01
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 14 13:41:22 2017 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Jun 14 17:04:28 2017 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=437e37bb

sys-libs/netbsd-csu: Add a self-test phase

 sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild | 64 +++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild b/sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild
index 9586ae34bed..bacdd60d24f 100644
--- a/sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild
+++ b/sys-libs/netbsd-csu/netbsd-csu-7.1.ebuild
@@ -59,6 +59,70 @@ multilib_src_compile() {
 	bsdmk_src_compile "${opts[@]}"
 }
 
+multilib_src_test() {
+	local cc=(
+		# -B sets prefix for internal gcc/clang file lookup
+		$(tc-getCC) -B"${BUILD_DIR}"
+	)
+
+	# 1. figure out the correct location for crt* files
+	if tc-is-gcc; then
+		# gcc requires crt*.o in multi-dir
+		local multidir=$("${cc[@]}" -print-multi-directory)
+		if [[ ${multidir} != . ]]; then
+			ln -s . "${multidir}" || die
+		fi
+	elif tc-is-clang; then
+		# clang is entirely happy with crt*.o in -B
+		:
+	else
+		eerror "Unsupported compiler for tests ($(tc-getCC))"
+		return
+	fi
+
+	# 2. verify that the compiler can use our crtbegin/crtend
+	local crtbegin=$("${cc[@]}" -print-file-name=crtbegin.o) || die
+	local crtend=$("${cc[@]}" -print-file-name=crtend.o) || die
+	if [[ ! ${crtbegin} -ef ${BUILD_DIR}/crtbegin.o ]]; then
+		die "Compiler uses wrong crtbegin: ${crtbegin}"
+	fi
+	if [[ ! ${crtend} -ef ${BUILD_DIR}/crtend.o ]]; then
+		die "Compiler uses wrong crtend: ${crtend}"
+	fi
+
+	cat > hello.c <<-EOF || die
+		#include <stdio.h>
+
+		__attribute__((constructor))
+		static void ctor_test()
+		{
+			fputs("ctor:", stdout);
+		}
+
+		__attribute__((destructor))
+		static void dtor_test()
+		{
+			fputs(":dtor", stdout);
+		}
+
+		int main()
+		{
+			fputs("main", stdout);
+			return 0;
+		}
+	EOF
+
+	emake -f /dev/null CC="${cc[*]}" hello
+
+	local out=$(./hello) || die
+	if [[ ${out} != ctor:main:dtor ]]; then
+		eerror "Invalid output from the test case."
+		eerror "  Expected: ctor:main:dtor"
+		eerror "  Output  : ${out}"
+		die "Test failed for ${ABI:-${ARCH}}"
+	fi
+}
+
 multilib_src_install() {
 	dolib crtbegin.o crtbeginS.o crtend.o
 	dosym crtbegin.o "/usr/$(get_libdir)/crtbeginT.o"


             reply	other threads:[~2017-06-14 17:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-14 17:04 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-06-14 17:04 [gentoo-commits] repo/gentoo:master commit in: sys-libs/netbsd-csu/ Michał Górny
2019-09-25 17:27 Michał Górny
2019-09-25 17:27 Michał Górny
2019-09-25 17:27 Michał Górny
2019-09-25 17:27 Michał Górny
2019-12-10 16:13 Michał Górny
2019-12-10 16:13 Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1497459868.437e37bbdbaa7623f9efda4464818568f5ea1e01.mgorny@gentoo \
    --to=mgorny@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox