Skip to content

check_config.h: unit tests #192

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

Conversation

gilles-peskine-arm
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm commented Jul 22, 2025

Unit tests for compile-time configuration checks. A step towards Mbed-TLS/mbedtls#10147.

The tests are done by injecting custom content into the user config files (TF_PSA_CRYPTO_CONFIG_FILE, MBEDTLS_USER_CONFIG_FILE), and running the preprocessor on one C file. So this can't catch #error run in other files, and this can't catch static assertions. Those features might be desirable but they are out of scope here.

With this pull request alone, nothing is added to the CI. This will come on the consuming branches: Mbed-TLS/TF-PSA-Crypto#387 and Mbed-TLS/mbedtls#10319

Follow-up: a framework to generate more config checks in #164.

PR checklist

Unit tests to check whether a configuration is accepted by config checks
done when compilin the library.

The framework provides a class and some smoke tests. It's up to the
consuming branches to provide test cases based on branch-specific knowledge,
and to arrange to run the tests in the CI.

Signed-off-by: Gilles Peskine <[email protected]>
Set the environment variable `UNITTEST_CONFIG_CHECKS_DEBUG` to
dump the preprocessor output to a file if a test case fails.

Signed-off-by: Gilles Peskine <[email protected]>
@gilles-peskine-arm gilles-peskine-arm added size-s Estimated task size: small (~2d) priority-high High priority - will be reviewed soon labels Jul 22, 2025
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review labels Jul 23, 2025
@valeriosetti valeriosetti self-requested a review July 23, 2025 07:35
@valeriosetti valeriosetti self-requested a review July 23, 2025 09:27
@github-project-automation github-project-automation bot moved this from In Development to Has Approval in Roadmap pull requests (new board) Jul 23, 2025
@gilles-peskine-arm gilles-peskine-arm added approved Design and code approved - may be waiting for CI or backports and removed needs-review Every commit must be reviewed by at least two team members, needs-reviewer This PR needs someone to pick it up for review labels Jul 23, 2025
@gilles-peskine-arm gilles-peskine-arm merged commit ba4f660 into Mbed-TLS:main Jul 23, 2025
3 of 4 checks passed
@github-project-automation github-project-automation bot moved this from Has Approval to Done in Roadmap pull requests (new board) Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Design and code approved - may be waiting for CI or backports priority-high High priority - will be reviewed soon size-s Estimated task size: small (~2d)
Development

Successfully merging this pull request may close these issues.

3 participants