Commit c5810987 authored by Kirill Smelkov's avatar Kirill Smelkov

golang: Run all select tests "more thoroughly"

Starting from b51b8d5d (select: Run tests more thoroughly) we are
running select subtests in repeated mode with N=1000. However not all
select subtests were run in repeated mode - for example e.g.
"non-blocking try send: not ok" was being run only once.

-> Rework all select subtests to be run in repeated mode to increase the
probability of catching bugs.
parent fa667412
......@@ -207,6 +207,7 @@ def test_select():
# non-blocking try send: not ok
ch = chan()
for i in range(N):
_, _rx = select(
(ch.send, 0),
default,
......@@ -214,6 +215,7 @@ def test_select():
assert (_, _rx) == (1, None)
# non-blocking try recv: not ok
for i in range(N):
_, _rx = select(
ch.recv,
default,
......@@ -281,16 +283,22 @@ def test_select():
ch2 = chan()
done = chan()
def _():
while 1:
waitBlocked(ch1.send)
assert ch1.recv() == 'a'
x = ch1.recv()
if x == 'stop':
break
assert x == 'a'
done.close()
go(_)
for i in range(N):
_, _rx = select(
(ch1.send, 'a'),
(ch2.send, 'b'),
)
assert (_, _rx) == (0, None)
ch1.send('stop')
done.recv()
assert len_sendq(ch1) == len_recvq(ch1) == 0
assert len_sendq(ch2) == len_recvq(ch2) == 0
......@@ -301,11 +309,13 @@ def test_select():
ch2 = chan()
done = chan()
def _():
for i in range(N):
waitBlocked(ch1.recv)
ch1.send('a')
done.close()
go(_)
for i in range(N):
_, _rx = select(
ch1.recv,
ch2.recv,
......@@ -321,16 +331,22 @@ def test_select():
ch2 = chan()
done = chan()
def _():
while 1:
waitBlocked(ch1.send)
assert ch1.recv() == 'a'
x = ch1.recv()
if x == 'stop':
break
assert x == 'a'
done.close()
go(_)
for i in range(N):
_, _rx = select(
(ch1.send, 'a'),
ch2.recv,
)
assert (_, _rx) == (0, None)
ch1.send('stop')
done.recv()
assert len_sendq(ch1) == len_recvq(ch1) == 0
assert len_sendq(ch2) == len_recvq(ch2) == 0
......@@ -341,11 +357,13 @@ def test_select():
ch2 = chan()
done = chan()
def _():
for i in range(N):
waitBlocked(ch1.recv)
ch1.send('a')
done.close()
go(_)
for i in range(N):
_, _rx = select(
ch1.recv,
(ch2.send, 'b'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment