-
Notifications
You must be signed in to change notification settings - Fork 8.2k
tests: time_units: check for overflow in z_tmcvt intermediate #52936
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
tests: time_units: check for overflow in z_tmcvt intermediate #52936
Conversation
377d651 to
497810d
Compare
tests/unit/time_units/testcase.yaml
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not critical or blocking, but this is weird yaml. Does utilities.time_units.z_tmcvt: {} work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a YAML n00b, so my guess is it will. Are there other instances of that in-tree?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mbolivar-nordic - Fixed!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a YAML n00b, so my guess is it will.
I guess you tested it? My working tree is busy with another branch rn, which is why I phrased it as a question
Are there other instances of that in-tree?
I don't know -- did you copy/paste it from somewhere?
My example is definitely valid YAML, it just creates an empty dictionary in the test specification:
In [21]: yaml_str = '''
...: common:
...: tags: time_units
...: type: unit
...: tests:
...: utilities.time_units.z_tmvct: {}
...: '''
In [22]: yaml.safe_load(yaml_str)
Out[22]:
{'common': {'tags': 'time_units', 'type': 'unit'},
'tests': {'utilities.time_units.z_tmvct': {}}}
from the comment on line 7 above, it looked to me like someone was looking for a way to have a dict key which mapped to an empty dict, but didn't know how to spell that in YAML.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a YAML n00b, so my guess is it will.
I guess you tested it?
Yep
Are there other instances of that in-tree?
I don't know -- did you copy/paste it from somewhere?
There is 1 instance of {} that I have found in-tree with grep and I only learned of it after you mentioned. But no, I did not copy-paste, but knew from my limited yaml experience that empty yaml attributes do not parse properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but knew from my limited yaml experience that empty yaml attributes do not parse properlly.
Gotcha. The secret trick is that YAML is actually a superset of JSON, so if you don't know how to do something in YAML but you do in JSON, it works as you'd expect.
As an extreme example:
In [2]: yaml_str = '''{'common': {'tags': 'time_units', 'type': 'unit'},
...: 'tests': {'utilities.time_units.z_tmvct': {}}}'''
In [3]: yaml.safe_load(yaml_str)
Out[3]:
{'common': {'tags': 'time_units', 'type': 'unit'},
'tests': {'utilities.time_units.z_tmvct': {}}}
Prior to zephyrproject-rtos#41602, due to the ordering of operations (first mul, then div), an intermediate value would overflow, resulting in a time non-linearity. This test ensures that time rolls-over properly. Signed-off-by: Chris Friedt <[email protected]>
497810d to
7f72d31
Compare
This simply adds a unit test for a previous change that went in which did not have an accompanying test.
Prior to #41602, due to the ordering of operations (first mul, then div), an intermediate value would overflow, resulting in a time non-linearity.
Fixes #41111