xtaci / smux

A Stream Multiplexing Library for golang with least memory usage(TDMA)
MIT License
1.31k stars 196 forks source link

test fails at high possibility #17

Closed rogers0 closed 7 years ago

rogers0 commented 7 years ago

While building debian package, I find go test fails at high possibility (more than 50% as I tested). Enclosed is the log for both FAIL and OK. Hope you have a clue on this. Thank you!

=== RUN   TestReadStreamAfterSessionClose
--- PASS: TestReadStreamAfterSessionClose (0.00s)
        session_test.go:374: broken pipe
=== RUN   TestWriteStreamAfterConnectionClose
--- PASS: TestWriteStreamAfterConnectionClose (0.00s)
=== RUN   TestNumStreamAfterClose
--- PASS: TestNumStreamAfterClose (0.00s)
=== RUN   TestRandomFrame
--- PASS: TestRandomFrame (0.01s)
        session_test.go:497: Version:1 Cmd:188 StreamID:3548764726 Length:284
=== RUN   TestReadDeadline
--- PASS: TestReadDeadline (0.00s)
=== RUN   TestWriteDeadline
--- FAIL: TestWriteDeadline (0.00s)
        session_test.go:550: No error when writing with past deadline
FAIL
exit status 1
FAIL    github.com/xtaci/smux   4.248s
dh_auto_test: go test -v github.com/xtaci/smux returned exit code 1
=== RUN   TestReadStreamAfterSessionClose
--- PASS: TestReadStreamAfterSessionClose (0.00s)
        session_test.go:374: broken pipe
=== RUN   TestWriteStreamAfterConnectionClose
--- PASS: TestWriteStreamAfterConnectionClose (0.00s)
=== RUN   TestNumStreamAfterClose
--- PASS: TestNumStreamAfterClose (0.00s)
=== RUN   TestRandomFrame
--- PASS: TestRandomFrame (0.01s)
        session_test.go:497: Version:1 Cmd:188 StreamID:3548764726 Length:284
=== RUN   TestReadDeadline
--- PASS: TestReadDeadline (0.00s)
=== RUN   TestWriteDeadline
--- PASS: TestWriteDeadline (0.00s)
PASS
ok      github.com/xtaci/smux   4.305s
 fakeroot debian/rules binary
dh binary --buildsystem=golang --with=golang
xtaci commented 7 years ago

I think the problem is the test case:

The WriteDeadline indicates that when a stream blocks, it should return with timeout error when the deadline has reached.

But it doesn't indicate that: when the stream is NOT BLOCKING, the write should return a timeout error when deadline has reached.

I'll try to fix the test, and it's really strange that this doesn't happen on my Mac, travis CI and ubuntu...

rogers0 commented 7 years ago

previous result was got from ubuntu in a virtualbox environment maybe you can reproduce this issue in your virtualbox on mac

xtaci commented 7 years ago

I've rewritten the test, try it

rogers0 commented 7 years ago

@xtaci thanks for your quick fix and sorry about my slow reply. yes, your latest commit fix the test in my virtualbox ubuntu system.

xtaci commented 7 years ago

you're welcome. it's all about the semantic of io.Write interface