-
-
Notifications
You must be signed in to change notification settings - Fork 30
Implement gzdirect #341
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
Implement gzdirect #341
Conversation
folkertdev
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.
Mostly looks good
- I think it'll be more convenient to use
Resultfor private functions that return "success or failure" - there are some blocks that are not covered by tests. This is mostly just fyi, and can be fixed later, but if it's easy to fix now, all the better.
| // No gzip header. If we were decoding gzip before, the remaining bytes | ||
| // are trailing garbage that can be ignored. | ||
| if !state.direct { | ||
| state.stream.avail_in = 0; | ||
| state.eof = true; | ||
| state.have = 0; | ||
| return 0; | ||
| } |
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.
this block is not currently hit by tests
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 was able to cover the other blocks with new tests. This one got messy enough that I put in a FIXME comment for now. The cleanest way to get the GzState into the proper state to trigger this block is probably to finish implementing the read+decompress support, and then create a gzip file with junk content at the end.
|
Thanks for reviewing, I'll post an update later today. Do you have a recommended test coverage measurement tool? I'm looking for something I can easily run locally. |
|
Yes, we use |
|
Is it considered okay to do file I/O from unit tests within |
|
Let's go with that for now, and then see if there is a more elegant way. It might be possible to e.g. fake a file descriptor in some cases, or expose some testing functions with an additional feature flag to |
Codecov ReportAttention: Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 39 files with indirect coverage changes 🚀 New features to boost your workflow:
|
eb8ae1a to
eb2c471
Compare
|
To make my new test cases work under Miri when running locally, I had to use |
|
Oops, I accidentally removed the Miri isolation fix. I'm restoring it now... |
| if state.stream.avail_in != 0 { | ||
| // Copy any remaining input to the start. | ||
| unsafe { | ||
| ptr::copy( |
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 suspect also here
| ptr::copy( | |
| ptr::copy_nonoverlapping( |
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.
In this case, we're shifting data from the middle of a buffer to the front, so it may overlap.
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.
Maybe add a note then that they may overlap
libz-rs-sys/src/gz.rs
Outdated
| // Open a non-gzip file for reading. gzdirect should return 1. | ||
| #[test] | ||
| #[cfg_attr(not(target_os = "linux"), ignore = "lseek is not implemented")] | ||
| // Open a gzip file for reading. gzdirect should return 0. |
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.
something weird happed with the comments here.
No description provided.