[PATCH][Ping v2] Environment variables forwarding
Maxim Ostapenko <[email protected]>
| Newsgroups | gmane.comp.sysutils.dejagnu.cvs |
|---|---|
| Message-ID | <534F860D.4090402__38251.3930592269$1397739632$gmane$org@partner.samsung.com> |
Ping. -------- Original Message -------- Subject: [PATCH][Ping] Environment variables forwarding Date: Thu, 03 Apr 2014 17:06:14 +0400 From: Maxim Ostapenko <[email protected]> To: [email protected] CC: Slava Garbuzov <[email protected]>, Yury Gribov <[email protected]> Ping. -------- Original Message -------- Subject: Re: [PATCH] Environment variables forwarding Date: Mon, 24 Mar 2014 13:46:09 +0400 From: Maxim Ostapenko <[email protected]> To: GCC Patches <[email protected]>, [email protected] CC: Yury Gribov <[email protected]>, Slava Garbuzov <[email protected]>, 'Evgeny Gavrin' <[email protected]> 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 _______________________________________________ Dejagnu-commit mailing list [email protected] https://lists.gnu.org/mailman/listinfo/dejagnu-commit
dejagnu.diff
(text/x-patch, 986 B)
2014-03-24 Max Ostapenko <[email protected]> * config/unix.exp: Parse incoming string in environment variables and program name itself. diff --git a/config/unix.exp b/config/unix.exp index 4b244ca..fa0327a 100644 --- a/config/unix.exp +++ b/config/unix.exp @@ -50,6 +50,9 @@ proc unix_load { dest prog args } { set inp "" } + regsub "^ *((\[^ \]+=\[^ \]* *)*).*" $prog "\\1" environ + regsub "^ *((\[^ \]+=\[^ \]* *)*)" $prog "" prog + if {![file exists $prog]} then { # We call both here because this should never happen. perror "$prog does not exist in unix_load." @@ -114,7 +117,7 @@ proc unix_load { dest prog args } { return [list "unresolved" ""] } } - set status [remote_exec $dest "$remotefile" $parg $inp] + set status [remote_exec $dest "$environ $remotefile" $parg $inp] remote_file $dest delete $remotefile.o $remotefile if { [lindex $status 0] < 0 } { verbose -log "Couldn't execute $prog, [lindex $status 1]" 3
gcc_dg.diff
(text/x-patch, 3.6 KB)
2014-03-24 Max Ostapenko <[email protected]> * 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 +}