MCPcopy
hub / github.com/dropbox/godropbox / TestReuseSimple

Method TestReuseSimple

sys/filelock/filelock_test.go:119–138  ·  view source on GitHub ↗
(c *C)

Source from the content-addressed store, hash-verified

117}
118
119func (s *FileLockSuite) TestReuseSimple(c *C) {
120 lockName := "testflock2"
121
122 fl1 := New(lockName)
123 fl2 := New(lockName)
124 fl3 := New(lockName)
125
126 // try using fl1 as an exclusive lock
127 c.Assert(fl1.Lock(), IsNil)
128 c.Assert(fl2.TryLock(), NotNil)
129 c.Assert(fl3.TryRLock(), NotNil)
130 c.Assert(fl1.Unlock(), IsNil)
131
132 // now try using fl1 as a read lock
133 c.Assert(fl1.RLock(), IsNil)
134 c.Assert(fl3.RLock(), IsNil)
135 c.Assert(fl2.TryLock(), NotNil)
136 c.Assert(fl1.RUnlock(), IsNil)
137 c.Assert(fl3.RUnlock(), IsNil)
138}
139
140func (s *FileLockSuite) TestAllTransitions(c *C) {
141 wouldBlock := ".*FileLock: would block(.|\n)*"

Callers

nothing calls this directly

Calls 7

NewFunction · 0.70
LockMethod · 0.65
TryLockMethod · 0.65
TryRLockMethod · 0.65
UnlockMethod · 0.65
RLockMethod · 0.65
RUnlockMethod · 0.65

Tested by

no test coverage detected