]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: move testSchedLocalQueue* to export_test
authorEmmanuel Odeke <emm.odeke@gmail.com>
Sat, 12 Mar 2016 23:41:08 +0000 (16:41 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sun, 13 Mar 2016 00:34:58 +0000 (00:34 +0000)
Move functions testSchedLocalQueueLocal and testSchedLocalQueueSteal
from proc.go to export_test.go, the only site that they are used.

Fixes #14796

Change-Id: I16b6fa4a13835eab33f66a2c2e87a5f5c79b7bd3
Reviewed-on: https://go-review.googlesource.com/20640
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/runtime/export_test.go
src/runtime/proc.go

index 0f6d9f7c99723354d5f62a66129fcfc58b035cf4..3d29851fa0cb099391df51fcd25238d6cd82fe38 100644 (file)
@@ -53,10 +53,68 @@ func GCMask(x interface{}) (ret []byte) {
 }
 
 func RunSchedLocalQueueTest() {
-       testSchedLocalQueue()
+       _p_ := new(p)
+       gs := make([]g, len(_p_.runq))
+       for i := 0; i < len(_p_.runq); i++ {
+               if g, _ := runqget(_p_); g != nil {
+                       throw("runq is not empty initially")
+               }
+               for j := 0; j < i; j++ {
+                       runqput(_p_, &gs[i], false)
+               }
+               for j := 0; j < i; j++ {
+                       if g, _ := runqget(_p_); g != &gs[i] {
+                               print("bad element at iter ", i, "/", j, "\n")
+                               throw("bad element")
+                       }
+               }
+               if g, _ := runqget(_p_); g != nil {
+                       throw("runq is not empty afterwards")
+               }
+       }
 }
+
 func RunSchedLocalQueueStealTest() {
-       testSchedLocalQueueSteal()
+       p1 := new(p)
+       p2 := new(p)
+       gs := make([]g, len(p1.runq))
+       for i := 0; i < len(p1.runq); i++ {
+               for j := 0; j < i; j++ {
+                       gs[j].sig = 0
+                       runqput(p1, &gs[j], false)
+               }
+               gp := runqsteal(p2, p1, true)
+               s := 0
+               if gp != nil {
+                       s++
+                       gp.sig++
+               }
+               for {
+                       gp, _ = runqget(p2)
+                       if gp == nil {
+                               break
+                       }
+                       s++
+                       gp.sig++
+               }
+               for {
+                       gp, _ = runqget(p1)
+                       if gp == nil {
+                               break
+                       }
+                       gp.sig++
+               }
+               for j := 0; j < i; j++ {
+                       if gs[j].sig != 1 {
+                               print("bad element ", j, "(", gs[j].sig, ") at iter ", i, "\n")
+                               throw("bad element")
+                       }
+               }
+               if s != i/2 && s != i/2+1 {
+                       print("bad steal ", s, ", want ", i/2, " or ", i/2+1, ", iter ", i, "\n")
+                       throw("bad steal")
+               }
+       }
 }
 
 var StringHash = stringHash
index 4aa6b3600e9e151de00c1bd869e2743aafc0d7c1..758a0a898c1d655994dd4711f87c3af1fc023a3e 100644 (file)
@@ -4027,71 +4027,6 @@ func runqsteal(_p_, p2 *p, stealRunNextG bool) *g {
        return gp
 }
 
-func testSchedLocalQueue() {
-       _p_ := new(p)
-       gs := make([]g, len(_p_.runq))
-       for i := 0; i < len(_p_.runq); i++ {
-               if g, _ := runqget(_p_); g != nil {
-                       throw("runq is not empty initially")
-               }
-               for j := 0; j < i; j++ {
-                       runqput(_p_, &gs[i], false)
-               }
-               for j := 0; j < i; j++ {
-                       if g, _ := runqget(_p_); g != &gs[i] {
-                               print("bad element at iter ", i, "/", j, "\n")
-                               throw("bad element")
-                       }
-               }
-               if g, _ := runqget(_p_); g != nil {
-                       throw("runq is not empty afterwards")
-               }
-       }
-}
-
-func testSchedLocalQueueSteal() {
-       p1 := new(p)
-       p2 := new(p)
-       gs := make([]g, len(p1.runq))
-       for i := 0; i < len(p1.runq); i++ {
-               for j := 0; j < i; j++ {
-                       gs[j].sig = 0
-                       runqput(p1, &gs[j], false)
-               }
-               gp := runqsteal(p2, p1, true)
-               s := 0
-               if gp != nil {
-                       s++
-                       gp.sig++
-               }
-               for {
-                       gp, _ = runqget(p2)
-                       if gp == nil {
-                               break
-                       }
-                       s++
-                       gp.sig++
-               }
-               for {
-                       gp, _ = runqget(p1)
-                       if gp == nil {
-                               break
-                       }
-                       gp.sig++
-               }
-               for j := 0; j < i; j++ {
-                       if gs[j].sig != 1 {
-                               print("bad element ", j, "(", gs[j].sig, ") at iter ", i, "\n")
-                               throw("bad element")
-                       }
-               }
-               if s != i/2 && s != i/2+1 {
-                       print("bad steal ", s, ", want ", i/2, " or ", i/2+1, ", iter ", i, "\n")
-                       throw("bad steal")
-               }
-       }
-}
-
 //go:linkname setMaxThreads runtime/debug.setMaxThreads
 func setMaxThreads(in int) (out int) {
        lock(&sched.lock)