github.com/brownsys/tracing-framework-go@v0.0.0-20161210174012-0542a62412fe/other/internal/gls/shim_test.go (about)

     1  // +build !goid
     2  
     3  package gls
     4  
     5  import (
     6  	"math/rand"
     7  	"runtime"
     8  	"sync"
     9  	"testing"
    10  )
    11  
    12  func TestPointerResolution(t *testing.T) {
    13  	vals := rand.Perm(1024)
    14  	var wg sync.WaitGroup
    15  	for i := 0; i < 4*runtime.NumCPU(); i++ {
    16  		wg.Add(1)
    17  		f := func() {
    18  			for i, v := range vals {
    19  				Put(i, v)
    20  			}
    21  			for i, v := range vals {
    22  				got, ok := Get(i)
    23  
    24  				if !ok || got != v {
    25  					t.Errorf("unexpected result: got %v:%v; want true:%v", ok, got, v)
    26  				}
    27  			}
    28  			wg.Done()
    29  		}
    30  		Go(f)
    31  	}
    32  	wg.Wait()
    33  }