From patchwork Thu Mar 16 17:52:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 739934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vkbdv6b8zz9s0Z for ; Fri, 17 Mar 2017 04:52:19 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="OhTprilR"; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=rTtwCMVaCGde+1aJwJA2U0+pG+IOL qbzWyYwoqnNCP98lp1iDxkfEMOePC8ECFZdkMk9Z9afJlDbMuQRDlS2LDW0DIhVh 107OLJusVEZLdQAC/moExo3Z1mNwjaOixBhlLT4F2IIh8GSTErK9es9B2ITFU0bS gZqO0bXi+FxaxU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=T3SETTzK1ieWQAj4JH8/ycqoxCM=; b=OhT prilR5PL9DpO0a3IP5CwuRgi7b1tWqN9Ig4UVnfysn2RKpGMu67eJbJVhUOWsW9R S64wYFmnjDE1TLObxsIlLvwqoPjOP9VdEDd5XVsElhCku6tTcrxh6oRCZoI8b3mo r41uheQxHPEWU70FQ4Zn9lkGfXT+cX2g0qLzs28k= Received: (qmail 16198 invoked by alias); 16 Mar 2017 17:52:13 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 16187 invoked by uid 89); 16 Mar 2017 17:52:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Thu, 16 Mar 2017 17:52:02 +0000 From: Joseph Myers To: Subject: conformtest: Make more tests into compilation tests [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) The conformtest header tests test some things through compilation tests and others through execution tests. This patch makes more of the tests into compilation tests, using _Static_assert (note: for float.h tests on floating-point values this is depending on a GNU extension, that those assertions are allowed in the absence of -pedantic although they aren't strictly integer constant expressions). The remaining execution tests are for values of things listed as "symbol" (in fact no such things have a value expectation listed) and for values of macros defined as string constants (three such values listed in total). This is intended as preparation for enabling the vast bulk of the tests to run for cross compilation. (Even the few remaining execution tests ought in principle to run for cross compilation when a test wrapper is defined, but that's more complicated. The existing execution tests for native builds in fact are linked and run with an existing installed libc that's required to exist to link against, rather than with the newly built libc; only the new headers are used.) Tested for x86_64. Committed. 2017-03-16 Joseph Myers * conform/conformtest.pl: Use compilation instead of execution tests for testing values of constants and usability in #if. diff --git a/conform/conformtest.pl b/conform/conformtest.pl index fedcbc3..54b38f8 100644 --- a/conform/conformtest.pl +++ b/conform/conformtest.pl @@ -472,11 +472,11 @@ while ($#headers >= 0) { } print TESTFILE "# define conformtest_value ($s)\n"; print TESTFILE "#endif\n"; - print TESTFILE "int main (void) { return !((($symbol < 0) == conformtest_negative) && ($symbol == conformtest_value)); }\n"; + print TESTFILE "_Static_assert ((($symbol < 0) == conformtest_negative) && ($symbol == conformtest_value), \"value match inside and outside #if\");\n"; close (TESTFILE); - runtest ($fnamebase, "Testing for #if usability of symbol $symbol", - "Symbol \"$symbol\" not usable in #if.", $res, $xfail); + compiletest ($fnamebase, "Testing for #if usability of symbol $symbol", + "Symbol \"$symbol\" not usable in #if.", $res, 0, $xfail); } if (defined ($type) && ($res == 0 || !$optional)) { @@ -503,13 +503,12 @@ while ($#headers >= 0) { open (TESTFILE, ">$fnamebase.c"); print TESTFILE "$prepend"; print TESTFILE "#include <$h>\n"; - # Negate the value since 0 means ok - print TESTFILE "int main (void) { return !($symbol $op $value); }\n"; + print TESTFILE "_Static_assert ($symbol $op $value, \"value constraint\");\n"; close (TESTFILE); - $res = runtest ($fnamebase, "Testing for value of symbol $symbol", - "Symbol \"$symbol\" has not the right value.", $res, - $xfail); + $res = compiletest ($fnamebase, "Testing for value of symbol $symbol", + "Symbol \"$symbol\" has not the right value.", + $res, 0, $xfail); } } elsif (/^symbol *([a-zA-Z0-9_]*) *([A-Za-z0-9_-]*)?/) { my($symbol) = $1;