mirror of https://github.com/docker/docs.git
Merge pull request #16636 from Microsoft/setrunninglocking
Move setRunningLocking to test code
This commit is contained in:
commit
79dd76b602
|
@ -121,7 +121,7 @@ func wait(waitChan <-chan struct{}, timeout time.Duration) error {
|
|||
// waitRunning waits until state is running. If state is already
|
||||
// running it returns immediately. If you want wait forever you must
|
||||
// supply negative timeout. Returns pid, that was passed to
|
||||
// setRunningLocking.
|
||||
// setRunning.
|
||||
func (s *State) waitRunning(timeout time.Duration) (int, error) {
|
||||
s.Lock()
|
||||
if s.Running {
|
||||
|
@ -178,12 +178,6 @@ func (s *State) getExitCode() int {
|
|||
return res
|
||||
}
|
||||
|
||||
func (s *State) setRunningLocking(pid int) {
|
||||
s.Lock()
|
||||
s.setRunning(pid)
|
||||
s.Unlock()
|
||||
}
|
||||
|
||||
func (s *State) setRunning(pid int) {
|
||||
s.Error = ""
|
||||
s.Running = true
|
||||
|
|
|
@ -18,7 +18,9 @@ func TestStateRunStop(t *testing.T) {
|
|||
atomic.StoreInt64(&pid, int64(runPid))
|
||||
close(started)
|
||||
}()
|
||||
s.setRunningLocking(i + 100)
|
||||
s.Lock()
|
||||
s.setRunning(i + 100)
|
||||
s.Unlock()
|
||||
|
||||
if !s.IsRunning() {
|
||||
t.Fatal("State not running")
|
||||
|
@ -90,7 +92,9 @@ func TestStateTimeoutWait(t *testing.T) {
|
|||
t.Log("Start callback fired")
|
||||
}
|
||||
|
||||
s.setRunningLocking(42)
|
||||
s.Lock()
|
||||
s.setRunning(49)
|
||||
s.Unlock()
|
||||
|
||||
stopped := make(chan struct{})
|
||||
go func() {
|
||||
|
|
Loading…
Reference in New Issue