Skip to content

Commit d217004

Browse files
committed
runtime: skip TestLldbPython when lldb is too old
The TestLldbPython test is known to fail with very old lldb releases (3.8 and older). Skip the test when the lldb found on the system is too old. Fixes #22299 Change-Id: I8f78d6c0d995118f806dae87f3f04a9726473116 Reviewed-on: https://go-review.googlesource.com/c/139397 Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 6d73537 commit d217004

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/runtime/runtime-lldb_test.go

+23
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import (
1010
"os"
1111
"os/exec"
1212
"path/filepath"
13+
"regexp"
1314
"runtime"
15+
"strconv"
1416
"strings"
1517
"testing"
1618
)
@@ -25,6 +27,27 @@ func checkLldbPython(t *testing.T) {
2527
}
2628
lldbPath = strings.TrimSpace(string(out))
2729

30+
// Check lldb version. The test is known to fail with 3.8 or older
31+
// (see Issue #22299).
32+
cmd = exec.Command("lldb", "--version")
33+
out, err = cmd.CombinedOutput()
34+
35+
// lldb --version should print "lldb version a.b.c"
36+
re := regexp.MustCompile(` ([[:digit:]]+)\.([[:digit:]]+)`)
37+
lldbVersion := re.FindStringSubmatch(string(out))
38+
if len(lldbVersion) != 3 {
39+
t.Errorf("bad lldb --version output: %s", out)
40+
}
41+
major, err1 := strconv.Atoi(lldbVersion[1])
42+
minor, err2 := strconv.Atoi(lldbVersion[2])
43+
if err1 != nil || err2 != nil {
44+
t.Errorf("bad lldb --version output: %s", out)
45+
}
46+
47+
if (major < 3) || (major == 3 && minor < 9) {
48+
t.Skipf("skipping because lldb version %v.%v is too old (need >= 3.9)", major, minor)
49+
}
50+
2851
cmd = exec.Command("/usr/bin/python2.7", "-c", "import sys;sys.path.append(sys.argv[1]);import lldb; print('go lldb python support')", lldbPath)
2952
out, err = cmd.CombinedOutput()
3053

0 commit comments

Comments
 (0)