From patchwork Mon Mar 24 09:46:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: max X-Patchwork-Id: 333040 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 9AD3D140090 for ; Mon, 24 Mar 2014 23:13:43 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=XttwVd45Hg0UQfLOV Au3MYI1E4V6x8D1Ar6m9A0LFafTdWwlDK86ogimMSbq6n0TDJ/esIghmPUidaHtV OC5Ae01lKDkoxnmTJhf5TD5NVvZc/KtajBRZ+ejCxPglLMKidamrKSTNWdVvu2z3 oeRBIaz5KucKoCkdlKSROWj/d4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=fgVgrl8hGrkf2ab27hpx0hh Q6MQ=; b=XN3ZNajcMU+pPCwiHJe8KdjOKSNCpGcUARFC35LbnpoXwkcA0lHiAJH wCEAOsAw47tHnU3Rsmx+LOOX6G57ZzE60KAzw+pZCqw5ijeZHHJS4vcmwRFSSxvV vdEnd6vrreQh70b6ic8S8+aswxlhub+KwuWNEBP44MN127IYeB6Q= Received: (qmail 13719 invoked by alias); 24 Mar 2014 09:46:25 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 13704 invoked by uid 89); 24 Mar 2014 09:46:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 X-HELO: mailout1.w1.samsung.com Received: from mailout1.w1.samsung.com (HELO mailout1.w1.samsung.com) (210.118.77.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (DES-CBC3-SHA encrypted) ESMTPS; Mon, 24 Mar 2014 09:46:22 +0000 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0N2X00FNLPT6SZ80@mailout1.w1.samsung.com> for gcc-patches@gcc.gnu.org; Mon, 24 Mar 2014 09:46:18 +0000 (GMT) Received: from eusync4.samsung.com ( [203.254.199.214]) by eucpsbgm1.samsung.com (EUCPMTA) with SMTP id 9A.5C.23059.AEEFF235; Mon, 24 Mar 2014 09:46:18 +0000 (GMT) Received: from [106.109.128.212] by eusync4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0N2X008L3PT54V10@eusync4.samsung.com>; Mon, 24 Mar 2014 09:46:18 +0000 (GMT) Message-id: <532FFEE1.2000606@partner.samsung.com> Date: Mon, 24 Mar 2014 13:46:09 +0400 From: Maxim Ostapenko User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-version: 1.0 To: GCC Patches , dejagnu@gnu.org Cc: Yury Gribov , Slava Garbuzov , 'Evgeny Gavrin' Subject: Re: [PATCH] Environment variables forwarding References: <532FECB4.90805@partner.samsung.com> In-reply-to: <532FECB4.90805@partner.samsung.com> Content-type: multipart/mixed; boundary=------------000902000804070104000901 X-IsSubscribed: yes Adding Dejagnu list this time. On 03/24/2014 12:28 PM, Maxim Ostapenko wrote: > Hi all, > > When porting Lsan on arm, I ran into problem with testing, because > almost all lsan tests require environment variables forwarding for > remote targets. Unfortunately, this feature isn't implemented yet > neither in Dejagnu nor in GCC. These two small patches seem to resolve > this issue. > > Tested on arm with asan.exp and ubsan.exp. > > I've cross-posted this message in Dejagnu too. > > Do these changes make sense? If not - what's the proper way to forward > env vars on remote targets? > > -Maxim 2014-03-24 Max Ostapenko * lib/gcc-dg.exp: Add check if Dejagnu supports environment variables forwarding for remote targets. * lib/target-supports.exp (check_runtime_env_vars_forwarding_nocache): New function. (check_runtime_env_vars_forwarding): New function. diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp index f9d52bc..05eab99 100644 --- a/gcc/testsuite/lib/gcc-dg.exp +++ b/gcc/testsuite/lib/gcc-dg.exp @@ -80,6 +80,9 @@ set LTO_TORTURE_OPTIONS "" global gcc_force_conventional_output set gcc_force_conventional_output "" +global target_env_vars_available +set target_env_vars_available "" + if [check_effective_target_lto] { # When having plugin test both slim and fat LTO and plugin/nonplugin # path. @@ -258,11 +261,21 @@ if { [info procs ${tool}_load] != [list] \ set saved_target_env_var [list] if { [info exists set_target_env_var] \ && [llength $set_target_env_var] != 0 } { - if { [is_remote target] } { - return [list "unsupported" ""] - } - set-target-env-var - } + if { [is_remote target] } { + if [check_runtime_env_vars_forwarding] { + foreach env_var $set_target_env_var { + set var [lindex $env_var 0] + set value [lindex $env_var 1] + set program "$var=$value $program" + } + } else { + return [list "unsupported" ""] + } + } else { + set-target-env-var + } + } + set result [eval [list saved_${tool}_load $program] $args] if { [info exists set_target_env_var] \ && [llength $set_target_env_var] != 0 } { diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index bee8471..3a3224f 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -5731,3 +5731,57 @@ proc force_conventional_output_for { test } { } } +# This procedure is the same the check_runtime_nocache one. The only +# difference is that executable will run with TEST=1 environment +# variable. If Dejagnu supports environment variables forwarding +# for remote targets, it will return 1, otherwise it will return 0. + +proc check_runtime_env_vars_forwarding_nocache {} { + global tool + global target_env_vars_available + set basename env_forwarding_works + set contents { + #ifdef __cplusplus + extern "C" + #endif + char *getenv(const char *name); + + #ifdef __cplusplus + extern "C" + #endif + int strcmp(const char *s1, const char *s2); + + int main () { return strcmp(getenv("TEST"), "1"); } + } + + set args "" + + set result [eval [list check_compile $basename executable $contents] $args] + set lines [lindex $result 0] + set output [lindex $result 1] + + set ok 0 + if { [string match "" $lines] } { + # No error messages, everything is OK. + set result [remote_load target "TEST=1 ./$output" "" ""] + set status [lindex $result 0] + verbose "check_runtime_nocache $basename: status is <$status>" 2 + if { $status == "pass" } { + set ok 1 + } + } + remote_file build delete $output + return $ok +} + +proc check_runtime_env_vars_forwarding {} { + global target_env_vars_available + if { $target_env_vars_available == "" } { + if [check_runtime_env_vars_forwarding_nocache] { + set target_env_vars_available 1 + } else { + set target_env_vars_available 0 + } + } + return $target_env_vars_available +}