auto merge of #17868 : nick29581/rust/valgrind, r=alexcrichton

r? @alexcrichton
This commit is contained in:
bors 2014-10-23 05:27:11 +00:00
commit 8a40854660
11 changed files with 110 additions and 36 deletions

View file

@ -17,6 +17,7 @@ pub enum Mode {
CompileFail,
RunFail,
RunPass,
RunPassValgrind,
Pretty,
DebugInfoGdb,
DebugInfoLldb,
@ -29,6 +30,7 @@ impl FromStr for Mode {
"compile-fail" => Some(CompileFail),
"run-fail" => Some(RunFail),
"run-pass" => Some(RunPass),
"run-pass-valgrind" => Some(RunPassValgrind),
"pretty" => Some(Pretty),
"debuginfo-lldb" => Some(DebugInfoLldb),
"debuginfo-gdb" => Some(DebugInfoGdb),
@ -44,6 +46,7 @@ impl fmt::Show for Mode {
CompileFail => "compile-fail",
RunFail => "run-fail",
RunPass => "run-pass",
RunPassValgrind => "run-pass-valgrind",
Pretty => "pretty",
DebugInfoGdb => "debuginfo-gdb",
DebugInfoLldb => "debuginfo-lldb",
@ -70,6 +73,13 @@ pub struct Config {
// The llvm binaries path
pub llvm_bin_path: Option<Path>,
// The valgrind path
pub valgrind_path: Option<String>,
// Whether to fail if we can't run run-pass-valgrind tests under valgrind
// (or, alternatively, to silently run them like regular run-pass tests).
pub force_valgrind: bool,
// The directory containing the tests to run
pub src_base: Path,

View file

@ -39,6 +39,11 @@ pub mod errors;
pub fn main() {
let args = os::args();
let config = parse_config(args);
if config.valgrind_path.is_none() && config.force_valgrind {
fail!("Can't find Valgrind to run Valgrind tests");
}
log_config(&config);
run_tests(&config);
}
@ -50,13 +55,15 @@ pub fn parse_config(args: Vec<String> ) -> Config {
reqopt("", "run-lib-path", "path to target shared libraries", "PATH"),
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
optopt("", "clang-path", "path to executable for codegen tests", "PATH"),
optopt("", "valgrind-path", "path to Valgrind executable for Valgrind tests", "PROGRAM"),
optflag("", "force-valgrind", "fail if Valgrind tests cannot be run under Valgrind"),
optopt("", "llvm-bin-path", "path to directory holding llvm binaries", "DIR"),
reqopt("", "src-base", "directory to scan for test files", "PATH"),
reqopt("", "build-base", "directory to deposit test outputs", "PATH"),
reqopt("", "aux-base", "directory to find auxiliary test files", "PATH"),
reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET"),
reqopt("", "mode", "which sort of compile tests to run",
"(compile-fail|run-fail|run-pass|pretty|debug-info)"),
"(compile-fail|run-fail|run-pass|run-pass-valgrind|pretty|debug-info)"),
optflag("", "ignored", "run tests marked as ignored"),
optopt("", "runtool", "supervisor program to run tests under \
(eg. emulator, valgrind)", "PROGRAM"),
@ -125,6 +132,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
run_lib_path: matches.opt_str("run-lib-path").unwrap(),
rustc_path: opt_path(matches, "rustc-path"),
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)),
valgrind_path: matches.opt_str("valgrind-path"),
force_valgrind: matches.opt_present("force-valgrind"),
llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
src_base: opt_path(matches, "src-base"),
build_base: opt_path(matches, "build-base"),
@ -162,7 +171,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
!opt_str2(matches.opt_str("adb-test-dir")).is_empty(),
lldb_python_dir: matches.opt_str("lldb-python-dir"),
test_shard: test::opt_shard(matches.opt_str("test-shard")),
verbose: matches.opt_present("verbose")
verbose: matches.opt_present("verbose"),
}
}

View file

@ -9,7 +9,7 @@
// except according to those terms.
use common::Config;
use common::{CompileFail, Pretty, RunFail, RunPass, DebugInfoGdb};
use common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind, DebugInfoGdb};
use common::{Codegen, DebugInfoLldb};
use errors;
use header::TestProps;
@ -35,7 +35,6 @@ use std::time::Duration;
use test::MetricMap;
pub fn run(config: Config, testfile: String) {
match config.target.as_slice() {
"arm-linux-androideabi" => {
@ -64,6 +63,7 @@ pub fn run_metrics(config: Config, testfile: String, mm: &mut MetricMap) {
CompileFail => run_cfail_test(&config, &props, &testfile),
RunFail => run_rfail_test(&config, &props, &testfile),
RunPass => run_rpass_test(&config, &props, &testfile),
RunPassValgrind => run_valgrind_test(&config, &props, &testfile),
Pretty => run_pretty_test(&config, &props, &testfile),
DebugInfoGdb => run_debuginfo_gdb_test(&config, &props, &testfile),
DebugInfoLldb => run_debuginfo_lldb_test(&config, &props, &testfile),
@ -164,6 +164,27 @@ fn run_rpass_test(config: &Config, props: &TestProps, testfile: &Path) {
}
}
fn run_valgrind_test(config: &Config, props: &TestProps, testfile: &Path) {
if config.valgrind_path.is_none() {
assert!(!config.force_valgrind);
return run_rpass_test(config, props, testfile);
}
let mut proc_res = compile_test(config, props, testfile);
if !proc_res.status.success() {
fatal_proc_rec("compilation failed!", &proc_res);
}
let mut new_config = config.clone();
new_config.runtool = new_config.valgrind_path.clone();
proc_res = exec_compiled_test(&new_config, props, testfile);
if !proc_res.status.success() {
fatal_proc_rec("test run failed!", &proc_res);
}
}
fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
if props.pp_exact.is_some() {
logv(config, "testing for exact pretty-printing".to_string());

View file

@ -804,7 +804,7 @@ pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String {
/// whitespace removed, and are only cut at whitespace boundaries.
///
/// Note: Function was moved here from `std::str` because this module is the only place that
/// uses it, and because it was to specific for a general string function.
/// uses it, and because it was too specific for a general string function.
///
/// #Failure:
///