-
Notifications
You must be signed in to change notification settings - Fork 3k
Unit tests for TCPSocket, TCPServer, UDPSocket, NetworkStack, InternetSocket #8138
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
Conversation
@SeppoTakalo please review |
|
||
TEST_F(TestTCPSocket, constructor_parameters) | ||
{ | ||
TCPSocket socketParam = TCPSocket(dynamic_cast<NetworkStack*>(&stack)); |
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.
As I'm not that experienced with C++ I would like to know why explicit cast is needed here?
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.
To get a runtime exception if casting is not possible.
For example, you modify your stub so that it is not actually inheriting NetworkStack anymore. Dynamic casting catches this error, but static casting does not. It might cause then sefgault.
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.
How does this work with RTTI disabled , or UNITTests have RTTI enabled?
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.
RTTI is by default enabled in GCC. It can be disabled with -fno-rtti flag, but I do not see it used anywhere in the UNITTESTS directory or in the build files, so I assume it remains enabled.
UNITTESTS/stubs/equeue_stub.c
Outdated
@@ -19,10 +19,17 @@ | |||
|
|||
void *equeue_alloc(equeue_t *q, size_t size) | |||
{ | |||
return (void *)malloc(size); |
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.
Unnecessary cast.
@SeppoTakalo @michalpasztamobica Would y'all mind answering @VeijoPesonen's questions? Also, this needs a rebase. |
@cmonr Rebased and fixed the commented issues. |
@OPpuolitaival Please review |
NO. Don't review.. Unittest were failing, but because #8182 is missing from the master, I could not run it on Mac OS X.
|
Add functional and line coverage for UDPSocket and TCPSocket. The EventFlagsstub and NetworkStackstub classes are allowed to store multiple return values to allow running internal loops multiple times.
Added more tests, improved the existing ones. setblocking tests were not checking anything, so they were removed and these functions are called in TCPSocket tests instead.
Most functions are empty or simply return "UNSUPPORTED", but it is still worth covering this functions with unit tests to have better control of unwanted changes.
TCPServer class only really implements attach method.
Improved the stubs for event queue and nsapi_dns, to allow checking if callback are handled correctly. This involves some memory allocation and deallocation. The NetworkStackWrapper is not covered as it seems to be deprecated code.
accept() is not anymore returning NULL pointer. It was a bug.
d9f586d
to
995e30d
Compare
Actually the #8182 DID fix unittesting in Mac OS X, I just did not pick both commits from it.. |
Progress when able! #8182 is now in. |
@SeppoTakalo You're referring to @ARMmbed/mbed-os-maintainers I'm aware that this PR doesn't interact with any of the CI tests, but asking to skip CI opens up the question for other to ask for the favor as well. I'd be considerably more comfortable skipping CI if we had some sort of explicit list detailing exactly when and how we would skip CI. Docs are a good contender, as well as unit tests. |
We got a ticket to cover this and should be resolved soon. Meanwhile /morph build |
Build : SUCCESSBuild number : 3146 Triggering tests/morph test |
@lorjala please review |
Exporter Build : SUCCESSBuild number : 2752 |
Test : FAILUREBuild number : 2950 |
@0xc0170 Needs re-testing. |
@SeppoTakalo Correct. We're working on getting the unittest PR in first before we restart other PRs. |
/morph test |
Test : SUCCESSBuild number : 2965 |
Description
Added unit tests for the following classes TCPSocket, TCPServer, UDPSocket, NetworkStack, InternetSocket.
Apart from the improved coverage (both functional and coverage) some changes were made in stubs to improve their functionality.
Pull request type