~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_lock/test_lock.py

  • Committer: Aaron Bentley
  • Date: 2007-04-01 04:06:14 UTC
  • mfrom: (2388 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2389.
  • Revision ID: aaron.bentley@utoronto.ca-20070401040614-3f0tytdrc2jtv8f6
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
        # Taking out a lock on a locked file should raise LockContention
107
107
        self.assertRaises(errors.LockContention, self.write_lock, 'a-file')
108
108
 
 
109
    def test_read_unlock_write(self):
 
110
        """Make sure that unlocking allows us to lock write"""
 
111
        a_lock = self.read_lock('a-file')
 
112
        a_lock.unlock()
 
113
        a_lock = self.write_lock('a-file')
 
114
        a_lock.unlock()
 
115
 
 
116
    # TODO: jam 20070319 fcntl read locks are not currently fully
 
117
    #       mutually exclusive with write locks. This will be fixed
 
118
    #       in the next release.
109
119
    def _disabled_test_write_then_read_excludes(self):
110
120
        """If a file is write-locked, taking out a read lock should fail.
111
121
 
116
126
        self.addCleanup(a_lock.unlock)
117
127
        # Taking out a lock on a locked file should raise LockContention
118
128
        self.assertRaises(errors.LockContention, self.read_lock, 'a-file')
 
129
 
 
130
    # TODO: jam 20070319 fcntl write locks are not currently fully
 
131
    #       mutually exclusive with read locks. This will be fixed
 
132
    #       in the next release.
 
133
    def _disabled_test_write_unlock_read(self):
 
134
        """If we have removed the write lock, we can grab a read lock."""
 
135
        a_lock = self.write_lock('a-file')
 
136
        a_lock.unlock()
 
137
        a_lock = self.read_lock('a-file')
 
138
        a_lock.unlock()
 
139
 
 
140
    def _disabled_test_multiple_read_unlock_write(self):
 
141
        """We can only grab a write lock if all read locks are done."""
 
142
        a_lock = b_lock = c_lock = None
 
143
        try:
 
144
            a_lock = self.read_lock('a-file')
 
145
            b_lock = self.read_lock('a-file')
 
146
            self.assertRaises(errors.LockContention, self.write_lock, 'a-file')
 
147
            a_lock.unlock()
 
148
            a_lock = None
 
149
            self.assertRaises(errors.LockContention, self.write_lock, 'a-file')
 
150
            b_lock.unlock()
 
151
            b_lock = None
 
152
            c_lock = self.write_lock('a-file')
 
153
            c_lock.unlock()
 
154
            c_lock = None
 
155
        finally:
 
156
            # Cleanup as needed
 
157
            if a_lock is not None:
 
158
                a_lock.unlock()
 
159
            if b_lock is not None:
 
160
                b_lock.unlock()
 
161
            if c_lock is not None:
 
162
                c_lock.unlock()