diff options
| author | bors <bors@rust-lang.org> | 2014-10-23 05:27:11 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-10-23 05:27:11 +0000 |
| commit | 8a4085466021c534427c544b860eabcdf4ed85df (patch) | |
| tree | 4296aab534b7af958b141182695c08dfe97a1ef6 /src | |
| parent | 96991e9335e260d2684785ee97dc1af9cbed5aad (diff) | |
| parent | 80ff1d1a107bc0b89e26c4179794573738bbb3fc (diff) | |
auto merge of #17868 : nick29581/rust/valgrind, r=alexcrichton
r? @alexcrichton
Diffstat (limited to 'src')
| -rw-r--r-- | src/compiletest/common.rs | 10 | ||||
| -rw-r--r-- | src/compiletest/compiletest.rs | 13 | ||||
| -rw-r--r-- | src/compiletest/runtest.rs | 25 | ||||
| -rw-r--r-- | src/libgetopts/lib.rs | 2 | ||||
| -rw-r--r-- | src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs (renamed from src/test/run-pass/cleanup-auto-borrow-obj.rs) | 0 | ||||
| -rw-r--r-- | src/test/run-pass-valgrind/dst-dtor-1.rs (renamed from src/test/run-pass/dst-dtor-1.rs) | 0 | ||||
| -rw-r--r-- | src/test/run-pass-valgrind/dst-dtor-2.rs (renamed from src/test/run-pass/dst-dtor-2.rs) | 0 |
7 files changed, 45 insertions, 5 deletions
diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs index 4c602b8e1a3..2c917f7aefe 100644 --- a/src/compiletest/common.rs +++ b/src/compiletest/common.rs @@ -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, diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs index 28aaca1776b..7af25de1f6f 100644 --- a/src/compiletest/compiletest.rs +++ b/src/compiletest/compiletest.rs @@ -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"), } } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index c703953ff70..34129dedbd8 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -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()); diff --git a/src/libgetopts/lib.rs b/src/libgetopts/lib.rs index 37b3458b555..aa625de9398 100644 --- a/src/libgetopts/lib.rs +++ b/src/libgetopts/lib.rs @@ -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: /// diff --git a/src/test/run-pass/cleanup-auto-borrow-obj.rs b/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs index 5d7dbbe5a29..5d7dbbe5a29 100644 --- a/src/test/run-pass/cleanup-auto-borrow-obj.rs +++ b/src/test/run-pass-valgrind/cleanup-auto-borrow-obj.rs diff --git a/src/test/run-pass/dst-dtor-1.rs b/src/test/run-pass-valgrind/dst-dtor-1.rs index 6e2ae117ce7..6e2ae117ce7 100644 --- a/src/test/run-pass/dst-dtor-1.rs +++ b/src/test/run-pass-valgrind/dst-dtor-1.rs diff --git a/src/test/run-pass/dst-dtor-2.rs b/src/test/run-pass-valgrind/dst-dtor-2.rs index deaf49228bc..deaf49228bc 100644 --- a/src/test/run-pass/dst-dtor-2.rs +++ b/src/test/run-pass-valgrind/dst-dtor-2.rs |
