From 40ae704ff2fc419c162527345bad63dd06394afe Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Wed, 10 Aug 2011 13:36:57 -0700 Subject: [PATCH] Begin valgrinding run-fail tests Introduce a temporary no-valgrind directive for the few that aren't clean --- mk/tests.mk | 2 +- src/test/compiletest/header.rs | 13 ++++++++-- src/test/compiletest/runtest.rs | 33 +++++++++++++++++++------- src/test/run-fail/explicit-fail-msg.rs | 3 +-- src/test/run-fail/fmt-fail.rs | 1 + src/test/run-fail/linked-failure.rs | 1 + src/test/run-fail/vec-overrun.rs | 4 +--- src/test/run-fail/vec-underrun.rs | 4 +--- 8 files changed, 41 insertions(+), 20 deletions(-) diff --git a/mk/tests.mk b/mk/tests.mk index 10a0e14b43b..c99a8cc61d2 100644 --- a/mk/tests.mk +++ b/mk/tests.mk @@ -185,11 +185,11 @@ CFAIL_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \ --build-base test/compile-fail/ \ --mode compile-fail \ -# FIXME (236): run-fail should run under valgrind once unwinding works RFAIL_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \ --src-base $$(S)src/test/run-fail/ \ --build-base test/run-fail/ \ --mode run-fail \ + $$(CTEST_RUNTOOL) \ RPASS_ARGS$(2) := $$(CTEST_COMMON_ARGS$(2)) \ --src-base $(S)src/test/run-pass/ \ diff --git a/src/test/compiletest/header.rs b/src/test/compiletest/header.rs index 46fc29e18fc..bd250073405 100644 --- a/src/test/compiletest/header.rs +++ b/src/test/compiletest/header.rs @@ -16,7 +16,10 @@ compile_flags: option::t[str], // If present, the name of a file that this test should match when // pretty-printed - pp_exact: option::t[str] + pp_exact: option::t[str], + // FIXME: no-valgrind is a temporary directive until all of run-fail + // is valgrind-clean + no_valgrind: bool }; // Load any test directives embedded in the file @@ -24,6 +27,7 @@ fn load_props(testfile: &str) -> test_props { let error_patterns = ~[]; let compile_flags = option::none; let pp_exact = option::none; + let no_valgrind = false; for each ln: str in iter_header(testfile) { alt parse_error_pattern(ln) { option::some(ep) { error_patterns += ~[ep]; } @@ -37,11 +41,16 @@ fn load_props(testfile: &str) -> test_props { if option::is_none(pp_exact) { pp_exact = parse_pp_exact(ln, testfile); } + + if no_valgrind == false { + no_valgrind = parse_name_directive(ln, "no-valgrind"); + } } ret { error_patterns: error_patterns, compile_flags: compile_flags, - pp_exact: pp_exact + pp_exact: pp_exact, + no_valgrind: no_valgrind }; } diff --git a/src/test/compiletest/runtest.rs b/src/test/compiletest/runtest.rs index 6a7056b3544..048dbd64b86 100644 --- a/src/test/compiletest/runtest.rs +++ b/src/test/compiletest/runtest.rs @@ -53,13 +53,22 @@ fn run_rfail_test(cx: &cx, props: &test_props, testfile: &str) { if procres.status != 0 { fatal_procres("compilation failed!", procres); } - procres = exec_compiled_test(cx, testfile); + procres = exec_compiled_test(cx, props, testfile); if procres.status == 0 { fatal_procres("run-fail test didn't produce an error!", procres); } + // This is the value valgrind returns on failure + // FIXME: Why is this value neither the value we pass to + // valgrind as --error-exitcode (1), nor the value we see as the + // exit code on the command-line (137)? + const valgrind_err: int = 9; + if procres.status == valgrind_err { + fatal_procres("run-fail test isn't valgrind-clean!", procres); + } + check_error_patterns(props, testfile, procres); } @@ -69,7 +78,7 @@ fn run_rpass_test(cx: &cx, props: &test_props, testfile: &str) { if procres.status != 0 { fatal_procres("compilation failed!", procres); } - procres = exec_compiled_test(cx, testfile); + procres = exec_compiled_test(cx, props, testfile); if procres.status != 0 { fatal_procres("test run failed!", procres); } @@ -219,8 +228,9 @@ fn compile_test(cx: &cx, props: &test_props, testfile: &str) -> procres { cx.config.compile_lib_path, option::none) } -fn exec_compiled_test(cx: &cx, testfile: &str) -> procres { - compose_and_run(cx, testfile, make_run_args, +fn exec_compiled_test(cx: &cx, props: &test_props, + testfile: &str) -> procres { + compose_and_run(cx, testfile, bind make_run_args(_, props, _), cx.config.run_lib_path, option::none) } @@ -248,12 +258,17 @@ fn make_exe_name(config: &config, testfile: &str) -> str { output_base_name(config, testfile) + os::exec_suffix() } -fn make_run_args(config: &config, testfile: &str) -> procargs { - // If we've got another tool to run under (valgrind), - // then split apart its command - let args = +fn make_run_args(config: &config, + props: &test_props, testfile: &str) -> procargs { + let toolargs = if !props.no_valgrind { + // If we've got another tool to run under (valgrind), + // then split apart its command split_maybe_args(config.runtool) - + [make_exe_name(config, testfile)]; + } else { + [] + }; + + let args = toolargs + [make_exe_name(config, testfile)]; ret {prog: args.(0), args: vec::slice(args, 1u, vec::len(args))}; } diff --git a/src/test/run-fail/explicit-fail-msg.rs b/src/test/run-fail/explicit-fail-msg.rs index a200bcd0a16..f238d226b34 100644 --- a/src/test/run-fail/explicit-fail-msg.rs +++ b/src/test/run-fail/explicit-fail-msg.rs @@ -1,4 +1,3 @@ - - // error-pattern:wooooo +// no-valgrind fn main() { let a = 1; if 1 == 1 { a = 2; } fail "woooo" + "o"; } \ No newline at end of file diff --git a/src/test/run-fail/fmt-fail.rs b/src/test/run-fail/fmt-fail.rs index 4428b496e64..d4eb12292a6 100644 --- a/src/test/run-fail/fmt-fail.rs +++ b/src/test/run-fail/fmt-fail.rs @@ -1,4 +1,5 @@ // error-pattern:meh +// no-valgrind use std; import std::str; diff --git a/src/test/run-fail/linked-failure.rs b/src/test/run-fail/linked-failure.rs index bdf561ccc35..a237b0ca394 100644 --- a/src/test/run-fail/linked-failure.rs +++ b/src/test/run-fail/linked-failure.rs @@ -1,6 +1,7 @@ // -*- rust -*- // error-pattern:1 == 2 +// no-valgrind fn child() { assert (1 == 2); } diff --git a/src/test/run-fail/vec-overrun.rs b/src/test/run-fail/vec-overrun.rs index f0ec8f2341b..64d2bf48a6a 100644 --- a/src/test/run-fail/vec-overrun.rs +++ b/src/test/run-fail/vec-overrun.rs @@ -1,9 +1,7 @@ - - - // -*- rust -*- // error-pattern:bounds check +// no-valgrind fn main() { let v: vec[int] = [10]; let x: int = 0; diff --git a/src/test/run-fail/vec-underrun.rs b/src/test/run-fail/vec-underrun.rs index 5bc224bc735..3c227107198 100644 --- a/src/test/run-fail/vec-underrun.rs +++ b/src/test/run-fail/vec-underrun.rs @@ -1,9 +1,7 @@ - - - // -*- rust -*- // error-pattern:bounds check +// no-valgrind fn main() { let v: vec[int] = [10, 20]; let x: int = 0; -- GitLab