aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/export_test.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2020-07-14 21:39:52 +0000
committerMichael Knyszek <mknyszek@google.com>2020-10-23 22:33:17 +0000
commite01a1c01f830e2398b773b803dce3238b1107ce9 (patch)
treeb20b5fb52e74ce63e46033447cd4c7aa1b5cabc7 /src/runtime/export_test.go
parent9db7db54b0e84d6b3ace94cb1f2a42e065575f17 (diff)
downloadgo-e01a1c01f830e2398b773b803dce3238b1107ce9.tar.gz
go-e01a1c01f830e2398b773b803dce3238b1107ce9.zip
runtime: add tests for addrRanges.findSucc
This change adds a test suite for addrRanges.findSucc so we can change the implementation more safely. For #40191. Change-Id: I14a834b6d54836cbc676eb0edb292ba6176705cc Reviewed-on: https://go-review.googlesource.com/c/go/+/242678 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Diffstat (limited to 'src/runtime/export_test.go')
-rw-r--r--src/runtime/export_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go
index 25b251f4ba..605bcb2294 100644
--- a/src/runtime/export_test.go
+++ b/src/runtime/export_test.go
@@ -785,6 +785,30 @@ func (a AddrRange) Equals(b AddrRange) bool {
return a == b
}
+// AddrRanges is a wrapper around addrRanges for testing.
+type AddrRanges struct {
+ addrRanges
+}
+
+// MakeAddrRanges creates a new addrRanges populated with
+// the ranges in a.
+func MakeAddrRanges(a ...AddrRange) AddrRanges {
+ // Methods that manipulate the backing store of addrRanges.ranges should
+ // not be used on the result from this function (e.g. add) since they may
+ // trigger reallocation.
+ ranges := make([]addrRange, 0, len(a))
+ for _, r := range a {
+ ranges = append(ranges, r.addrRange)
+ }
+ return AddrRanges{addrRanges{ranges: ranges, sysStat: new(uint64)}}
+}
+
+// FindSucc returns the successor to base. See addrRanges.findSucc
+// for more details.
+func (a *AddrRanges) FindSucc(base uintptr) int {
+ return a.findSucc(base)
+}
+
// BitRange represents a range over a bitmap.
type BitRange struct {
I, N uint // bit index and length in bits