Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tcpsocket tests to use sigio and not to wait #9794

Merged
merged 1 commit into from Feb 26, 2019

Conversation

@michalpasztamobica
Copy link
Contributor

commented Feb 21, 2019

Description

As previously done for TLSSockets - we don't want the receiver thread to do a busy wait.
I decided not to touch the UDPSocket echo tests as they do packet counting (and accept some missing packets ratio), so the design there would have to be different, but if you think it's reasonable to rewrite that test to, I can do it as well.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[x] Test update
[ ] Breaking change

Reviewers

@SeppoTakalo
@AriParkkila
@VeijoPesonen
@KariHaapalehto
@mtomczykmobica
@tymoteuszblochmobica

TESTS/netsocket/tcp/tcpsocket_echotest.cpp Outdated
continue;
} else if (recvd < 0) {
TEST_FAIL();
int recvd = sock.recv(&(tcp_global::rx_buffer[bytes2recv_total - bytes2recv]), bytes2recv);

This comment has been minimized.

Copy link
@SeppoTakalo

SeppoTakalo Feb 21, 2019

Contributor

I don't think you should remove the while() loop.

You are supposed to loop UNTIl you get the WOULD_BLOCK.

Only then you are guaranteed to receive sigio() event.

This comment has been minimized.

Copy link
@michalpasztamobica

michalpasztamobica Feb 21, 2019

Author Contributor

Not sure I understand correctly... The tcpsocket_echotest_nonblock_receive() function is called from sigio handler. I thought it is supposed to trigger on the event to be sure the data is there waiting to be read?
Perhaps I am missing something about how the sigio works?

This comment has been minimized.

Copy link
@SeppoTakalo

SeppoTakalo Feb 21, 2019

Contributor

For example, if the driver received 2kB of data.. sends sigio() event to notify that there is new data to be read, and you read 1kB. It does not send another event, because there was not change in the state.. the device is still readable.

This comment has been minimized.

Copy link
@SeppoTakalo

SeppoTakalo Feb 21, 2019

Contributor

sigio() notifies that there is change of state.

readable -> not readable or
not readable -> readable or
connected -> disconnected or
connecting -> connected or
new connections acceptable -> no new connections
etc...

This comment has been minimized.

Copy link
@michalpasztamobica

michalpasztamobica Feb 21, 2019

Author Contributor

Now I see. Then I will also fix the tlssocket echo tests as I made the same mistake there some time ago.

This comment has been minimized.

Copy link
@michalpasztamobica

michalpasztamobica Feb 22, 2019

Author Contributor

Brough the loop back into the receiver both for tcp and tls socket tests. Thanks for pointing this out!

@ciarmcom ciarmcom requested review from AriParkkila, KariHaapalehto, mtomczykmobica, SeppoTakalo, tymoteuszblochmobica, VeijoPesonen and ARMmbed/mbed-os-maintainers Feb 21, 2019

@michalpasztamobica michalpasztamobica force-pushed the michalpasztamobica:greentea_tcpsocket_sigio branch Feb 22, 2019

Show resolved Hide resolved TESTS/netsocket/tls/tlssocket_echotest.cpp Outdated

@michalpasztamobica michalpasztamobica force-pushed the michalpasztamobica:greentea_tcpsocket_sigio branch Feb 25, 2019

@michalpasztamobica

This comment has been minimized.

Copy link
Contributor Author

commented Feb 25, 2019

@VeijoPesonen , thanks for your remarks. I just pushed improved code.

Show resolved Hide resolved TESTS/netsocket/tls/tlssocket_echotest.cpp Outdated

@michalpasztamobica michalpasztamobica force-pushed the michalpasztamobica:greentea_tcpsocket_sigio branch to 999273f Feb 25, 2019

@cmonr cmonr requested review from SeppoTakalo, OPpuolitaival and VeijoPesonen and removed request for SeppoTakalo and OPpuolitaival Feb 25, 2019

@cmonr

cmonr approved these changes Feb 25, 2019

Copy link
Contributor

left a comment

LGTM

@cmonr

This comment has been minimized.

Copy link
Contributor

commented Feb 26, 2019

CI started while waiting on one or two more people to complete reviews

@cmonr cmonr added needs: CI and removed needs: review labels Feb 26, 2019

@mbed-ci

This comment has been minimized.

Copy link

commented Feb 26, 2019

Test run: SUCCESS

Summary: 10 of 10 test jobs passed
Build number : 1
Build artifacts

@0xc0170 0xc0170 merged commit b08ddaa into ARMmbed:master Feb 26, 2019

25 checks passed

continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci/build-ARM Success
Details
jenkins-ci/build-ARMC6 Success
Details
jenkins-ci/build-GCC_ARM Success
Details
jenkins-ci/build-IAR Success
Details
jenkins-ci/dynamic-memory-usage RTOS ROM(+0 bytes) RAM(+0 bytes)
Details
jenkins-ci/exporter Success
Details
jenkins-ci/greentea-test Success
Details
jenkins-ci/mbed2-build-ARM Success
Details
jenkins-ci/mbed2-build-GCC_ARM Success
Details
jenkins-ci/mbed2-build-IAR Success
Details
travis-ci/astyle Local astyle testing has passed
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/doxy-spellcheck Local doxy-spellcheck testing has passed
Details
travis-ci/events Passed, runtime is 10442 cycles (-65 cycles)
Details
travis-ci/gitattributestest Local gitattributestest testing has passed
Details
travis-ci/include_check Local include_check testing has passed
Details
travis-ci/licence_check Local licence_check testing has passed
Details
travis-ci/littlefs Passed, code size is 8408B (+0.00%)
Details
travis-ci/psa-autogen Local psa-autogen testing has passed
Details
travis-ci/tools-py2.7 Local tools-py2.7 testing has passed
Details
travis-ci/tools-py3.5 Local tools-py3.5 testing has passed
Details
travis-ci/tools-py3.6 Local tools-py3.6 testing has passed
Details
travis-ci/tools-py3.7 Local tools-py3.7 testing has passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.