Clean up compiletest
This commit is contained in:
parent
156088f8a8
commit
e2523c1842
@ -142,7 +142,6 @@
|
||||
"needs-relocation-model-pic",
|
||||
"needs-run-enabled",
|
||||
"needs-rust-lld",
|
||||
"needs-rust-lldb",
|
||||
"needs-sanitizer-address",
|
||||
"needs-sanitizer-cfi",
|
||||
"needs-sanitizer-dataflow",
|
||||
|
@ -296,15 +296,9 @@ pub struct Config {
|
||||
/// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
|
||||
pub gdb_version: Option<u32>,
|
||||
|
||||
/// Whether GDB has native rust support
|
||||
pub gdb_native_rust: bool,
|
||||
|
||||
/// Version of LLDB
|
||||
pub lldb_version: Option<u32>,
|
||||
|
||||
/// Whether LLDB has native rust support
|
||||
pub lldb_native_rust: bool,
|
||||
|
||||
/// Version of LLVM
|
||||
pub llvm_version: Option<u32>,
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::common::{Config, Debugger, Sanitizer};
|
||||
use crate::common::{Config, Sanitizer};
|
||||
use crate::header::IgnoreDecision;
|
||||
|
||||
pub(super) fn handle_needs(
|
||||
@ -114,11 +114,6 @@ pub(super) fn handle_needs(
|
||||
condition: cache.rust_lld,
|
||||
ignore_reason: "ignored on targets without Rust's LLD",
|
||||
},
|
||||
Need {
|
||||
name: "needs-rust-lldb",
|
||||
condition: config.debugger != Some(Debugger::Lldb) || config.lldb_native_rust,
|
||||
ignore_reason: "ignored on targets without Rust's LLDB",
|
||||
},
|
||||
Need {
|
||||
name: "needs-dlltool",
|
||||
condition: cache.dlltool,
|
||||
|
@ -194,14 +194,8 @@ fn make_absolute(path: PathBuf) -> PathBuf {
|
||||
let target = opt_str2(matches.opt_str("target"));
|
||||
let android_cross_path = opt_path(matches, "android-cross-path");
|
||||
let (cdb, cdb_version) = analyze_cdb(matches.opt_str("cdb"), &target);
|
||||
let (gdb, gdb_version, gdb_native_rust) =
|
||||
analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path);
|
||||
let (lldb_version, lldb_native_rust) = matches
|
||||
.opt_str("lldb-version")
|
||||
.as_deref()
|
||||
.and_then(extract_lldb_version)
|
||||
.map(|(v, b)| (Some(v), b))
|
||||
.unwrap_or((None, false));
|
||||
let (gdb, gdb_version) = analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path);
|
||||
let lldb_version = matches.opt_str("lldb-version").as_deref().and_then(extract_lldb_version);
|
||||
let color = match matches.opt_str("color").as_deref() {
|
||||
Some("auto") | None => ColorConfig::AutoColor,
|
||||
Some("always") => ColorConfig::AlwaysColor,
|
||||
@ -298,9 +292,7 @@ fn make_absolute(path: PathBuf) -> PathBuf {
|
||||
cdb_version,
|
||||
gdb,
|
||||
gdb_version,
|
||||
gdb_native_rust,
|
||||
lldb_version,
|
||||
lldb_native_rust,
|
||||
llvm_version,
|
||||
system_llvm: matches.opt_present("system-llvm"),
|
||||
android_cross_path,
|
||||
@ -1035,19 +1027,17 @@ fn find_cdb(target: &str) -> Option<OsString> {
|
||||
Some([major, minor, patch, build])
|
||||
}
|
||||
|
||||
/// Returns (Path to GDB, GDB Version, GDB has Rust Support)
|
||||
/// Returns (Path to GDB, GDB Version)
|
||||
fn analyze_gdb(
|
||||
gdb: Option<String>,
|
||||
target: &str,
|
||||
android_cross_path: &PathBuf,
|
||||
) -> (Option<String>, Option<u32>, bool) {
|
||||
) -> (Option<String>, Option<u32>) {
|
||||
#[cfg(not(windows))]
|
||||
const GDB_FALLBACK: &str = "gdb";
|
||||
#[cfg(windows)]
|
||||
const GDB_FALLBACK: &str = "gdb.exe";
|
||||
|
||||
const MIN_GDB_WITH_RUST: u32 = 7011010;
|
||||
|
||||
let fallback_gdb = || {
|
||||
if is_android_gdb_target(target) {
|
||||
let mut gdb_path = match android_cross_path.to_str() {
|
||||
@ -1076,12 +1066,10 @@ fn analyze_gdb(
|
||||
|
||||
let version = match version_line {
|
||||
Some(line) => extract_gdb_version(&line),
|
||||
None => return (None, None, false),
|
||||
None => return (None, None),
|
||||
};
|
||||
|
||||
let gdb_native_rust = version.map_or(false, |v| v >= MIN_GDB_WITH_RUST);
|
||||
|
||||
(Some(gdb), version, gdb_native_rust)
|
||||
(Some(gdb), version)
|
||||
}
|
||||
|
||||
fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
|
||||
@ -1131,8 +1119,8 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
|
||||
Some(((major * 1000) + minor) * 1000 + patch)
|
||||
}
|
||||
|
||||
/// Returns (LLDB version, LLDB is rust-enabled)
|
||||
fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
|
||||
/// Returns LLDB version
|
||||
fn extract_lldb_version(full_version_line: &str) -> Option<u32> {
|
||||
// Extract the major LLDB version from the given version string.
|
||||
// LLDB version strings are different for Apple and non-Apple platforms.
|
||||
// The Apple variant looks like this:
|
||||
@ -1149,9 +1137,7 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
|
||||
// There doesn't seem to be a way to correlate the Apple version
|
||||
// with the upstream version, and since the tests were originally
|
||||
// written against Apple versions, we make a fake Apple version by
|
||||
// multiplying the first number by 100. This is a hack, but
|
||||
// normally fine because the only non-Apple version we test is
|
||||
// rust-enabled.
|
||||
// multiplying the first number by 100. This is a hack.
|
||||
|
||||
let full_version_line = full_version_line.trim();
|
||||
|
||||
@ -1160,12 +1146,12 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
|
||||
{
|
||||
if let Some(idx) = apple_ver.find(not_a_digit) {
|
||||
let version: u32 = apple_ver[..idx].parse().unwrap();
|
||||
return Some((version, full_version_line.contains("rust-enabled")));
|
||||
return Some(version);
|
||||
}
|
||||
} else if let Some(lldb_ver) = full_version_line.strip_prefix("lldb version ") {
|
||||
if let Some(idx) = lldb_ver.find(not_a_digit) {
|
||||
let version: u32 = lldb_ver[..idx].parse().ok()?;
|
||||
return Some((version * 100, full_version_line.contains("rust-enabled")));
|
||||
return Some(version * 100);
|
||||
}
|
||||
}
|
||||
None
|
||||
|
@ -856,12 +856,10 @@ fn run_debuginfo_gdb_test(&self) {
|
||||
}
|
||||
|
||||
fn run_debuginfo_gdb_test_no_opt(&self) {
|
||||
let prefixes = &["gdb"];
|
||||
|
||||
let dbg_cmds = DebuggerCommands::parse_from(
|
||||
&self.testpaths.file,
|
||||
self.config,
|
||||
prefixes,
|
||||
&["gdb"],
|
||||
self.revision,
|
||||
)
|
||||
.unwrap_or_else(|e| self.fatal(&e));
|
||||
@ -1043,9 +1041,7 @@ fn run_debuginfo_gdb_test_no_opt(&self) {
|
||||
.push_str(&format!("file {}\n", exe_file.to_str().unwrap().replace(r"\", r"\\")));
|
||||
|
||||
// Force GDB to print values in the Rust format.
|
||||
if self.config.gdb_native_rust {
|
||||
script_str.push_str("set language rust\n");
|
||||
}
|
||||
script_str.push_str("set language rust\n");
|
||||
|
||||
// Add line breakpoints
|
||||
for line in &dbg_cmds.breakpoint_lines {
|
||||
@ -1130,21 +1126,11 @@ fn run_debuginfo_lldb_test_no_opt(&self) {
|
||||
}
|
||||
}
|
||||
|
||||
let prefixes = if self.config.lldb_native_rust {
|
||||
static PREFIXES: &[&str] = &["lldb", "lldbr"];
|
||||
println!("NOTE: compiletest thinks it is using LLDB with native rust support");
|
||||
PREFIXES
|
||||
} else {
|
||||
static PREFIXES: &[&str] = &["lldb", "lldbg"];
|
||||
println!("NOTE: compiletest thinks it is using LLDB without native rust support");
|
||||
PREFIXES
|
||||
};
|
||||
|
||||
// Parse debugger commands etc from test files
|
||||
let dbg_cmds = DebuggerCommands::parse_from(
|
||||
&self.testpaths.file,
|
||||
self.config,
|
||||
prefixes,
|
||||
&["lldb"],
|
||||
self.revision,
|
||||
)
|
||||
.unwrap_or_else(|e| self.fatal(&e));
|
||||
|
@ -48,12 +48,12 @@ macro_rules! test { ($($expectation:literal: $input:literal,)*) => {{$(
|
||||
#[test]
|
||||
fn test_extract_lldb_version() {
|
||||
// Apple variants
|
||||
assert_eq!(extract_lldb_version("LLDB-179.5"), Some((179, false)));
|
||||
assert_eq!(extract_lldb_version("lldb-300.2.51"), Some((300, false)));
|
||||
assert_eq!(extract_lldb_version("LLDB-179.5"), Some(179));
|
||||
assert_eq!(extract_lldb_version("lldb-300.2.51"), Some(300));
|
||||
|
||||
// Upstream versions
|
||||
assert_eq!(extract_lldb_version("lldb version 6.0.1"), Some((600, false)));
|
||||
assert_eq!(extract_lldb_version("lldb version 9.0.0"), Some((900, false)));
|
||||
assert_eq!(extract_lldb_version("lldb version 6.0.1"), Some(600));
|
||||
assert_eq!(extract_lldb_version("lldb version 9.0.0"), Some(900));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user