diff options
| author | Paul Nasrat <pnasrat@google.com> | 2015-01-14 14:32:01 -0500 |
|---|---|---|
| committer | Ian Lance Taylor <iant@golang.org> | 2015-01-15 05:20:19 +0000 |
| commit | a25af2e99e21fe9011d4057cfab1e0cb0ffb3cdb (patch) | |
| tree | 06e5bbc0aac9be5f79c09c2c627bd2dcfd8e56ce /src/runtime/runtime-gdb_test.go | |
| parent | 7785be8f2227df881e7ab3a4e81a2fc69a165cf8 (diff) | |
| download | go-a25af2e99e21fe9011d4057cfab1e0cb0ffb3cdb.tar.xz | |
runtime: fix runtime-gdb script loading
runtime.rtype was a copy of reflect.rtype - update script to use that directly.
Introduces a basic test which will skip on systems without appropriate GDB.
Fixes #9326
Change-Id: I6ec74e947bd2e1295492ca34b3a8c1b49315a8cb
Reviewed-on: https://go-review.googlesource.com/2821
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/runtime/runtime-gdb_test.go')
| -rw-r--r-- | src/runtime/runtime-gdb_test.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go new file mode 100644 index 0000000000..4a74dd372a --- /dev/null +++ b/src/runtime/runtime-gdb_test.go @@ -0,0 +1,59 @@ +package runtime_test + +import ( + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "testing" +) + +func checkGdbPython(t *testing.T) { + cmd := exec.Command("gdb", "-nx", "-q", "--batch", "-ex", "python import sys; print('golang gdb python support')") + out, err := cmd.CombinedOutput() + + if err != nil { + t.Skipf("skipping due to issue running gdb%v", err) + } + if string(out) != "golang gdb python support\n" { + t.Skipf("skipping due to lack of python gdb support: %s", out) + } +} + +const helloSource = ` +package main +import "fmt" +func main() { + fmt.Println("hi") +} +` + +func TestGdbLoadRuntimeSupport(t *testing.T) { + + checkGdbPython(t) + + dir, err := ioutil.TempDir("", "go-build") + if err != nil { + t.Fatalf("failed to create temp directory: %v", err) + } + defer os.RemoveAll(dir) + + src := filepath.Join(dir, "main.go") + err = ioutil.WriteFile(src, []byte(helloSource), 0644) + if err != nil { + t.Fatalf("failed to create file: %v", err) + } + + cmd := exec.Command("go", "build", "-o", "a.exe") + cmd.Dir = dir + out, err := cmd.CombinedOutput() + if err != nil { + t.Fatalf("building source %v\n%s", err, out) + } + + got, _ := exec.Command("gdb", "-nx", "-q", "--batch", "-ex", "source runtime-gdb.py", + filepath.Join(dir, "a.exe")).CombinedOutput() + if string(got) != "Loading Go Runtime support.\n" { + t.Fatalf("%s", got) + } +} |
