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

1
configure vendored
View File

@ -906,6 +906,7 @@ do
done done
make_dir $h/test/run-pass make_dir $h/test/run-pass
make_dir $h/test/run-pass-valgrind
make_dir $h/test/run-pass-fulldeps make_dir $h/test/run-pass-fulldeps
make_dir $h/test/run-fail make_dir $h/test/run-fail
make_dir $h/test/compile-fail make_dir $h/test/compile-fail

View File

@ -174,6 +174,8 @@ else
CFG_VALGRIND_COMPILE := CFG_VALGRIND_COMPILE :=
endif endif
VALGRIND_PATH :=$(CFG_VALGRIND)
ifdef CFG_ENABLE_VALGRIND ifdef CFG_ENABLE_VALGRIND
$(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND)) $(info cfg: enabling valgrind (CFG_ENABLE_VALGRIND))
else else
@ -182,6 +184,7 @@ endif
ifdef CFG_BAD_VALGRIND ifdef CFG_BAD_VALGRIND
$(info cfg: disabling valgrind due to its unreliability on this platform) $(info cfg: disabling valgrind due to its unreliability on this platform)
CFG_VALGRIND := CFG_VALGRIND :=
VALGRIND_PATH :=
endif endif

View File

@ -1,4 +1,4 @@
# Copyright 2012 The Rust Project Developers. See the COPYRIGHT # Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
# file at the top-level directory of this distribution and at # file at the top-level directory of this distribution and at
# http://rust-lang.org/COPYRIGHT. # http://rust-lang.org/COPYRIGHT.
# #
@ -184,12 +184,12 @@ check-notidy: cleantmptestlogs cleantestlibs all check-stage2
# A slightly smaller set of tests for smoke testing. # A slightly smaller set of tests for smoke testing.
check-lite: cleantestlibs cleantmptestlogs \ check-lite: cleantestlibs cleantmptestlogs \
$(foreach crate,$(TEST_TARGET_CRATES),check-stage2-$(crate)) \ $(foreach crate,$(TEST_TARGET_CRATES),check-stage2-$(crate)) \
check-stage2-rpass \ check-stage2-rpass check-stage2-rpass-valgrind \
check-stage2-rfail check-stage2-cfail check-stage2-rmake check-stage2-rfail check-stage2-cfail check-stage2-rmake
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
# Only check the 'reference' tests: rpass/cfail/rfail/rmake. # Only check the 'reference' tests: rpass/cfail/rfail/rmake.
check-ref: cleantestlibs cleantmptestlogs check-stage2-rpass \ check-ref: cleantestlibs cleantmptestlogs check-stage2-rpass check-stage2-rpass-valgrind \
check-stage2-rfail check-stage2-cfail check-stage2-rmake check-stage2-rfail check-stage2-cfail check-stage2-rmake
$(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log $(Q)$(CFG_PYTHON) $(S)src/etc/check-summary.py tmp/*.log
@ -491,6 +491,8 @@ $(foreach host,$(CFG_HOST), \
RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc) RPASS_RC := $(wildcard $(S)src/test/run-pass/*.rc)
RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs) RPASS_RS := $(wildcard $(S)src/test/run-pass/*.rs)
RPASS_VALGRIND_RC := $(wildcard $(S)src/test/run-pass-valgrind/*.rc)
RPASS_VALGRIND_RS := $(wildcard $(S)src/test/run-pass-valgrind/*.rs)
RPASS_FULL_RC := $(wildcard $(S)src/test/run-pass-fulldeps/*.rc) RPASS_FULL_RC := $(wildcard $(S)src/test/run-pass-fulldeps/*.rc)
RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs) RPASS_FULL_RS := $(wildcard $(S)src/test/run-pass-fulldeps/*.rs)
CFAIL_FULL_RC := $(wildcard $(S)src/test/compile-fail-fulldeps/*.rc) CFAIL_FULL_RC := $(wildcard $(S)src/test/compile-fail-fulldeps/*.rc)
@ -511,6 +513,7 @@ CODEGEN_CC := $(wildcard $(S)src/test/codegen/*.cc)
PERF_RS := $(wildcard $(S)src/test/bench/*.rs) PERF_RS := $(wildcard $(S)src/test/bench/*.rs)
RPASS_TESTS := $(RPASS_RC) $(RPASS_RS) RPASS_TESTS := $(RPASS_RC) $(RPASS_RS)
RPASS_VALGRIND_TESTS := $(RPASS_VALGRIND_RC) $(RPASS_VALGRIND_RS)
RPASS_FULL_TESTS := $(RPASS_FULL_RC) $(RPASS_FULL_RS) RPASS_FULL_TESTS := $(RPASS_FULL_RC) $(RPASS_FULL_RS)
CFAIL_FULL_TESTS := $(CFAIL_FULL_RC) $(CFAIL_FULL_RS) CFAIL_FULL_TESTS := $(CFAIL_FULL_RC) $(CFAIL_FULL_RS)
RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS) RFAIL_TESTS := $(RFAIL_RC) $(RFAIL_RS)
@ -527,6 +530,14 @@ CTEST_BUILD_BASE_rpass = run-pass
CTEST_MODE_rpass = run-pass CTEST_MODE_rpass = run-pass
CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL) CTEST_RUNTOOL_rpass = $(CTEST_RUNTOOL)
CTEST_SRC_BASE_rpass-valgrind = run-pass-valgrind
CTEST_BUILD_BASE_rpass-valgrind = run-pass-valgrind
CTEST_MODE_rpass-valgrind = run-pass-valgrind
CTEST_RUNTOOL_rpass-valgrind = $(CTEST_RUNTOOL)
ifdef VALGRIND_PATH
CTEST_TESTARGS += --valgrind-path "$(VALGRIND_PATH)"
endif
CTEST_SRC_BASE_rpass-full = run-pass-fulldeps CTEST_SRC_BASE_rpass-full = run-pass-fulldeps
CTEST_BUILD_BASE_rpass-full = run-pass-fulldeps CTEST_BUILD_BASE_rpass-full = run-pass-fulldeps
CTEST_MODE_rpass-full = run-pass CTEST_MODE_rpass-full = run-pass
@ -622,7 +633,7 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \
# remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898). # remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS)) CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS))
# The tests can not be optimized while the rest of the compiler is optimized, so # The tests cannot be optimized while the rest of the compiler is optimized, so
# filter out the optimization (if any) from rustc and then figure out if we need # filter out the optimization (if any) from rustc and then figure out if we need
# to be optimized # to be optimized
CTEST_RUSTC_FLAGS := $$(subst -O,,$$(CTEST_RUSTC_FLAGS)) CTEST_RUSTC_FLAGS := $$(subst -O,,$$(CTEST_RUSTC_FLAGS))
@ -634,6 +645,7 @@ endif
# slow things down. # slow things down.
CTEST_RUSTC_FLAGS += -C codegen-units=1 CTEST_RUSTC_FLAGS += -C codegen-units=1
CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
--compile-lib-path $$(HLIB$(1)_H_$(3)) \ --compile-lib-path $$(HLIB$(1)_H_$(3)) \
--run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \ --run-lib-path $$(TLIB$(1)_T_$(2)_H_$(3)) \
@ -655,6 +667,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
$$(CTEST_TESTARGS) $$(CTEST_TESTARGS)
CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS) CTEST_DEPS_rpass_$(1)-T-$(2)-H-$(3) = $$(RPASS_TESTS)
CTEST_DEPS_rpass-valgrind_$(1)-T-$(2)-H-$(3) = $$(RPASS_VALGRIND_TESTS)
CTEST_DEPS_rpass-full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3)) CTEST_DEPS_rpass-full_$(1)-T-$(2)-H-$(3) = $$(RPASS_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
CTEST_DEPS_cfail-full_$(1)-T-$(2)-H-$(3) = $$(CFAIL_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3)) CTEST_DEPS_cfail-full_$(1)-T-$(2)-H-$(3) = $$(CFAIL_FULL_TESTS) $$(CSREQ$(1)_T_$(3)_H_$(3)) $$(SREQ$(1)_T_$(2)_H_$(3))
CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS) CTEST_DEPS_rfail_$(1)-T-$(2)-H-$(3) = $$(RFAIL_TESTS)
@ -726,7 +739,7 @@ endif
endef endef
CTEST_NAMES = rpass rpass-full cfail-full rfail cfail bench perf debuginfo-gdb debuginfo-lldb codegen CTEST_NAMES = rpass rpass-valgrind rpass-full cfail-full rfail cfail bench perf debuginfo-gdb debuginfo-lldb codegen
$(foreach host,$(CFG_HOST), \ $(foreach host,$(CFG_HOST), \
$(eval $(foreach target,$(CFG_TARGET), \ $(eval $(foreach target,$(CFG_TARGET), \
@ -895,6 +908,7 @@ TEST_GROUPS = \
$(foreach crate,$(TEST_CRATES),$(crate)) \ $(foreach crate,$(TEST_CRATES),$(crate)) \
$(foreach crate,$(TEST_DOC_CRATES),doc-crate-$(crate)) \ $(foreach crate,$(TEST_DOC_CRATES),doc-crate-$(crate)) \
rpass \ rpass \
rpass-valgrind \
rpass-full \ rpass-full \
cfail-full \ cfail-full \
rfail \ rfail \

View File

@ -17,6 +17,7 @@ pub enum Mode {
CompileFail, CompileFail,
RunFail, RunFail,
RunPass, RunPass,
RunPassValgrind,
Pretty, Pretty,
DebugInfoGdb, DebugInfoGdb,
DebugInfoLldb, DebugInfoLldb,
@ -29,6 +30,7 @@ fn from_str(s: &str) -> Option<Mode> {
"compile-fail" => Some(CompileFail), "compile-fail" => Some(CompileFail),
"run-fail" => Some(RunFail), "run-fail" => Some(RunFail),
"run-pass" => Some(RunPass), "run-pass" => Some(RunPass),
"run-pass-valgrind" => Some(RunPassValgrind),
"pretty" => Some(Pretty), "pretty" => Some(Pretty),
"debuginfo-lldb" => Some(DebugInfoLldb), "debuginfo-lldb" => Some(DebugInfoLldb),
"debuginfo-gdb" => Some(DebugInfoGdb), "debuginfo-gdb" => Some(DebugInfoGdb),
@ -44,6 +46,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
CompileFail => "compile-fail", CompileFail => "compile-fail",
RunFail => "run-fail", RunFail => "run-fail",
RunPass => "run-pass", RunPass => "run-pass",
RunPassValgrind => "run-pass-valgrind",
Pretty => "pretty", Pretty => "pretty",
DebugInfoGdb => "debuginfo-gdb", DebugInfoGdb => "debuginfo-gdb",
DebugInfoLldb => "debuginfo-lldb", DebugInfoLldb => "debuginfo-lldb",
@ -70,6 +73,9 @@ pub struct Config {
// The llvm binaries path // The llvm binaries path
pub llvm_bin_path: Option<Path>, pub llvm_bin_path: Option<Path>,
// The valgrind path
pub valgrind_path: Option<String>,
// The directory containing the tests to run // The directory containing the tests to run
pub src_base: Path, 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("", "run-lib-path", "path to target shared libraries", "PATH"),
reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"), reqopt("", "rustc-path", "path to rustc to use for compiling", "PATH"),
optopt("", "clang-path", "path to executable for codegen tests", "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"), optopt("", "llvm-bin-path", "path to directory holding llvm binaries", "DIR"),
reqopt("", "src-base", "directory to scan for test files", "PATH"), reqopt("", "src-base", "directory to scan for test files", "PATH"),
reqopt("", "build-base", "directory to deposit test outputs", "PATH"), reqopt("", "build-base", "directory to deposit test outputs", "PATH"),
reqopt("", "aux-base", "directory to find auxiliary test files", "PATH"), reqopt("", "aux-base", "directory to find auxiliary test files", "PATH"),
reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET"), reqopt("", "stage-id", "the target-stage identifier", "stageN-TARGET"),
reqopt("", "mode", "which sort of compile tests to run", 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"), optflag("", "ignored", "run tests marked as ignored"),
optopt("", "runtool", "supervisor program to run tests under \ optopt("", "runtool", "supervisor program to run tests under \
(eg. emulator, valgrind)", "PROGRAM"), (eg. emulator, valgrind)", "PROGRAM"),
@ -125,6 +126,7 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
run_lib_path: matches.opt_str("run-lib-path").unwrap(), run_lib_path: matches.opt_str("run-lib-path").unwrap(),
rustc_path: opt_path(matches, "rustc-path"), rustc_path: opt_path(matches, "rustc-path"),
clang_path: matches.opt_str("clang-path").map(|s| Path::new(s)), 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)), llvm_bin_path: matches.opt_str("llvm-bin-path").map(|s| Path::new(s)),
src_base: opt_path(matches, "src-base"), src_base: opt_path(matches, "src-base"),
build_base: opt_path(matches, "build-base"), build_base: opt_path(matches, "build-base"),

View File

@ -9,7 +9,7 @@
// except according to those terms. // except according to those terms.
use common::Config; use common::Config;
use common::{CompileFail, Pretty, RunFail, RunPass, DebugInfoGdb}; use common::{CompileFail, Pretty, RunFail, RunPass, RunPassValgrind, DebugInfoGdb};
use common::{Codegen, DebugInfoLldb}; use common::{Codegen, DebugInfoLldb};
use errors; use errors;
use header::TestProps; use header::TestProps;
@ -35,7 +35,6 @@
use test::MetricMap; use test::MetricMap;
pub fn run(config: Config, testfile: String) { pub fn run(config: Config, testfile: String) {
match config.target.as_slice() { match config.target.as_slice() {
"arm-linux-androideabi" => { "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), CompileFail => run_cfail_test(&config, &props, &testfile),
RunFail => run_rfail_test(&config, &props, &testfile), RunFail => run_rfail_test(&config, &props, &testfile),
RunPass => run_rpass_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), Pretty => run_pretty_test(&config, &props, &testfile),
DebugInfoGdb => run_debuginfo_gdb_test(&config, &props, &testfile), DebugInfoGdb => run_debuginfo_gdb_test(&config, &props, &testfile),
DebugInfoLldb => run_debuginfo_lldb_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) { fn run_pretty_test(config: &Config, props: &TestProps, testfile: &Path) {
if props.pp_exact.is_some() { if props.pp_exact.is_some() {
logv(config, "testing for exact pretty-printing".to_string()); 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. /// 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 /// 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: /// #Failure:
/// ///