Skip to content

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

Merged
merged 8 commits into from
Sep 26, 2018

Conversation

michalpasztamobica
Copy link
Contributor

@michalpasztamobica michalpasztamobica commented Sep 14, 2018

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

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

@michalpasztamobica
Copy link
Contributor Author

@SeppoTakalo please review


TEST_F(TestTCPSocket, constructor_parameters)
{
TCPSocket socketParam = TCPSocket(dynamic_cast<NetworkStack*>(&stack));
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@@ -19,10 +19,17 @@

void *equeue_alloc(equeue_t *q, size_t size)
{
return (void *)malloc(size);
Copy link
Contributor

Choose a reason for hiding this comment

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

Unnecessary cast.

@cmonr
Copy link
Contributor

cmonr commented Sep 20, 2018

@SeppoTakalo @michalpasztamobica Would y'all mind answering @VeijoPesonen's questions?

Also, this needs a rebase.

@SeppoTakalo
Copy link
Contributor

@cmonr Rebased and fixed the commented issues.

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 21, 2018

jenkins-ci/unittests — Test job: unstable

@OPpuolitaival Please review

@SeppoTakalo
Copy link
Contributor

SeppoTakalo commented Sep 21, 2018

NO.

Don't review..

Unittest were failing, but because #8182 is missing from the master, I could not run it on Mac OS X.

Should be fixed now. Actually still failing and 8182 did not fix unittests for me, so I need to continue on this on Monday.

michalpasztamobica and others added 7 commits September 21, 2018 14:23
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.
@SeppoTakalo SeppoTakalo force-pushed the master branch 2 times, most recently from d9f586d to 995e30d Compare September 21, 2018 11:31
@SeppoTakalo
Copy link
Contributor

Actually the #8182 DID fix unittesting in Mac OS X, I just did not pick both commits from it..
However, should be fixed now.

@cmonr
Copy link
Contributor

cmonr commented Sep 22, 2018

Progress when able! #8182 is now in.

@SeppoTakalo
Copy link
Contributor

@cmonr this is already done. #8182 was needed for OS X, but our CI is Ubuntu, so this already passed tests.

@cmonr
Copy link
Contributor

cmonr commented Sep 22, 2018

@SeppoTakalo You're referring to jenkins-ci/unittests — Test job: successful, correct?

@ARMmbed/mbed-os-maintainers
@ARMmbed/mbed-os-test
Are we ok with bypassing Jenkins CI with this PR, since it only contains unittest changes?

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.

@0xc0170
Copy link
Contributor

0xc0170 commented Sep 24, 2018

We got a ticket to cover this and should be resolved soon. Meanwhile

/morph build

@mbed-ci
Copy link

mbed-ci commented Sep 24, 2018

Build : SUCCESS

Build number : 3146
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8138/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@OPpuolitaival
Copy link
Contributor

@lorjala please review

@0xc0170 0xc0170 requested a review from lorjala September 24, 2018 06:59
@mbed-ci
Copy link

mbed-ci commented Sep 24, 2018

@mbed-ci
Copy link

mbed-ci commented Sep 24, 2018

@SeppoTakalo
Copy link
Contributor

@0xc0170 Needs re-testing.
Unrelated failure.

@cmonr
Copy link
Contributor

cmonr commented Sep 25, 2018

@SeppoTakalo Correct. We're working on getting the unittest PR in first before we restart other PRs.

@cmonr
Copy link
Contributor

cmonr commented Sep 25, 2018

/morph test

@mbed-ci
Copy link

mbed-ci commented Sep 25, 2018

@0xc0170 0xc0170 merged commit 4957dd5 into ARMmbed:master Sep 26, 2018
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.

8 participants