mirror of
https://github.com/faucetsdn/ryu.git
synced 2026-05-04 20:06:09 +02:00
hub: add some more tests
Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
parent
47bc96ef98
commit
5003c1634c
@ -186,6 +186,48 @@ class Test_hub(unittest.TestCase):
|
||||
hub.joinall(threads)
|
||||
assert len(result) == 0
|
||||
|
||||
def test_spawn_kill_nowait_joinall(self):
|
||||
# XXX this test relies on the scheduling behaviour.
|
||||
# the intention here is, killing threads before they get active.
|
||||
|
||||
def _child(result):
|
||||
result.append(1)
|
||||
|
||||
threads = []
|
||||
result = []
|
||||
with hub.Timeout(2):
|
||||
threads.append(hub.spawn(_child, result))
|
||||
for t in threads:
|
||||
hub.kill(t)
|
||||
hub.joinall(threads)
|
||||
assert len(result) == 0
|
||||
|
||||
def test_spawn_kill_die_joinall(self):
|
||||
def _child(result):
|
||||
result.append(1)
|
||||
|
||||
threads = []
|
||||
result = []
|
||||
with hub.Timeout(2):
|
||||
threads.append(hub.spawn(_child, result))
|
||||
threads.append(hub.spawn(_child, result))
|
||||
hub.sleep(0.5)
|
||||
for t in threads:
|
||||
hub.kill(t)
|
||||
hub.joinall(threads)
|
||||
assert len(result) == 2
|
||||
|
||||
def test_spawn_exception_joinall(self):
|
||||
def _child():
|
||||
raise Exception("hoge")
|
||||
|
||||
threads = []
|
||||
with hub.Timeout(2):
|
||||
threads.append(hub.spawn(_child))
|
||||
threads.append(hub.spawn(_child))
|
||||
hub.sleep(0.5)
|
||||
hub.joinall(threads)
|
||||
|
||||
def test_event1(self):
|
||||
ev = hub.Event()
|
||||
ev.set()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user