Add run-pass-valgrind tests

Closes #16914
This commit is contained in:
Nick Cameron 2014-10-07 20:00:26 +13:00
parent 7d7e409839
commit f466e1a59f
7 changed files with 56 additions and 9 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,9 @@ pub struct Config {
// The llvm binaries path
pub llvm_bin_path: Option<Path>,
// The valgrind path
pub valgrind_path: Option<String>,
// The directory containing the tests to run
pub src_base: Path,

View file

@ -50,13 +50,14 @@ 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"),
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 +126,7 @@ 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"),
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"),

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() {
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);
}
println!("running valgrind");
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:
///