-
Notifications
You must be signed in to change notification settings - Fork 3k
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
TLSSocketWrapper::recvfrom sets SocketAddress output variable #11169
Conversation
31b1a28
to
9d3fd32
Compare
@dmaziec1, thank you for your changes. |
There was a problem hiding this 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.
UNITTESTS/stubs/stoip4_stub.c
Outdated
* \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) | ||
{ | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
9d3fd32
to
e9059c2
Compare
@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. |
CI started |
Should be fixed as well :) |
Test run: SUCCESSSummary: 11 of 11 test jobs passed |
Description
According to: #10865 . In
TLSSocketWrapper::recvfrom
outputsSocketAddress
the peer address. It is tested by UNITTEST.TLSSocketWrapper
unittest does not use stoip4_stub anymore.Pull request type
Reviewers
@SeppoTakalo
@michalpasztamobica
@kjbracey-arm