Skip to content

Commit 11368d2

Browse files
committed
Error if we should be able to Valgrind but can't
1 parent 1b5eb2d commit 11368d2

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

mk/tests.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,11 @@ CTEST_RUNTOOL_rpass-valgrind = $(CTEST_RUNTOOL)
533533
ifdef VALGRIND_PATH
534534
CTEST_TESTARGS += --valgrind-path "$(VALGRIND_PATH)"
535535
endif
536+
ifndef CFG_BAD_VALGRIND
537+
ifndef CFG_DISABLE_VALGRIND
538+
CTEST_TESTARGS += --force-valgrind
539+
endif
540+
endif
536541

537542
CTEST_SRC_BASE_rpass-full = run-pass-fulldeps
538543
CTEST_BUILD_BASE_rpass-full = run-pass-fulldeps

src/compiletest/common.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ pub struct Config {
7676
// The valgrind path
7777
pub valgrind_path: Option<String>,
7878

79+
// Whether to fail if we can't run run-pass-valgrind tests under valgrind
80+
// (or, alternatively, to silently run them like regular run-pass tests).
81+
pub force_valgrind: bool,
82+
7983
// The directory containing the tests to run
8084
pub src_base: Path,
8185

src/compiletest/compiletest.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ pub mod errors;
3939
pub fn main() {
4040
let args = os::args();
4141
let config = parse_config(args);
42+
43+
if config.valgrind_path.is_none() && config.force_valgrind {
44+
fail!("Can't find Valgrind to run Valgrind tests");
45+
}
46+
4247
log_config(&config);
4348
run_tests(&config);
4449
}
@@ -50,7 +55,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
5055
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
5156
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
5257
optopt("", "clang-path", "path to executable for codegen tests", "PATH"),
53-
optopt("", "valgrind-path", "path to valgrind executable for valgrind tests", "PROGRAM"),
58+
optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM"),
59+
optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind"),
5460
optopt("", "llvm-bin-path", "path to directory holding llvm binaries", "DIR"),
5561
reqopt("", "src-base", "directory to scan for test files", "PATH"),
5662
reqopt("", "build-base", "directory to deposit test outputs", "PATH"),
@@ -127,6 +133,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
127133
rustc_path: opt_path(matches, "rustc-path"),
128134
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
129135
valgrind_path: matches.opt_str("valgrind-path"),
136+
force_valgrind: matches.opt_present("force-valgrind"),
130137
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
131138
src_base: opt_path(matches, "src-base"),
132139
build_base: opt_path(matches, "build-base"),
@@ -164,7 +171,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
164171
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
165172
lldb_python_dir: matches.opt_str("lldb-python-dir"),
166173
test_shard: test::opt_shard(matches.opt_str("test-shard")),
167-
verbose: matches.opt_present("verbose")
174+
verbose: matches.opt_present("verbose"),
168175
}
169176
}
170177

src/compiletest/runtest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ fn run_rpass_test(config: &Config, props: &TestProps, testfile: &Path) {
166166

167167
fn run_valgrind_test(config: &Config, props: &TestProps, testfile: &Path) {
168168
if config.valgrind_path.is_none() {
169+
assert!(!config.force_valgrind);
169170
return run_rpass_test(config, props, testfile);
170171
}
171172

@@ -175,7 +176,6 @@ fn run_valgrind_test(config: &Config, props: &TestProps, testfile: &Path) {
175176
fatal_proc_rec("compilation failed!", &proc_res);
176177
}
177178

178-
println!("running valgrind");
179179
let mut new_config = config.clone();
180180
new_config.runtool = new_config.valgrind_path.clone();
181181
proc_res = exec_compiled_test(&new_config, props, testfile);

0 commit comments

Comments
 (0)