...
1
16
17 package loader
18
19 import (
20 "testing"
21 "sync"
22 )
23
24 func Test_registerModuleLockFree(t *testing.T) {
25 n, parallel := 1000, 8
26 head := moduledata{}
27 tail := &head
28 wg := sync.WaitGroup{}
29 wg.Add(parallel)
30 filler := func(n int) {
31 defer wg.Done()
32 for i := 0; i < n; i++ {
33 m := &moduledata{}
34 registerModuleLockFree(&tail, m)
35 }
36 }
37 for i := 0; i < parallel; i++ {
38 go filler(n)
39 }
40 wg.Wait()
41 i := 0
42 for p := head.next; p != nil; p = p.next {
43 i += 1
44 }
45 if i != parallel * n {
46 t.Errorf("got %v, expected %v", i, parallel * n)
47 }
48 }
49
View as plain text