Skip to content

Add Mbed Configuration Option Range Limits #8673

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
merged 7 commits into from
Nov 19, 2018

Conversation

kegilbert
Copy link
Contributor

@kegilbert kegilbert commented Nov 7, 2018

Description

Add optional range limits and accepted value lists to configuration option default and overridden values.

Added some rudimentary tests, let me know if you'd like any more. Will squash after the review period.

Example output with multiple invalid configurations in a Mbed OS build:

Invalid config range for platform.stdio-baud-rate, value 9600 is not in the required range: [115200:-1]    
Invalid config range for drivers.test, value bloep is not an accepted value: [u'bloop', u'bleep']          
Invalid config range for drivers.uart-serial-rxbuf-size, value 256 is not in the required range: [0:100]   
Invalid config range for drivers.uart-serial-txbuf-size, value 256 is not in the required range: [300:-1]                                                                    

You can see the proposed JSON format in the added test files.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[X] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

@kegilbert kegilbert force-pushed the config-range-limits-dev branch from 34827da to c289b5c Compare November 8, 2018 16:15
@kegilbert kegilbert force-pushed the config-range-limits-dev branch from c289b5c to a834794 Compare November 8, 2018 16:19
@kegilbert
Copy link
Contributor Author

kegilbert commented Nov 8, 2018

@theotherjimmy Updated, rebased, and retested.

New error format:

Building project mbed-os (K64F, GCC_ARM)                                                                                           
Scan: mbed-os                                                                                                                      
[ERROR]                                                                                                                            
Invalid config range for drivers.uart-serial-rxbuf-size = 256 (macro name: "MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE"), is not an a
ccepted value: [0, 512]                                                                                                            
Invalid config range for drivers.uart-serial-txbuf-size = 256 (macro name: "MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE"), is not in t
he required range: [-inf:200]                                                                                                      
Invalid config range for platform.stdio-baud-rate = 9600 (macro name: "MBED_CONF_PLATFORM_STDIO_BAUD_RATE"), is not in the required
 range: [115200:inf]                                                                                                               

Copy link
Contributor

@bridadan bridadan left a comment

Choose a reason for hiding this comment

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

Super slick feature! A few questions/suggestions below.

@kegilbert kegilbert force-pushed the config-range-limits-dev branch from d5bca28 to 7a43666 Compare November 13, 2018 22:12
@kegilbert
Copy link
Contributor Author

@theotherjimmy @bridadan Fairly substantial rework to better handle all string/integer formats:

Range Acceptable Value List Both
None X X X
5 ./ ./ X
"5" ./ ./ X
"0x05" ./ ./ X
"Text" X ./ X

As a result it does look a bit grosser than before, let me know your thoughts.

@theotherjimmy Question in regards to:
https://github.com/ARMmbed/mbed-os/blob/master/tools/test/config/config_test.py#L92

This is checking if the expected exception message is in the actual exception string which means if the test throws additional exceptions but the first part of the message stays the same it will pass. For example:

If I expect

Invalid config range for drivers.uart-serial-c1 = 256 (macro name: "MBED_CONF_DRIVERS_UART_SERIAL_C1"), is not an accepted value: 0, 2560, 312                   
Invalid config range settings for drivers.uart-serial-c2 = text (macro name: "MBED_CONF_DRIVERS_UART_SERIAL_C2"). Range specifiers are not applicable to non-deci
mal/hexadecimal string values                                                                                                                                    
Invalid config range for drivers.uart-serial-rxbuf-size = 256 (macro name: "MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE"), is not an accepted value: 0, 255, 312    

but get the same exception with the addition of

Invalid config range for drivers.uart-serial-txbuf-size = 256 (macro name: "MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE"), is not in the required range: [200:250]  

That will pass. Changing that "is in" to a hard check if the strings match one to one causes several other tests to fail such as the duplicate lib test as the actual exception contains path information that we can't hardcode so I'm assuming this was done on purpose. Just a heads up that with how I'm generating exceptions there is a test gap as is.

@bridadan
Copy link
Contributor

Changing that "is in" to a hard check if the strings match one to one causes several other tests to fail such as the duplicate lib test as the actual exception contains path information that we can't hardcode so I'm assuming this was done on purpose.

Huh, very interesting, thanks for checking that. Maybe something like a regular expression would be fitting here?

Copy link
Contributor

@bridadan bridadan left a comment

Choose a reason for hiding this comment

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

Some simplifications and another question or two.

Move JSON accepted value ranges back to JSON array
@kegilbert
Copy link
Contributor Author

@bridadan Refactored, awesome find with the automagic int conversions looks much cleaner. Changed the JSON formats back to the array format, but print out a comma separated string list on exceptions for better readability.

I'll sync with you tomorrow on my thoughts of updating the expected exception message logic.

Copy link
Contributor

@bridadan bridadan left a comment

Choose a reason for hiding this comment

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

Looking really good! Two more little nit picks but I think we're getting there!

@kegilbert
Copy link
Contributor Author

@bridadan Updated!

@cmonr
Copy link
Contributor

cmonr commented Nov 15, 2018

Well darn. @kegilbert Please take a look at the pytest failure.

@cmonr cmonr dismissed stale reviews from bridadan and theotherjimmy November 15, 2018 18:04

PR updated.

@kegilbert
Copy link
Contributor Author

Forgot to update the expected error message in the test case, should be fixed.

Copy link
Contributor

@bridadan bridadan left a comment

Choose a reason for hiding this comment

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

Very nice work! Thanks for being so speedy getting the feedback integrated 👍

@kegilbert
Copy link
Contributor Author

Thanks for giving the feedback!

@cmonr
Copy link
Contributor

cmonr commented Nov 17, 2018

/morph build

@mbed-ci
Copy link

mbed-ci commented Nov 17, 2018

Build : SUCCESS

Build number : 3654
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/8673/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Nov 17, 2018

@mbed-ci
Copy link

mbed-ci commented Nov 17, 2018

Test : SUCCESS

Build number : 3434
Test logs :http://mbed-os-logs.s3-website-us-west-1.amazonaws.com/?prefix=logs/8673/3434

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.

7 participants