about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2013-06-18 19:52:05 -0700
committerBrian Anderson <banderson@mozilla.com>2013-06-18 19:52:05 -0700
commit7f55fc33f08a7ec5df0d06b4b0543bc864e60640 (patch)
treed8b84b09faa330265850b263701d57e8dc775f9e /src
parent04b1dbabf567f530c20e44d5e97967dae3aabd17 (diff)
downloadrust-7f55fc33f08a7ec5df0d06b4b0543bc864e60640.tar.gz
rust-7f55fc33f08a7ec5df0d06b4b0543bc864e60640.zip
std: Work around some failing 'run' tests when valgrinding. #7224
Under valgrind on 64->32 cross compiles the dynamic linker is emitting
some error messages on stderr, which interferes with the tests that
are checking stderr.
Diffstat (limited to 'src')
-rw-r--r--src/libstd/run.rs30
-rw-r--r--src/rt/rust_builtin.cpp6
-rw-r--r--src/rt/rustrt.def.in1
3 files changed, 32 insertions, 5 deletions
diff --git a/src/libstd/run.rs b/src/libstd/run.rs
index b204cf6cfb0..7a96bf35218 100644
--- a/src/libstd/run.rs
+++ b/src/libstd/run.rs
@@ -915,7 +915,7 @@ priv fn waitpid(pid: pid_t) -> int {
 #[cfg(test)]
 mod tests {
     use io;
-    use libc::{c_int};
+    use libc::{c_int, uintptr_t};
     use option::{Option, None, Some};
     use os;
     use path::Path;
@@ -958,7 +958,10 @@ mod tests {
 
         assert_eq!(status, 0);
         assert_eq!(output_str.trim().to_owned(), ~"hello");
-        assert_eq!(error, ~[]);
+        // FIXME #7224
+        if !running_on_valgrind() {
+            assert_eq!(error, ~[]);
+        }
     }
 
     #[test]
@@ -1043,7 +1046,10 @@ mod tests {
 
         assert_eq!(status, 0);
         assert_eq!(output_str.trim().to_owned(), ~"hello");
-        assert_eq!(error, ~[]);
+        // FIXME #7224
+        if !running_on_valgrind() {
+            assert_eq!(error, ~[]);
+        }
     }
 
     #[test]
@@ -1057,14 +1063,20 @@ mod tests {
 
         assert_eq!(status, 0);
         assert_eq!(output_str.trim().to_owned(), ~"hello");
-        assert_eq!(error, ~[]);
+        // FIXME #7224
+        if !running_on_valgrind() {
+            assert_eq!(error, ~[]);
+        }
 
         let run::ProcessOutput {status, output, error}
             = prog.finish_with_output();
 
         assert_eq!(status, 0);
         assert_eq!(output, ~[]);
-        assert_eq!(error, ~[]);
+        // FIXME #7224
+        if !running_on_valgrind() {
+            assert_eq!(error, ~[]);
+        }
     }
 
     #[test]
@@ -1169,4 +1181,12 @@ mod tests {
 
         assert!(output.contains("RUN_TEST_NEW_ENV=123"));
     }
+
+    fn running_on_valgrind() -> bool {
+        unsafe { rust_running_on_valgrind() != 0 }
+    }
+
+    extern {
+        fn rust_running_on_valgrind() -> uintptr_t;
+    }
 }
diff --git a/src/rt/rust_builtin.cpp b/src/rt/rust_builtin.cpp
index 5e7357c9b7b..3bd5e09e007 100644
--- a/src/rt/rust_builtin.cpp
+++ b/src/rt/rust_builtin.cpp
@@ -17,6 +17,7 @@
 #include "sync/timer.h"
 #include "sync/rust_thread.h"
 #include "rust_abi.h"
+#include "vg/valgrind.h"
 
 #include <time.h>
 
@@ -930,6 +931,11 @@ rust_begin_unwind(uintptr_t token) {
 #endif
 }
 
+extern "C" CDECL uintptr_t
+rust_running_on_valgrind() {
+    return RUNNING_ON_VALGRIND;
+}
+
 //
 // Local Variables:
 // mode: C++
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index e3e522aa7ce..ba7ada04a27 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -239,3 +239,4 @@ rust_valgrind_stack_deregister
 rust_take_env_lock
 rust_drop_env_lock
 rust_update_log_settings
+rust_running_on_valgrind
\ No newline at end of file