Skip to content

Commit

Permalink
test: use pkg/lock instead of stdlib sync
Browse files Browse the repository at this point in the history
Currently the contrib/scripts/lock-check.sh script fails in the CI
runtime tests with:

20:33:58      runtime: contrib/scripts/lock-check.sh
20:33:58      runtime: ./test/ginkgo-ext/scopes.go:	mutex         *sync.Mutex
20:33:58      runtime: ./test/ginkgo-ext/scopes.go:		mutex:   &sync.Mutex{},
20:33:58      runtime: ./test/ginkgo-ext/scopes.go:			mutex:   &sync.Mutex{},
20:33:58      runtime: Found sync.Mutex usage. Please use pkg/lock instead to improve deadlock detection
20:33:58      runtime: Makefile:508: recipe for target 'postcheck' failed
20:33:58      runtime: make: *** [postcheck] Error

Fixes: 9d97e52 ("test: Mend gingko-ext")

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  • Loading branch information
tklauser authored and aanm committed May 27, 2020
1 parent 40320d6 commit e871f28
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/ginkgo-ext/scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ import (
"reflect"
"regexp"
"strings"
"sync"
"sync/atomic"
"time"

"github.com/cilium/cilium/pkg/lock"

"github.com/onsi/ginkgo"
"github.com/onsi/ginkgo/config"
)
Expand All @@ -37,7 +38,7 @@ type scope struct {
parent *scope
children []*scope
counter int32
mutex *sync.Mutex
mutex *lock.Mutex
before []func()
after []func()
afterEach []func()
Expand All @@ -55,7 +56,7 @@ var (
currentScope = &scope{
text: "EntireTestsuite",
counter: -1,
mutex: &sync.Mutex{},
mutex: &lock.Mutex{},
}

rootScope = currentScope
Expand Down Expand Up @@ -467,7 +468,7 @@ func wrapContextFunc(fn func(string, func()) bool, focused bool) func(string, fu
text: currentScope.text + " " + text,
parent: currentScope,
focused: focused,
mutex: &sync.Mutex{},
mutex: &lock.Mutex{},
counter: -1,
}
currentScope.children = append(currentScope.children, newScope)
Expand Down

0 comments on commit e871f28

Please sign in to comment.