about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo>2014-10-02 11:35:24 +0200
committerMichael Woerister <michaelwoerister@posteo>2014-10-08 08:24:49 +0200
commit895aac9935f8804bf4a3669bbba1caea29c656f2 (patch)
tree57b958dafd2fa1c958e0509698659986f7ddfed6
parent593174b42d522f7c5e90ea18402cf67306e2481d (diff)
downloadrust-895aac9935f8804bf4a3669bbba1caea29c656f2.tar.gz
rust-895aac9935f8804bf4a3669bbba1caea29c656f2.zip
debuginfo: Add LLDB version handling to test infrastructure.
-rwxr-xr-xconfigure6
-rw-r--r--mk/tests.mk1
-rw-r--r--src/compiletest/common.rs3
-rw-r--r--src/compiletest/compiletest.rs38
-rw-r--r--src/compiletest/header.rs39
-rw-r--r--src/compiletest/runtest.rs11
6 files changed, 95 insertions, 3 deletions
diff --git a/configure b/configure
index ad2dd1b8789..aced2fd64db 100755
--- a/configure
+++ b/configure
@@ -535,13 +535,17 @@ probe CFG_LLDB             lldb
 
 if [ ! -z "$CFG_GDB" ]
 then
-    # Extract the version
+    # Store GDB's version
     CFG_GDB_VERSION=$($CFG_GDB --version 2>/dev/null | head -1)
     putvar CFG_GDB_VERSION
 fi
 
 if [ ! -z "$CFG_LLDB" ]
 then
+    # Store LLDB's version
+    CFG_LLDB_VERSION=$($CFG_LLDB --version 2>/dev/null | head -1)
+    putvar CFG_LLDB_VERSION
+
     # If CFG_LLDB_PYTHON_DIR is not already set from the outside and valid, try to read it from
     # LLDB via the -P commandline options.
     if [ -z "$CFG_LLDB_PYTHON_DIR" ] || [ ! -d "$CFG_LLDB_PYTHON_DIR" ]
diff --git a/mk/tests.mk b/mk/tests.mk
index fe2c4cb4151..04be295c271 100644
--- a/mk/tests.mk
+++ b/mk/tests.mk
@@ -625,6 +625,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
         --target $(2) \
         --host $(3) \
         --gdb-version="$(CFG_GDB_VERSION)" \
+        --lldb-version="$(CFG_LLDB_VERSION)" \
         --android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
         --adb-path=$(CFG_ADB) \
         --adb-test-dir=$(CFG_ADB_TEST_DIR) \
diff --git a/src/compiletest/common.rs b/src/compiletest/common.rs
index afe2d071461..4c602b8e1a3 100644
--- a/src/compiletest/common.rs
+++ b/src/compiletest/common.rs
@@ -133,6 +133,9 @@ pub struct Config {
     // Version of GDB
     pub gdb_version: Option<String>,
 
+    // Version of LLDB
+    pub lldb_version: Option<String>,
+
     // Path to the android tools
     pub android_cross_path: Path,
 
diff --git a/src/compiletest/compiletest.rs b/src/compiletest/compiletest.rs
index 1e5e3ebdb34..95bc79f1208 100644
--- a/src/compiletest/compiletest.rs
+++ b/src/compiletest/compiletest.rs
@@ -71,7 +71,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
           optflag("", "jit", "run tests under the JIT"),
           optopt("", "target", "the target to build for", "TARGET"),
           optopt("", "host", "the host to build for", "HOST"),
-          optopt("", "gdb-version", "the version of GDB used", "MAJOR.MINOR"),
+          optopt("", "gdb-version", "the version of GDB used", "VERSION STRING"),
+          optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING"),
           optopt("", "android-cross-path", "Android NDK standalone path", "PATH"),
           optopt("", "adb-path", "path to the android debugger", "PATH"),
           optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
@@ -149,6 +150,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
         target: opt_str2(matches.opt_str("target")),
         host: opt_str2(matches.opt_str("host")),
         gdb_version: extract_gdb_version(matches.opt_str("gdb-version")),
+        lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
         android_cross_path: opt_path(matches, "android-cross-path"),
         adb_path: opt_str2(matches.opt_str("adb-path")),
         adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
@@ -391,3 +393,37 @@ fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
         _ => None
     }
 }
