Files
wasmtime/tests/all/debug/lldb.rs
Alex Crichton 4c82da440a Move most wasmtime tests into one test suite (#1544)
* Move most wasmtime tests into one test suite

This commit moves most wasmtime tests into a single test suite which
gets compiled into one executable instead of having lots of test
executables. The goal here is to reduce disk space on CI, and this
should be achieved by having fewer executables which means fewer copies
of `libwasmtime.rlib` linked across binaries on the system. More
importantly though this means that DWARF debug information should only
be in one executable rather than duplicated across many.

* Share more build caches

Globally set `RUSTFLAGS` to `-Dwarnings` instead of individually so all
build steps share the same value.

* Allow some dead code in cranelift-codegen

Prevents having to fix all warnings for all possible feature
combinations, only the main ones which come up.

* Update some debug file paths
2020-04-17 17:22:12 -05:00

129 lines
3.0 KiB
Rust

#![allow(dead_code)]
use anyhow::{bail, format_err, Result};
use filecheck::{CheckerBuilder, NO_VARIABLES};
use std::env;
use std::io::Write;
use std::process::Command;
use tempfile::NamedTempFile;
fn lldb_with_script(args: &[&str], script: &str) -> Result<String> {
let lldb_path = env::var("LLDB").unwrap_or("lldb".to_string());
let mut cmd = Command::new(&lldb_path);
cmd.arg("--batch");
if cfg!(target_os = "macos") {
cmd.args(&["-o", "settings set plugin.jit-loader.gdb.enable on"]);
}
let mut script_file = NamedTempFile::new()?;
script_file.write(script.as_bytes())?;
let script_path = script_file.path().to_str().unwrap();
cmd.args(&["-s", &script_path]);
let mut me = std::env::current_exe().expect("current_exe specified");
me.pop(); // chop off the file name
me.pop(); // chop off `deps`
me.push("wasmtime");
cmd.arg(me);
cmd.arg("--");
cmd.args(args);
let output = cmd.output().expect("success");
if !output.status.success() {
bail!(
"failed to execute {:?}: {}",
cmd,
String::from_utf8_lossy(&output.stderr),
);
}
Ok(String::from_utf8(output.stdout)?)
}
fn check_lldb_output(output: &str, directives: &str) -> Result<()> {
let mut builder = CheckerBuilder::new();
builder
.text(directives)
.map_err(|e| format_err!("unable to build checker: {:?}", e))?;
let checker = builder.finish();
let check = checker
.explain(output, NO_VARIABLES)
.map_err(|e| format_err!("{:?}", e))?;
assert!(check.0, "didn't pass check {}", check.1);
Ok(())
}
#[test]
#[ignore]
#[cfg(all(
any(target_os = "linux", target_os = "macos"),
target_pointer_width = "64"
))]
pub fn test_debug_dwarf_lldb() -> Result<()> {
let output = lldb_with_script(
&[
"-g",
"tests/all/debug/testsuite/fib-wasm.wasm",
"--invoke",
"fib",
"3",
],
r#"b fib
r
fr v
c"#,
)?;
check_lldb_output(
&output,
r#"
check: Breakpoint 1: no locations (pending)
check: Unable to resolve breakpoint to any actual locations.
check: 1 location added to breakpoint 1
check: stop reason = breakpoint 1.1
check: frame #0
sameln: JIT
sameln: fib(n=3)
check: n = 3
check: a = 0
check: resuming
check: exited with status
"#,
)?;
Ok(())
}
#[test]
#[ignore]
#[cfg(all(
any(target_os = "linux", target_os = "macos"),
target_pointer_width = "64"
))]
pub fn test_debug_dwarf_ptr() -> Result<()> {
let output = lldb_with_script(
&[
"-g",
"--opt-level",
"0",
"tests/all/debug/testsuite/reverse-str.wasm",
],
r#"b reverse-str.c:9
r
p __vmctx->set(),&*s
c"#,
)?;
check_lldb_output(
&output,
r#"
check: Breakpoint 1: no locations (pending)
check: stop reason = breakpoint 1.1
check: frame #0
sameln: reverse(s=(__ptr =
check: "Hello, world."
check: resuming
"#,
)?;
Ok(())
}