Test code where gate is closed successfully
()
| 196 | |
| 197 | |
| 198 | def test1(): |
| 199 | """ Test code where gate is closed successfully """ |
| 200 | |
| 201 | print 'test1()...' |
| 202 | |
| 203 | gate = ThreadGate(10, 20) |
| 204 | |
| 205 | random.seed() |
| 206 | |
| 207 | print 'Starting threads...' |
| 208 | # Create 10 threads |
| 209 | threads = [] |
| 210 | threads.append(OwnerThread(gate)) |
| 211 | |
| 212 | for x in range(10): |
| 213 | threads.append(SampleThread(x, gate)) |
| 214 | |
| 215 | # Start threads and join |
| 216 | for x in range(11): |
| 217 | threads[x].start() |
| 218 | |
| 219 | |
| 220 | # Join with threads |
| 221 | for x in range(11): |
| 222 | threads[x].join() |
| 223 | |
| 224 | print 'Joined with threads' |
| 225 | print 'Gate count=>',gate.get_count() |
| 226 | |
| 227 | # Exit and entry logs must be same |
| 228 | print enterlog |
| 229 | print exitlog |
| 230 | |
| 231 | def test2(): |
| 232 | """ Test code where gate is closed unsuccessfully """ |
no test coverage detected