-
Notifications
You must be signed in to change notification settings - Fork 33
Check for correctness of feature argument number when parsing feature arguments #556
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
base: master
Are you sure you want to change the base?
Conversation
|
@waltdisgrace Ping me here once you've figured out the testing issues, happy to help if you get stuck. |
cdb0ed0 to
ea97fa3
Compare
|
Rebased. |
|
@waltdisgrace Please post the error that you obtain from your newly added test with the unmodified code, i.e., the code w/out your additional changes in the source. |
|
Here is the relevant snippet of the |
|
@waltdisgrace: Ok! That failure looks right to me. |
|
Rebased |
mulkieran
left a comment
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.
The implementation for Flakey looks reasonable to me. Linear won't have any feature args, because it is so simple, but I think all the other targets that are supported have feature args and will therefore each implementation will contain the same bug.
Please go ahead and pick another, e.g., ThinPoolDev and apply the same fix.
|
@mulkieran Should the fixes for the other targets be done in separate PRs or the same PR as Flakey? |
@waltdisgrace You should make up a separate commit in this PR for ThinPoolDev and for each of the other target types that require the change. |
|
Rebased |
mulkieran
left a comment
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.
One request. There's a complication w/ cache that did not exist w/ flakey because the feature args are followed by the policy field, which as far as I can tell is mandatory. But the code is still vulnerable to a panic with something like
+ #[test]
+ fn test_cache_target_params_too_few() {
+ let result = "cache 42:42 42:43 42:44 16 2 writethrough passthrough default 0"
+ .parse::<CacheTargetParams>();
+ assert_matches!(result, Err(DmError::Dm(ErrorEnum::Invalid, _)));
+ }
|
I pushed a commit containing all of the changes you explicitly requested. Regarding the test you provided: This test causes a panic at the assertion that the input results in an error, not at the source code. The name you chose for the test, "... too_few", implies that the input, "cache 42:42 42:43 42:44 16 2 writethrough passthrough default 0", has too few arguments. However, this is a valid input that has enough arguments. Am I missing something? |
Whoops! Yes, I had modified the test to try out some other things. Try this instead: |
|
@mulkieran. That test looks reasonable to me and it passes when run against the source code changes of my most recently pushed commit. Adding your test to the PR now. |
mulkieran
left a comment
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.
A few more requests...I'll probably need one more pass.
src/cachedev.rs
Outdated
| .map(|x| (*x).to_string()) | ||
| .collect(); | ||
|
|
||
| if vals.len() <= end_feature_args_index + 1 { |
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.
Just make this if vals.len() < end_feature_args_index and then make the error message specific to too few feature_args. That change means we could still fail on policy missing, but I want to leave that until later, also.
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.
To avoid an out-of-bounds panic on test inputs that are only incorrect because of an incorrect feature argument number, this condition was chosen. Changing the condition to if vals.len() < end_feature_args_index would make sense for test inputs that are incorrect for the additional reason of being void of mandatory policy args, e.g. "cache 42:42 42:43 42:44 16 4 writethrough".
…_args_index in feature_args calculation, place check for inputs with too few values after end_feature_args_calculation, add test for inputs with too few values
|
Unlikely to manage to get to this before next release. |
Preliminary PR for #485