Skip to content

Refactor hal greentea cmake #15056

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

Closed
wants to merge 6 commits into from
Closed

Conversation

rajkan01
Copy link
Contributor

@rajkan01 rajkan01 commented Sep 7, 2021

Summary of changes

Fixes #14947

Initially, every library greentea test has its project() creation in their CMake. As running greentea using CTest move all greentea test suite under one global project mbed-os and MBED_CONFIG_PATH set at the root mbed os CMake under the condition BUILD_GREENTEA_TESTS check so refactored hal greentea CMake accordingly.

Impact of changes

The pin_names generic greentea test previously skipped/included based on LED1 and BUTTON1 macros which are defined in targets pinNames.h header file but unfortunately this macro will not be visible at CMake configuration time to find out that test to skip/include, so introduced new CMake command-line argument MBED_HAL_PIN_NAMES_GENERIC_TEST to decide inclusion of pin_names generic test

Migration actions required

User requires to pass -D MBED_HAL_PIN_NAMES_GENERIC_TEST ON to the CMake command-line argument to enable pin_names generic test

Documentation

#15001


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


Initially, every library greentea test has its project() creation in
their CMake. As running greentea using CTest move all greentea test
suite under one global project mbed-os and MBED_CONFIG_PATH set at
the root mbed os CMake under the condition BUILD_GREENTEA_TESTS
check so refactored mbed_hal greentea CMake accordingly.
Initially, every library greentea test has its project() creation in
their CMake. As running greentea using CTest move all greentea test
suite under one global project mbed-os and MBED_CONFIG_PATH set at
the root mbed os CMake under the condition BUILD_GREENTEA_TESTS
check so refactored mbed_hal_fpga_ci_test_shield greentea CMake accordingly.
Initially, every library greentea test has its project() creation in
their CMake. As running greentea using CTest move all greentea test
suite under one global project mbed-os and MBED_CONFIG_PATH set at
the root mbed os CMake under the condition BUILD_GREENTEA_TESTS
check so refactored mbed_timing_fpga_ci_test_shield greentea CMake accordingly.
Added CMake ctest support for pin_names greentea test
@rajkan01 rajkan01 force-pushed the refactor_hal_greentea_cmake branch from 0545df4 to 44057a7 Compare September 7, 2021 12:11
@ciarmcom ciarmcom added the release-type: patch Indentifies a PR as containing just a patch label Sep 7, 2021
@ciarmcom ciarmcom requested a review from a team September 7, 2021 12:30
@ciarmcom
Copy link
Member

ciarmcom commented Sep 7, 2021

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

@mergify mergify bot added needs: CI and removed needs: review labels Sep 9, 2021
@mbed-ci
Copy link

mbed-ci commented Sep 9, 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_cmake-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-example-ARM ✔️
jenkins-ci/mbed-os-ci_cmake-cloud-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-cloud-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_cmake-example-ARM ✔️
jenkins-ci/mbed-os-ci_build-example-GCC_ARM ✔️
jenkins-ci/mbed-os-ci_build-example-ARM ✔️
jenkins-ci/mbed-os-ci_greentea-test ✔️

@0xc0170 0xc0170 requested a review from a team September 9, 2021 11:18
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 9, 2021

@ARMmbed/mbed-os-core Please review

set(TEST_SKIPPED "FPGA CI Test Shield is needed to run this test")
elseif(NOT("TARGET_FF_ARDUINO" IN_LIST MBED_TARGET_DEFINITIONS OR
"TARGET_FF_ARDUINO_UNO" IN_LIST MBED_TARGET_DEFINITIONS) AND
NOT DEFINED MBED_CONF_TARGET_DEFAULT_FORM_FACTOR)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
NOT DEFINED MBED_CONF_TARGET_DEFAULT_FORM_FACTOR)
NOT "MBED_CONF_TARGET_DEFAULT_FORM_FACTOR" IN_LIST MBED_TARGET_DEFINITIONS)

It's an Mbed configuration macro, not a CMake variable. You can only use DEFINED on CMake variables. Same comments for the other files.

Comment on lines +6 to +9
# This test is enabled via CMake command-line argument -DMBED_HAL_PIN_NAMES_GENERIC_TEST=ON.
if(NOT MBED_HAL_PIN_NAMES_GENERIC_TEST)
set(TEST_SKIPPED "Pin names generic test is not enabled for this Target")
endif()
Copy link
Contributor

@LDong-Arm LDong-Arm Sep 9, 2021

Choose a reason for hiding this comment

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

@ARMmbed/mbed-os-core As per the PR description, this test can't be built or run if a target has no LED or button. Such check is not available to CMake, because pins are defined in a header file. As we okay with the idea of an additional CMake variable?

If we want to do this,

Copy link
Contributor

@rwalton-arm rwalton-arm Sep 9, 2021

Choose a reason for hiding this comment

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

@ARMmbed/mbed-os-core As per the PR description, this test can't be built or run if a target has no LED or button. Such check is not available to CMake, because pins are defined in a header file. As we okay with the idea of an additional CMake variable?

If we want to do this,

I had a look at this with @rajkan01 yesterday. Initially I suggested setting SKIP_REGULAR_EXPRESSION and emitting a trace message from the test to set the skipped state. However, @rajkan01 ran into a problem with this approach and it didn't work as expected. In that case an additional variable seemed reasonable (another option would be to add another field to targets.json to say "has_button" or similar, which didn't seem ideal at the time either).

Anyway, now I see the code, I'm not entirely convinced that forcing the user to set this is the best approach. One potential issue: how will CI know when to pass this cache variable? Maybe we have a solution for that, I don't know.

At this point I'm wondering if we should add another field to targets.json, so we can automate skipping/enabling this test. It's not the cleanest solution but it might be the best we can do. It wouldn't really be "test specific" config, as we're describing the available peripherals on the device. This particular test only runs if LED or BUTTON pins are available.

#if !defined LED1 && !defined BUTTON1

If we don't want to add an extra field to targets.json, and we decide the current approach is valid, i.e we want to add extra "user-facing" variables, we should of course document this clearly. We should also add the option so it shows up in ccmake and cmake-gui.

@ciarmcom ciarmcom added the stale Stale Pull Request label Sep 21, 2021
@ciarmcom
Copy link
Member

This pull request has automatically been marked as stale because it has had no recent activity. @rajkan01, please carry out any necessary work to get the changes merged. Thank you for your contributions.

@mergify mergify bot added needs: work and removed needs: work labels Feb 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add CTest support for greentea tests: hal
6 participants