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

Add boilerplate unit test code to currently untested modules #14993

Merged
merged 3 commits into from
Aug 17, 2021

Conversation

hazzlim
Copy link
Contributor

@hazzlim hazzlim commented Aug 11, 2021

Summary of changes

In pursuit of increasing unit test coverage of MbedOS, we add the
boilerplate code for unit testing of AnalogIn.cpp and an empty test
source file. This serves two purposes - it allows us to report on
currently untested sources in code coverage data, and it makes it a
little easier for developers to write unit tests for these sources.

The 'empty' test file contains a main function that simply returns. This
is required to allow CMake's add_executable() to be used to pull in the
source file for the SUT, which ensures that this source file is built
and therefore instrumented to generate coverage data. The alternative
that was explored was to instead use Google Test's TEST() macro and
prefix the test name with 'DISABLED_' to skip it, but that resulted in
the test being reported as skipped, which was deemed undesireable for
these 'empty' tests.

Additionally, stubs for analogin_api.c functions are added to the Mbed-stubs-hal library, to allow AnalogIn.cpp to build & to be used by the future unit tests.

Impact of changes

Migration actions required

None.

Documentation

None.

Pull request type

[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

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

Reviewers

@Patater @rwalton-arm @ARMmbed/mbed-os-core

@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Aug 11, 2021
@ciarmcom ciarmcom requested a review from Patater August 11, 2021 09:00
@ciarmcom
Copy link
Member

@hazzlim, thank you for your changes.
@Patater @rwalton-arm @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@rwalton-arm rwalton-arm left a comment

Choose a reason for hiding this comment

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

LGTM, only one question/comment.

drivers/tests/UNITTESTS/AnalogIn/test_analogin.cpp Outdated Show resolved Hide resolved
drivers/tests/UNITTESTS/AnalogIn/test_analogin.cpp Outdated Show resolved Hide resolved
@mergify mergify bot dismissed Patater’s stale review August 11, 2021 16:59

Pull request has been modified.

Patater
Patater previously approved these changes Aug 12, 2021
@Patater Patater changed the title Preliminary Work: Adding boilerplate unit test code to currently untested modules Add boilerplate unit test code to currently untested modules Aug 12, 2021
Unit tests for drivers are currently not checked for style compliance.
We should be checking coding style in unit tests, so we remove them from
the .codecheckignore file.
Currently there are no stub implementations of the analogin_api.c
functions. As the AnalogIn class makes use of these functions, these
stub definitions are required in order to build AnalogIn.cpp and
generate .gcno files to be used to generate code coverage metrics.
In pursuit of increasing unit test coverage of Mbed OS, we add the
boilerplate code for unit testing of AnalogIn.cpp and an empty test
source file. This serves two purposes - it allows us to report on
currently untested sources in code coverage data, and it makes it a
little easier for developers to write unit tests for these sources.

The 'empty' test file contains a main function that simply returns. This
is required to allow CMake's add_executable() to be used to pull in the
source file for the SUT, which ensures that this source file is built
and therefore instrumented to generate coverage data. The alternative
that was explored was to instead use Google Test's TEST() macro and
prefix the test name with 'DISABLED_' to skip it, but that resulted in
the test being reported as skipped, which was deemed undesireable for
these 'empty' tests.
@mergify mergify bot dismissed Patater’s stale review August 16, 2021 09:15

Pull request has been modified.

@hazzlim hazzlim requested a review from Patater August 16, 2021 09:21
@0xc0170
Copy link
Contributor

0xc0170 commented Aug 16, 2021

CI started

Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -35,4 +35,3 @@
^UNITTESTS
^storage/blockdevice/tests/UNITTESTS
^storage/kvstore/tests/UNITTESTS
^drivers/tests/UNITTESTS
Copy link
Contributor

Choose a reason for hiding this comment

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

Just an observation: There seem to be no style changes needed in this commit. The style checking CI is passing. If there were files out of style in drivers/tests/UNITTESTS, this commit would have needed fixes to get those files back in style.

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 Jaeden, noted. I did run astyle on them but they turned out to all be fine, luckily.

@Patater Patater added this to In progress (8) in Mbed Core via automation Aug 16, 2021
@Patater Patater moved this from In progress (8) to Reviewer approved & awaiting CI & merge (3) in Mbed Core Aug 16, 2021
@mbed-ci
Copy link

mbed-ci commented Aug 16, 2021

Jenkins CI Test : ✔️ SUCCESS

Build Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & Artifacts

CLICK for Detailed Summary

jobs Status
jenkins-ci/mbed-os-ci_unittests ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-greentea-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 merged commit acbf352 into ARMmbed:master Aug 17, 2021
Mbed Core automation moved this from Reviewer approved & awaiting CI & merge (3) to Done Aug 17, 2021
@mergify mergify bot removed the ready for merge label Aug 17, 2021
@mbedmain mbedmain added release-version: 6.14.0 Release-pending and removed release-type: patch Indentifies a PR as containing just a patch Release-pending labels Aug 18, 2021
@LDong-Arm LDong-Arm moved this from Done to Reported in Mbed Core Aug 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Mbed Core
  
Reported
Development

Successfully merging this pull request may close these issues.

None yet

8 participants