+
+fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
+    // Extract the major LLDB version from the given version string.
+    // LLDB version strings are different for Apple and non-Apple platforms.
+    // At the moment, this function only supports the Apple variant, which looks
+    // like this:
+    //
+    // LLDB-179.5 (older versions)
+    // lldb-300.2.51 (new versions)
+    //
+    // We are only interested in the major version number, so this function
+    // will return `Some("179")` and `Some("300")` respectively.
+
+    match full_version_line {
+        Some(ref full_version_line)
+          if full_version_line.as_slice().trim().len() > 0 => {
+            let full_version_line = full_version_line.as_slice().trim();
+
+            let re = Regex::new(r"[Ll][Ll][Dd][Bb]-([0-9]+)").unwrap();
+
+            match re.captures(full_version_line) {
+                Some(captures) => {
+                    Some(captures.at(1).to_string())
+                }
+                None => {
+                    println!("Could not extract LLDB version from line '{}'",
+                             full_version_line);
+                    None
+                }
+            }
+        },
+        _ => None
+    }
+}
diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs
index cc765695cb7..a9c984d8061 100644
--- a/src/compiletest/header.rs
+++ b/src/compiletest/header.rs
@@ -181,6 +181,34 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
         }
     }
 
+    fn ignore_lldb(config: &Config, line: &str) -> bool {
+        if config.mode != common::DebugInfoLldb {
+            return false;
+        }
+
+        if parse_name_directive(line, "ignore-lldb") {
+            return true;
+        }
+
+        match config.lldb_version {
+            Some(ref actual_version) => {
+                if line.contains("min-lldb-version") {
+                    let min_version = line.trim()
+                                          .split(' ')
+                                          .last()
+                                          .expect("Malformed lldb version directive");
+                    // Ignore if actual version is smaller the minimum required
+                    // version
+                    lldb_version_to_int(actual_version.as_slice()) <
+                        lldb_version_to_int(min_version.as_slice())
+                } else {
+                    false
+                }
+            }
+            None => false
+        }
+    }
+
     let val = iter_header(testfile, |ln| {
         !parse_name_directive(ln, "ignore-test") &&
         !parse_name_directive(ln, ignore_target(config).as_slice()) &&
@@ -188,7 +216,7 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
         !(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) &&
         !(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) &&
         !ignore_gdb(config, ln) &&
-        !(config.mode == common::DebugInfoLldb && parse_name_directive(ln, "ignore-lldb"))
+        !ignore_lldb(config, ln)
     });
 
     !val
@@ -330,3 +358,12 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
 
     return major * 1000 + minor;
 }
+
+pub fn lldb_version_to_int(version_string: &str) -> int {
+    let error_string = format!(
+        "Encountered LLDB version string with unexpected format: {}",
+        version_string);
+    let error_string = error_string.as_slice();
+    let major: int = FromStr::from_str(version_string).expect(error_string);
+    return major;
+}
diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs
index b39ad46bc86..2b52ac65e47 100644
--- a/src/compiletest/runtest.rs
+++ b/src/compiletest/runtest.rs
@@ -626,6 +626,17 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
 
     let exe_file = make_exe_name(config, testfile);
 
+    match config.lldb_version {
+        Some(ref version) => {
+            println!("NOTE: compiletest thinks it is using LLDB version {}",
+                     version.as_slice());
+        }
+        _ => {
+            println!("NOTE: compiletest does not know which version of \
+                      LLDB it is using");
+        }
+    }
+
     // Parse debugger commands etc from test files
     let DebuggerCommands {
         commands,