Commit b51b8d5d authored by Kirill Smelkov's avatar Kirill Smelkov

select: Run tests more thoroughly

With more iterations it triggers a bug:

	kirr@deco:~/src/tools/go/pygolang$ py.test -vsx
	============================================== test session starts ===============================================
	platform linux2 -- Python 2.7.15+, pytest-3.6.4, py-1.6.0, pluggy-0.6.0 -- /usr/bin/python2
	cachedir: .pytest_cache
	rootdir: /home/kirr/src/tools/go/pygolang, inifile:
	collected 7 items

	golang/_gopath_test.py::test_import_module PASSED
	golang/_gopath_test.py::test_import_package PASSED
	golang/gcompat_test.py::test_qq PASSED
	golang/golang_test.py::test_go PASSED
	golang/golang_test.py::test_chan PASSED
	golang/golang_test.py::test_select Exception in thread Thread-117:
	Traceback (most recent call last):
	  File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
	    self.run()
	  File "/usr/lib/python2.7/threading.py", line 754, in run
	    self.__target(*self.__args, **self.__kwargs)
	  File "/home/kirr/src/tools/go/pygolang/golang/golang_test.py", line 320, in _
	    assert (_, _rx) == (1, 'b')
	AssertionError: assert (1, 'xxx1') == (1, 'b')
	  At index 1 diff: 'xxx1' != 'b'
	  Full diff:
	  - (1, 'xxx1')
	  + (1, 'b')
parent ec929991
...@@ -137,6 +137,8 @@ def test_chan(): ...@@ -137,6 +137,8 @@ def test_chan():
def test_select(): def test_select():
N = 1000 # times to do repeated select/chan or select/select interactions
# non-blocking try send: not ok # non-blocking try send: not ok
ch = chan() ch = chan()
_, _rx = select( _, _rx = select(
...@@ -172,7 +174,7 @@ def test_select(): ...@@ -172,7 +174,7 @@ def test_select():
done.close() done.close()
go(_) go(_)
for i in range(10): for i in range(N):
tdelay() tdelay()
_, _rx = select( _, _rx = select(
(ch.send, i), (ch.send, i),
...@@ -186,12 +188,12 @@ def test_select(): ...@@ -186,12 +188,12 @@ def test_select():
ch = chan() ch = chan()
done = chan() done = chan()
def _(): def _():
for i in range(10): for i in range(N):
ch.send(i) ch.send(i)
done.close() done.close()
go(_) go(_)
for i in range(10): for i in range(N):
tdelay() tdelay()
if i % 2: if i % 2:
_, _rx = select( _, _rx = select(
...@@ -290,7 +292,7 @@ def test_select(): ...@@ -290,7 +292,7 @@ def test_select():
# buffered ping-pong # buffered ping-pong
ch = chan(1) ch = chan(1)
for i in range(10): for i in range(N):
_, _rx = select( _, _rx = select(
(ch.send, i), (ch.send, i),
ch.recv, ch.recv,
...@@ -300,7 +302,7 @@ def test_select(): ...@@ -300,7 +302,7 @@ def test_select():
# select vs select # select vs select
for i in range(10): for i in range(N):
ch1 = chan() ch1 = chan()
ch2 = chan() ch2 = chan()
done = chan() done = chan()
......
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