diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-01-10 14:39:15 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-01-10 14:39:15 +0100 |
commit | 3bea3e7d86fcdc8b8ff5183b29b75b1fc6d49b8e (patch) | |
tree | 981da769dc58392f62b4e3b17757cdf6bf3605de | |
parent | 52971cdf2b2fcba653a908186c4db36da06cef8b (diff) |
ffi: Optionally use valgrind to check the c-tests.
-rw-r--r-- | ffi/tests/c-tests.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/ffi/tests/c-tests.rs b/ffi/tests/c-tests.rs index c0a25072..2498c725 100644 --- a/ffi/tests/c-tests.rs +++ b/ffi/tests/c-tests.rs @@ -2,7 +2,7 @@ extern crate libc; extern crate nettle; use std::cmp::min; -use std::env::var_os; +use std::env::{self, var_os}; use std::ffi::OsStr; use std::fmt::Write as FmtWrite; use std::fs; @@ -243,9 +243,21 @@ fn build(include_dir: &Path, ldpath: &Path, target_dir: &Path, /// Runs the test case. fn run(ldpath: &Path, exe: &Path) -> io::Result<()> { - let st = Command::new(exe) - .env("LD_LIBRARY_PATH", ldpath) - .status()?; + let st = + if let Ok(valgrind) = env::var("SEQUOIA_CTEST_VALGRIND") { + Command::new(valgrind) + .env("LD_LIBRARY_PATH", ldpath) + .args(&["--error-exitcode=123", + "--leak-check=yes", + "--quiet", + "--", + exe.to_str().unwrap()]) + .status()? + } else { + Command::new(exe) + .env("LD_LIBRARY_PATH", ldpath) + .status()? + }; if ! st.success() { return Err(io::Error::new(io::ErrorKind::Other, "failed")); } |