Re: [PATCH] Environment variables forwarding
On Wed, Mar 26, 2014 at 10:42:12AM -0700, Mike Stump wrote: On Mar 25, 2014, at 7:31 AM, Yury Gribov y.gri...@samsung.com wrote: On 03/24/2014 01:46 PM, Maxim Ostapenko wrote: On 03/24/2014 12:28 PM, Maxim Ostapenko wrote: 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. So, I’m interested in what Jakub might say… but, seems reasonable to enhance it so that this is possible. I'd personaly think it is not worth bothering, such features could be just tested on native testing. But if somebody is willing to maintain it for cross-testing and review that, I don't object. Jakub
Re: [PATCH] Environment variables forwarding
But if somebody is willing to maintain it for cross-testing Yup, we'll do this. Now what bothers me is zero feedback from Dejagnu folks... -Y
Re: [PATCH] Environment variables forwarding
On Thu, Mar 27, 2014 at 09:56:22AM +0400, Yury Gribov wrote: Now what bothers me is zero feedback from Dejagnu folks... Come on, it's only been a couple of days. :-) Ben signature.asc Description: Digital signature
Re: [PATCH] Environment variables forwarding
Cc-ing Jakub cause he's the author of original set-target-env-var support in GCC testsuite. On 03/24/2014 01:46 PM, Maxim Ostapenko wrote: 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 -Y 2014-03-24 Max Ostapenko m.ostape...@partner.samsung.com * 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 2014-03-24 Max Ostapenko m.ostape...@partner.samsung.com * 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
[PATCH] Environment variables forwarding
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 m.ostape...@partner.samsung.com * 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 2014-03-24 Max Ostapenko m.ostape...@partner.samsung.com * 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 +}
Re: [PATCH] Environment variables forwarding
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 m.ostape...@partner.samsung.com * 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 2014-03-24 Max Ostapenko m.ostape...@partner.samsung.com * 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