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

CMake: unittests: Show all tests in CTest report #14944

Merged
merged 7 commits into from
Jul 28, 2021

Conversation

rwalton-arm
Copy link
Contributor

@rwalton-arm rwalton-arm commented Jul 22, 2021

Summary of changes

Previously a test executable was recognised as a single test by CTest.
However, test executables usually contain multiple test cases, the
results of the test cases should be individually reported. With our
previous setup we could miss test case failures that don't cause the
executable to return an error code.

This commit uses gtest_discover_test to discover all test cases in a
test executable. This enables CTest to match test passes and failures
from the googletest binary output.

This PR also fixes some tests which were dependent on the state of
mocks set in previous tests, meaning they had to be executed in a specific
order or the tests would fail.

Impact of changes

Migration actions required

Documentation


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

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

Reviewers


@mergify mergify bot added the do not merge label Jul 22, 2021
@ciarmcom
Copy link
Member

@rwalton-arm, thank you for your changes.
@ARMmbed/mbed-os-connectivity @ARMmbed/mbed-os-hal @ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

@rwalton-arm
Copy link
Contributor Author

@rwalton-arm, thank you for your changes.
@ARMmbed/mbed-os-connectivity @ARMmbed/mbed-os-hal @ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

This is still a work in progress, I have the following test failures still to fix (previously the failures were being masked because we only showed them as failed if the binary returned an error code):

The following tests FAILED:
        316 - Test_LoRaMac.post_process_mcps_req (SEGFAULT)
        353 - Test_LoRaWANStack.acquire_tx_metadata (Failed)
        354 - Test_LoRaWANStack.acquire_rx_metadata (SEGFAULT)

Previously a test executable was recognised as a single test by CTest.
However, test executables usually contain multiple test cases, the
results of the test cases should be individually reported. With our
previous setup we could miss test case failures that didn't cause the
executable to return an error code.

This commit uses gtest_discover_test to discover all test cases in a
test executable. This enables CTest to match test passes and failures
from the googletest binary output.
Some tests in athandlertest.cpp relied on the state of stubs set in
previous tests. This caused test failures if the tests cases were ran in
isolation. Remove the interdependencies between tests by setting stub
values in the tests that rely on them.
…init_get

Instead of performing 10,000 "set, deinit, get" operations, let's just
perform 100. This reduces test time from 4.8s to 0.02s.
We had commented out a line where we reset LoRaPHY_stub::uint16_value to
0. This was causing an invalid array access in
LoRaMac::handle_data_frame, when trying to extract the
_mps_indication.channel from list of channel_params_t returned by
lora_phy->get_phy_channels.
This test was relying on the state of `LoRaMac_stub::bool_true_counter`
to be set to 1 from a previous test. When the test was ran in isolation
the `LoRaWANStack::rx_timeout_interrupt_handler` callback would fail
because we weren't returning true from the stub implementation of
`LoRaMac::nwk_joined`. Due to this
`LoRaWANStack::post_process_tx_no_reception` was never called. This
caused the LoRaWANStack object to think the "tx_metadata" was "stale"
(i.e the data hadn't changed since any previous read). So, when we
attempted to call `LoRaWANStack::acquire_tx_metadata` it returned
`LORAWAN_STATUS_METADATA_NOT_AVAILABLE` as it thought we had no new
metadata to report, causing the test assertion to fail.
We failed to set `LoRaMac_stub::mlme_ind_ptr` to a valid pointer. When
we tried to dereference it in `LoRaWANStack::process_reception` we hit a
SEGFAULT.
@rwalton-arm rwalton-arm changed the title WIP: CMake: unittests: Show all tests in CTest report CMake: unittests: Show all tests in CTest report Jul 28, 2021
@rwalton-arm rwalton-arm marked this pull request as ready for review July 28, 2021 08:42
@rwalton-arm
Copy link
Contributor Author

@rwalton-arm, thank you for your changes.
@ARMmbed/mbed-os-connectivity @ARMmbed/mbed-os-hal @ARMmbed/mbed-os-core @ARMmbed/mbed-os-maintainers please review.

This is still a work in progress, I have the following test failures still to fix (previously the failures were being masked because we only showed them as failed if the binary returned an error code):

The following tests FAILED:
        316 - Test_LoRaMac.post_process_mcps_req (SEGFAULT)
        353 - Test_LoRaWANStack.acquire_tx_metadata (Failed)
        354 - Test_LoRaWANStack.acquire_rx_metadata (SEGFAULT)

Ready for review now.

@rwalton-arm rwalton-arm linked an issue Jul 28, 2021 that may be closed by this pull request
@Patater Patater self-assigned this Jul 28, 2021
@mbed-ci
Copy link

mbed-ci commented Jul 28, 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 ✔️

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

CI Started

@Patater Patater merged commit 3d36264 into ARMmbed:master Jul 28, 2021
@mergify mergify bot added release version missing When PR does not contain release version, bot should label it and we fix it afterwards and removed ready for merge labels Jul 28, 2021
@mergify
Copy link

mergify bot commented Jul 28, 2021

This PR does not contain release version label after merging.

@0xc0170 0xc0170 added release-type: patch Indentifies a PR as containing just a patch and removed release version missing When PR does not contain release version, bot should label it and we fix it afterwards labels Jul 29, 2021
@0xc0170
Copy link
Contributor

0xc0170 commented Jul 29, 2021

Version fixed

@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
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.

CTest report doesn't show all unit test cases executed
6 participants