Skip to content

Commit 7f55fc3

Browse files
committed
std: Work around some failing 'run' tests when valgrinding. rust-lang#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.
1 parent 04b1dba commit 7f55fc3

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/libstd/run.rs

+25-5
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ priv fn waitpid(pid: pid_t) -> int {
915915
#[cfg(test)]
916916
mod tests {
917917
use io;
918-
use libc::{c_int};
918+
use libc::{c_int, uintptr_t};
919919
use option::{Option, None, Some};
920920
use os;
921921
use path::Path;
@@ -958,7 +958,10 @@ mod tests {
958958
959959
assert_eq!(status, 0);
960960
assert_eq!(output_str.trim().to_owned(), ~"hello");
961-
assert_eq!(error, ~[]);
961+
// FIXME #7224
962+
if !running_on_valgrind() {
963+
assert_eq!(error, ~[]);
964+
}
962965
}
963966
964967
#[test]
@@ -1043,7 +1046,10 @@ mod tests {
10431046
10441047
assert_eq!(status, 0);
10451048
assert_eq!(output_str.trim().to_owned(), ~"hello");
1046-
assert_eq!(error, ~[]);
1049+
// FIXME #7224
1050+
if !running_on_valgrind() {
1051+
assert_eq!(error, ~[]);
1052+
}
10471053
}
10481054
10491055
#[test]
@@ -1057,14 +1063,20 @@ mod tests {
10571063
10581064
assert_eq!(status, 0);
10591065
assert_eq!(output_str.trim().to_owned(), ~"hello");
1060-
assert_eq!(error, ~[]);
1066+
// FIXME #7224
1067+
if !running_on_valgrind() {
1068+
assert_eq!(error, ~[]);
1069+
}
10611070
10621071
let run::ProcessOutput {status, output, error}
10631072
= prog.finish_with_output();
10641073
10651074
assert_eq!(status, 0);
10661075
assert_eq!(output, ~[]);
1067-
assert_eq!(error, ~[]);
1076+
// FIXME #7224
1077+
if !running_on_valgrind() {
1078+
assert_eq!(error, ~[]);
1079+
}
10681080
}
10691081
10701082
#[test]
@@ -1169,4 +1181,12 @@ mod tests {
11691181
11701182
assert!(output.contains("RUN_TEST_NEW_ENV=123"));
11711183
}
1184+
1185+
fn running_on_valgrind() -> bool {
1186+
unsafe { rust_running_on_valgrind() != 0 }
1187+
}
1188+
1189+
extern {
1190+
fn rust_running_on_valgrind() -> uintptr_t;
1191+
}
11721192
}

src/rt/rust_builtin.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "sync/timer.h"
1818
#include "sync/rust_thread.h"
1919
#include "rust_abi.h"
20+
#include "vg/valgrind.h"
2021

2122
#include <time.h>
2223

@@ -930,6 +931,11 @@ rust_begin_unwind(uintptr_t token) {
930931
#endif
931932
}
932933

934+
extern "C" CDECL uintptr_t
935+
rust_running_on_valgrind() {
936+
return RUNNING_ON_VALGRIND;
937+
}
938+
933939
//
934940
// Local Variables:
935941
// mode: C++

src/rt/rustrt.def.in

+1
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,4 @@ rust_valgrind_stack_deregister
239239
rust_take_env_lock
240240
rust_drop_env_lock
241241
rust_update_log_settings
242+
rust_running_on_valgrind

0 commit comments

Comments
 (0)