summaryrefslogtreecommitdiffstats
path: root/src/sync/export_test.go
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:23:18 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-16 19:23:18 +0000
commit43a123c1ae6613b3efeed291fa552ecd909d3acf (patch)
treefd92518b7024bc74031f78a1cf9e454b65e73665 /src/sync/export_test.go
parentInitial commit. (diff)
downloadgolang-1.20-upstream.tar.xz
golang-1.20-upstream.zip
Adding upstream version 1.20.14.upstream/1.20.14upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/sync/export_test.go')
-rw-r--r--src/sync/export_test.go57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/sync/export_test.go b/src/sync/export_test.go
new file mode 100644
index 0000000..c020ef7
--- /dev/null
+++ b/src/sync/export_test.go
@@ -0,0 +1,57 @@
+// Copyright 2012 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package sync
+
+// Export for testing.
+var Runtime_Semacquire = runtime_Semacquire
+var Runtime_Semrelease = runtime_Semrelease
+var Runtime_procPin = runtime_procPin
+var Runtime_procUnpin = runtime_procUnpin
+
+// poolDequeue testing.
+type PoolDequeue interface {
+ PushHead(val any) bool
+ PopHead() (any, bool)
+ PopTail() (any, bool)
+}
+
+func NewPoolDequeue(n int) PoolDequeue {
+ d := &poolDequeue{
+ vals: make([]eface, n),
+ }
+ // For testing purposes, set the head and tail indexes close
+ // to wrapping around.
+ d.headTail = d.pack(1<<dequeueBits-500, 1<<dequeueBits-500)
+ return d
+}
+
+func (d *poolDequeue) PushHead(val any) bool {
+ return d.pushHead(val)
+}
+
+func (d *poolDequeue) PopHead() (any, bool) {
+ return d.popHead()
+}
+
+func (d *poolDequeue) PopTail() (any, bool) {
+ return d.popTail()
+}
+
+func NewPoolChain() PoolDequeue {
+ return new(poolChain)
+}
+
+func (c *poolChain) PushHead(val any) bool {
+ c.pushHead(val)
+ return true
+}
+
+func (c *poolChain) PopHead() (any, bool) {
+ return c.popHead()
+}
+
+func (c *poolChain) PopTail() (any, bool) {
+ return c.popTail()
+}