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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve API documentation and test coverage #11878

Merged
merged 4 commits into from
Dec 4, 2019

Conversation

michalpasztamobica
Copy link
Contributor

@michalpasztamobica michalpasztamobica commented Nov 18, 2019

Description (required)

Harden netsocket APIs in documentation and unittests.
Continuation of the task started in #11808.

Summary of change (What the change is for and why)

I've gone through the Doxygen docs of our APIs and tried to make sure all returnable errors are explicitly mentioned and references are given to underlying APIs, if they can return other errors. Then I went to check if existing unittests cover all the possible return values.

The goal is for the users to be able to only check returnable errors, rather than go through all possible nsapi_error_t values.

The only untested APIs are:

  • L3IP - It includes LWIPStack.h and basically requires full LWIP configuration - quite an overkill for testing what is effectively a wrapper class.
  • fully abstract classes (like DNS, WiFiInterface, MeshInterface) - as they have no code to test. It is also difficult to predict possible return values, as they may depend on the underlying driver implementation.
  • I assumed cellular APIs are under control and supervision of cellular team and did not touch those.

There is one functional change in the return value of PPPInterface function. Reviewers, please pay attention 馃槂 .

I hae also moved OnboardNetworkStackMock function it its own file and explicitly called the file a _mock. I hope this is OK? (Alternatively, we could create a mocks directory, next to the existing stubs, or call the file a _stub, even though it contains a mock).

Documentation (Details of any document updates required)

Pull request type (required)

[x] Patch update (Bug fix / Target update / Docs update / Test update / Refactor)
[] Feature update (New feature / Functionality change / New API)
[] Major update (Breaking change E.g. Return code change / API behaviour change)

Test results (required)

[] No Tests required for this change (E.g docs only update)
[] Covered by existing mbed-os tests (Greentea or Unittest)
[x] Tests / results supplied as part of this PR

Reviewers (optional)

@AnttiKauppila

@ciarmcom ciarmcom requested review from AnttiKauppila and a team November 18, 2019 10:00
@ciarmcom
Copy link
Member

@michalpasztamobica, thank you for your changes.
@AnttiKauppila @ARMmbed/mbed-os-ipcore @ARMmbed/mbed-os-maintainers please review.

@michalpasztamobica
Copy link
Contributor Author

I fixed the doxyspell error and removed one of the _mock files, which I realised wasn't used anywhere in the end.

@michalpasztamobica
Copy link
Contributor Author

@AnttiKauppila , could you review, please?

@bulislaw
Copy link
Member

As it stands it's a breaking change and should target 6.

@@ -80,7 +80,7 @@ nsapi_error_t PPPInterface::disconnect()
if (_interface) {
return _interface->bringdown();
}
return NSAPI_ERROR_OK;
return NSAPI_ERROR_NO_CONNECTION;
Copy link
Contributor

Choose a reason for hiding this comment

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

This functional change might need more than just Fix PPPInterface::disconnect to return NO_CONNECTION or is it that clear ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the remark, @0xc0170 . I amended the commit message, to make sure the reason for this change is clear. Is this ok now?

I think that this code must have never been triggered until I added unittests for it, just now. It's such an obvious bug to return OK if there is no interface...

Copy link
Contributor

Choose a reason for hiding this comment

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

61d0ac8 is still the same or is it different commit?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't the hash of the commit change when amended? The modification looks the same...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I looked through the changes before and after the recent push and they are identical, only the commit message changed now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fix PPPInterface::disconnect to return NO_CONNECTION in case of failure - this is the new commit msg then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes with "in case of failure" added to clarify what has exactly changed.
Did I misunderstand your request? :)

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 22, 2019

Will start CI soon, some 5.15 needs to get in first today

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 22, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Nov 22, 2019

Test run: FAILED

Summary: 1 of 4 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_unittests

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 22, 2019

@michalpasztamobica Please rebase

@michalpasztamobica
Copy link
Contributor Author

@0xc0170 , rebased, resolved conflicts and fixed uninitialized variable that caused valgrind to crash.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 25, 2019

CI started

@mbed-ci
Copy link

mbed-ci commented Nov 25, 2019

Test run: FAILED

Summary: 1 of 4 test jobs failed
Build number : 2
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_unittests

@michalpasztamobica
Copy link
Contributor Author

@0xc0170 , I rebased and fixed the unittest compilation issue (one of the stubs was renamed form .c to .cpp while the PR was being processed). The CI can be restarted.

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 26, 2019

Will start CI when later today

@0xc0170
Copy link
Contributor

0xc0170 commented Nov 28, 2019

I triggered CI but right away noticed the conflicts :/ Please rebase and we shall restart CI

@michalpasztamobica
Copy link
Contributor Author

@0xc0170 , I just rebased and resolved conflicts.

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 2, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Dec 2, 2019

Test run: FAILED

Summary: 1 of 4 test jobs failed
Build number : 4
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_unittests

@michalpasztamobica
Copy link
Contributor Author

Logs are not fully clear to me, but there was an uninitialized variable in one of the newly added tests, which valgrind detected.
Fixed now, @0xc0170 , would you please restart the CI?

@0xc0170
Copy link
Contributor

0xc0170 commented Dec 3, 2019

CI restarted

@mbed-ci
Copy link

mbed-ci commented Dec 3, 2019

Test run: SUCCESS

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

@0xc0170 0xc0170 removed the needs: CI label Dec 4, 2019
@0xc0170 0xc0170 merged commit 4ae8984 into ARMmbed:master Dec 4, 2019
@michalpasztamobica michalpasztamobica deleted the api_hardening branch December 4, 2019 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-version: 6.0.0-alpha-1 First pre-release version of 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants