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

Use config.py as a module in depends.py #6493

Merged
merged 5 commits into from
Mar 2, 2023

Conversation

AndrzejKurek
Copy link
Contributor

@AndrzejKurek AndrzejKurek commented Oct 27, 2022

depends.py now uses config.py to get the available configuration options as well as manipulate the config file.
Fixes #6440.
Backport here

@AndrzejKurek AndrzejKurek added needs-review Every commit must be reviewed by at least two team members, needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review component-test Test framework and CI scripts labels Oct 27, 2022
@AndrzejKurek AndrzejKurek marked this pull request as ready for review October 28, 2022 09:37
@mprse mprse self-requested a review December 1, 2022 11:38
Copy link
Contributor

@mprse mprse left a comment

Choose a reason for hiding this comment

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

PR looks good.
Spotted only 2 places for potential improvements.

Tested script locally. Executed few configs. Works fine and colors are really cool.
It seems that CI is unhappy, but the results are stale.

@@ -72,6 +72,9 @@
import sys
import traceback

import scripts_path # pylint: disable=unused-import

This comment was marked as resolved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

conf.set(option, value)
return True

def unset_config_option(conf, option, colors):
Copy link
Contributor

Choose a reason for hiding this comment

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

Body of set_config_option and unset_config_option is very similar. I suggest to optimize the code and handle set/unset in auxiliary function and then only call auxiliary function with corresponding parameters from set_config_option/unset_config_option.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done :)

Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
log_command(['config.py', 'unset', option])
conf.unset(option)
else:
if value is True:
Copy link
Contributor

Choose a reason for hiding this comment

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

I assume that value can be of Boolean or String type?
Not sure if this is good solution. Safer would be to keep value always as String and assume possible values like: Enable, Disable, <Other Value>.

Then we would have:
set_config_option_value(conf, 'MBEDTLS_TEST_HOOKS', colors, 'Disable')

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to distinguish #define FOO from #define FOO Enable, so no, the current code is right in having a string for #define FOO ... vs True for #define FOO and False for no definition at all.

It would help to convey this through type annotations. value : Union[bool, str] and documentation explaining what I wrote above.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added as a new commit.

Requested config option can be either boolean or a string.
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
mprse
mprse previously approved these changes Jan 24, 2023
Copy link
Contributor

@mprse mprse left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my comments.
LGTM!

Only one thing is strange now that only one parameter has specified type. But it is well described.

Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

The code is a bit roundabout in places, but that's not a big deal and it does what it's supposed to do.

tests/scripts/depends.py Outdated Show resolved Hide resolved
tests/scripts/depends.py Outdated Show resolved Hide resolved
return False
return True

def set_config_option_value(conf, option, colors, value: Union[bool, str]):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this function (without the logging) be in config.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would be an improvement if other scripts provide similar code.

@gilles-peskine-arm gilles-peskine-arm added approved Design and code approved - may be waiting for CI or backports needs-backports Backports are missing or are pending review and approval. and removed needs-review Every commit must be reviewed by at least two team members, needs-ci Needs to pass CI tests needs-reviewer This PR needs someone to pick it up for review labels Feb 4, 2023
As suggested by gilles-peskine-arm.

Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
@gilles-peskine-arm gilles-peskine-arm added needs-review Every commit must be reviewed by at least two team members, and removed approved Design and code approved - may be waiting for CI or backports labels Feb 7, 2023
Copy link
Contributor

@gilles-peskine-arm gilles-peskine-arm left a comment

Choose a reason for hiding this comment

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

Thanks for the improvements!

mprse
mprse previously approved these changes Feb 10, 2023
Copy link
Contributor

@mprse mprse 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 needs to be restarted.

@aditya-deshpande-arm aditya-deshpande-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, labels Feb 14, 2023
As suggested by gilles-peskine-arm.

Co-authored-by: Gilles Peskine <gilles.peskine@arm.com>
Signed-off-by: Andrzej Kurek <andrzej.kurek@arm.com>
@AndrzejKurek
Copy link
Contributor Author

Force-pushed the last commit without changes to re-run the CI.

Copy link
Contributor

@gilles-peskine-arm gilles-peskine-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

@AndrzejKurek AndrzejKurek removed the needs-backports Backports are missing or are pending review and approval. label Mar 1, 2023
@gilles-peskine-arm gilles-peskine-arm merged commit 57897b8 into Mbed-TLS:development Mar 2, 2023
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 component-test Test framework and CI scripts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Depends.py enhancement: config.py inclusion as a module
4 participants