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

TLSSocketWrapper::recvfrom sets SocketAddress output variable #11169

Merged
merged 1 commit into from
Aug 20, 2019

Conversation

dmaziec
Copy link
Contributor

@dmaziec dmaziec commented Aug 6, 2019

Description

According to: #10865 . In TLSSocketWrapper::recvfrom outputs SocketAddress the peer address. It is tested by UNITTEST. TLSSocketWrapper unittest does not use stoip4_stub anymore.

Pull request type

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

Reviewers

@SeppoTakalo
@michalpasztamobica
@kjbracey-arm

@dmaziec dmaziec force-pushed the TLSSocketWrapper_recvfrom_modified branch from 31b1a28 to 9d3fd32 Compare August 6, 2019 09:46
@ciarmcom
Copy link
Member

ciarmcom commented Aug 6, 2019

@dmaziec1, thank you for your changes.
@SeppoTakalo @kjbracey-arm @michalpasztamobica @ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@SeppoTakalo SeppoTakalo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix looks OK, but I would prefer not to copy the stoip4() into the stub folder.
If we require the original code in this case, we should include it in the test.

* \param dest buffer for address. MUST be 4 bytes.
* \return boolean set to true if conversion succeded, false if it didn't
*/
bool stoip4(const char *ip4addr, size_t len, void *dest)
{

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of copying the stoip4() function here, can we modify the build scripts to include the original code.

Maintaining a stub and original, which both are identical, does not make sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not exactly the original. It never returns false and doesn't even perform all the checks, so it can be safely used in other tests, which don't really care about the data being copied or not, and would do fine with an empty stub.
However, to check that the getpeername works we need to perform the copy in this one place - hence the copying algorithm runs if the inputs are valid.
If we were to use the actual function we would have to guarantee the input parameters validity. Should we?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remove the usage of this stub from TLSSocket tests, it passes OK.

$ git diff
diff --git i/UNITTESTS/features/netsocket/TLSSocketWrapper/unittest.cmake w/UNITTESTS/features/netsocket/TLSSocketWrapper/unittest.cmake
index 2ff13c2dc6..d126328baf 100644
--- i/UNITTESTS/features/netsocket/TLSSocketWrapper/unittest.cmake
+++ w/UNITTESTS/features/netsocket/TLSSocketWrapper/unittest.cmake
@@ -28,8 +28,6 @@ set(unittest-test-sources
   stubs/mbed_shared_queues_stub.cpp
   stubs/nsapi_dns_stub.cpp
   stubs/EventFlags_stub.cpp
-  stubs/stoip4_stub.c
-  stubs/ip4tos_stub.c
   stubs/SocketStats_Stub.cpp
 )

Notice that UNITTESTS/features/netsocket/TLSSocketWrapper/unittest.cmake already seem to include the original stoip4()

I does not seem to require getpeername(), that is tested elsewhere.

Copy link
Contributor Author

@dmaziec dmaziec Aug 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good point. We haven't tried it before, but it works.

UNITTEST added. TLSSocketWrapper unittest does not use stoip4_stub anymore.
@dmaziec dmaziec force-pushed the TLSSocketWrapper_recvfrom_modified branch from 9d3fd32 to e9059c2 Compare August 6, 2019 13:09
@michalpasztamobica
Copy link
Contributor

@0xc0170 , I cannot rerun the failed job, but I believe if you do, we will be able to merge this, as it's reviewed and approved.
Unless, @kjbracey-arm , would like to have a final word, as the original author of the issue report? :)

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 19, 2019

CI started

@0xc0170
Copy link
Contributor

0xc0170 commented Aug 19, 2019

continuous-integration/jenkins/pr-merge

Should be fixed as well :)

@mbed-ci
Copy link

mbed-ci commented Aug 19, 2019

Test run: SUCCESS

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

@0xc0170 0xc0170 merged commit 64fb49e into ARMmbed:master Aug 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants