Skip to content

Commit 914a25c

Browse files
committed
runtime: only check the existence of variables in gdb info locals test
As discussed in golang.org/cl/28499: Only test that all expected variables are listed in 'info locals' since different versions of gdb print variables in different order and with differing amount of information and formats. Fixes #28499 Change-Id: I76627351170b5fdf2bf8cbf143e54f628b45dc4e Reviewed-on: https://go-review.googlesource.com/c/146598 Reviewed-by: Heschi Kreinick <[email protected]>
1 parent 484fc06 commit 914a25c

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/runtime/runtime-gdb_test.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,13 @@ func testGdbPython(t *testing.T, cgo bool) {
262262
// However, the newer dwarf location list code reconstituted
263263
// aggregates from their fields and reverted their printing
264264
// back to its original form.
265+
// Only test that all variables are listed in 'info locals' since
266+
// different versions of gdb print variables in different
267+
// order and with differing amount of information and formats.
265268

266-
infoLocalsRe1 := regexp.MustCompile(`slicevar *= *\[\]string *= *{"def"}`)
267-
// Format output from gdb v8.2
268-
infoLocalsRe2 := regexp.MustCompile(`^slicevar = .*\nmapvar = .*\nstrvar = 0x[0-9a-f]+ "abc"`)
269-
// Format output from gdb v7.7
270-
infoLocalsRe3 := regexp.MustCompile(`^mapvar = .*\nstrvar = "abc"\nslicevar *= *\[\]string`)
271-
if bl := blocks["info locals"]; !infoLocalsRe1.MatchString(bl) &&
272-
!infoLocalsRe2.MatchString(bl) &&
273-
!infoLocalsRe3.MatchString(bl) {
269+
if bl := blocks["info locals"]; !strings.Contains(bl, "slicevar") ||
270+
!strings.Contains(bl, "mapvar") ||
271+
!strings.Contains(bl, "strvar") {
274272
t.Fatalf("info locals failed: %s", bl)
275273
}
276274

0 commit comments

Comments
 (0)