dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Set environment variable on remote target


From: Jie Zhang
Subject: Set environment variable on remote target
Date: Thu, 17 Jul 2008 00:52:34 +0800
User-agent: Mozilla-Thunderbird 2.0.0.14 (X11/20080509)

libmudflap tests set a environment MUDFLAP_OPTIONS=-viol-segv before testing such that violations are promoted to SIGSEGV signals in testing. Otherwise, the exit value would be 0 even the test has violations. libmudflap testsuite depends on the exit value of tests to decide if the test PASS or FAIL. Setting MUDFLAP_OPTIONS is done in DejaGNU by

  setenv MUDFLAP_OPTIONS "-viol-segv"

which works fine on native testing. But when doing remote cross testing, setenv does not help. I cannot find existing mechanism in DejaGNU. So I want to use a global array like remote_env. If remote cross testing, add the environment variable in this array. Then set the environment variables according to the array when remote execute test case. I wrote a draft patch show what I means, which is attached. In mudflap testsuite, replace each setenv with

        if { ![is_remote target] } {
            setenv MUDFLAP_OPTIONS "-viol-segv"
        } else {
            remote_setenv MUDFLAP_OPTIONS "-viol-segv"
        }

Is it the right way to do this, or is there existing method I can use but I missed?


Thanks,

Jie
diff --git a/lib/rsh.exp b/lib/rsh.exp
index 1a207a8..df3b3d1 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..8523973 100644
--- a/lib/utils.exp
+++ b/lib/utils.exp
@@ -414,3 +414,33 @@ proc getenv { var } {
     }
 }
 
+#
+# Set an environment variable remotely
+#
+proc remote_setenv { var val } {
+    global remote_env
+
+    set remote_env($var) $val
+}
+
+#
+# Unset an environment variable remotely
+#
+proc remote_unsetenv { var } {
+    global remote_env
+    unset remote_env($var)
+}
+
+#
+# Get a value from an environment variable remotely
+#
+proc remote_getenv { var } {
+    global remote_env
+
+    if {[info exists remote_env($var)]} {
+       return $remote_env($var)
+    } else {
+       return ""
+    }
+}
+

reply via email to

[Prev in Thread] Current Thread [Next in Thread]