Andreas Schwab wrote:
Jie Zhang <[EMAIL PROTECTED]> writes:
@@ -261,7 +262,11 @@ proc rsh_exec { boardname program pargs inp outp } {
set inp "/dev/null"
}
- set ret [local_exec "$RSH $rsh_useropts $hostname sh -c '$program $pargs \\; echo XYZ\\\${?}ZYX'" $inp $outp $timeout]
+ set remote_envs ""
+ foreach envvar [array names remote_env] {
+ set remote_envs "$remote_envs $envvar=$remote_env($envvar)"
That needs to do proper quoting to protect shell meta characters.
Thanks for pointing out this. A new patch is attached. Is the quoting right?
I also dropped remote_getenv from the new patch, since I just realized
it cannot get remote environment variable indeed. remote_unsetenv was
dropped for the same reason.
The patch for gcc is also attached for review.
Jie
diff --git a/lib/rsh.exp b/lib/rsh.exp
index 1a207a8..13be541 100644
--- a/lib/rsh.exp
+++ b/lib/rsh.exp
@@ -225,6 +225,7 @@ proc rsh_upload {desthost srcfile destfile} {
#
proc rsh_exec { boardname program pargs inp outp } {
global timeout
+ global remote_env
verbose "Executing $boardname:$program $pargs < $inp"
@@ -261,7 +262,11 @@ proc rsh_exec { boardname program pargs inp outp } {
set inp "/dev/null"
}
- set ret [local_exec "$RSH $rsh_useropts $hostname sh -c '$program $pargs \\; echo XYZ\\\${?}ZYX'" $inp $outp $timeout]
+ set remote_envs ""
+ foreach envvar [array names remote_env] {
+ set remote_envs "$remote_envs $envvar=\"$remote_env($envvar)\""
+ }
+ set ret [local_exec "$RSH $rsh_useropts $hostname sh -c '$remote_envs $program $pargs \\; echo XYZ\\\${?}ZYX'" $inp $outp $timeout]
set status [lindex $ret 0]
set output [lindex $ret 1]
diff --git a/lib/utils.exp b/lib/utils.exp
index 6c9ff98..6325dd8 100644
--- a/lib/utils.exp
+++ b/lib/utils.exp
@@ -414,3 +414,12 @@ proc getenv { var } {
}
}
+#
+# Set an environment variable remotely
+#
+proc remote_setenv { var val } {
+ global remote_env
+
+ set remote_env($var) $val
+}
+
Index: testsuite/libmudflap.c/cfrags.exp
===================================================================
--- testsuite/libmudflap.c/cfrags.exp (revision 136236)
+++ testsuite/libmudflap.c/cfrags.exp (working copy)
@@ -13,7 +13,11 @@
${srcdir}/libmudflap.c/hook*.c \
${srcdir}/libmudflap.c/pass*.c]] {
set bsrc [file tail $srcfile]
- setenv MUDFLAP_OPTIONS "-viol-segv"
+ if { ![is_remote target] } {
+ setenv MUDFLAP_OPTIONS "-viol-segv"
+ } else {
+ remote_setenv MUDFLAP_OPTIONS "-viol-segv"
+ }
dg-runtest $srcfile $flags "-fmudflap -lmudflap"
}
}
Index: testsuite/libmudflap.c/externs.exp
===================================================================
--- testsuite/libmudflap.c/externs.exp (revision 136236)
+++ testsuite/libmudflap.c/externs.exp (working copy)
@@ -23,7 +23,11 @@
set test "externs-21 linkage ${flags}"
if [string match "" $l3] { pass $test } { fail $test }
- setenv MUDFLAP_OPTIONS "-viol-segv"
+ if { ![is_remote target] } {
+ setenv MUDFLAP_OPTIONS "-viol-segv"
+ } else {
+ remote_setenv MUDFLAP_OPTIONS "-viol-segv"
+ }
remote_spawn host "./externs-12.exe"
set l5 [remote_wait host 10]
Index: testsuite/libmudflap.c++/ctors.exp
===================================================================
--- testsuite/libmudflap.c++/ctors.exp (revision 136236)
+++ testsuite/libmudflap.c++/ctors.exp (working copy)
@@ -28,7 +28,11 @@
set test "ctors-21 linkage ${flags}"
if [string match "" $l3] { pass $test } { fail $test }
- setenv MUDFLAP_OPTIONS "-viol-segv"
+ if { ![is_remote target] } {
+ setenv MUDFLAP_OPTIONS "-viol-segv"
+ } else {
+ remote_setenv MUDFLAP_OPTIONS "-viol-segv"
+ }
remote_spawn host "./ctors-12.exe"
set l5 [remote_wait host 10]
Index: testsuite/libmudflap.c++/c++frags.exp
===================================================================
--- testsuite/libmudflap.c++/c++frags.exp (revision 136236)
+++ testsuite/libmudflap.c++/c++frags.exp (working copy)
@@ -14,7 +14,11 @@
foreach flags $MUDFLAP_FLAGS {
foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.c++/*frag.cxx]] {
set bsrc [file tail $srcfile]
- setenv MUDFLAP_OPTIONS "-viol-segv"
+ if { ![is_remote target] } {
+ setenv MUDFLAP_OPTIONS "-viol-segv"
+ } else {
+ remote_setenv MUDFLAP_OPTIONS "-viol-segv"
+ }
dg-runtest $srcfile $flags "-fmudflap -lmudflap"
}
}
Index: testsuite/libmudflap.cth/cthfrags.exp
===================================================================
--- testsuite/libmudflap.cth/cthfrags.exp (revision 136236)
+++ testsuite/libmudflap.cth/cthfrags.exp (working copy)
@@ -9,7 +9,11 @@
foreach flags $MUDFLAP_FLAGS {
foreach srcfile [lsort [glob -nocomplain ${srcdir}/libmudflap.cth/*.c]] {
set bsrc [file tail $srcfile]
- setenv MUDFLAP_OPTIONS "-viol-segv"
+ if { ![is_remote target] } {
+ setenv MUDFLAP_OPTIONS "-viol-segv"
+ } else {
+ remote_setenv MUDFLAP_OPTIONS "-viol-segv"
+ }
if {$libmudflapth} then {
# --noinhibit-exec works around a ld problem that causes
# "Dwarf Error: Invalid or unhandled FORM value: 14"