| 117 | } |
| 118 | |
| 119 | func (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 | |
| 140 | func (s *FileLockSuite) TestAllTransitions(c *C) { |
| 141 | wouldBlock := ".*FileLock: would block(.|\n)*" |