-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8321616: Retire binary test vectors in test/jdk/java/util/zip/ZipFile #17038
Conversation
👋 Welcome back eirbjo! A progress list of the required criteria for merging this PR into |
Webrevs
|
Thank you for tacking the conversion of this test to junit One quick comment, if we are updating this test, we should look to get rid of input.zip which means we should also address as part of the change: open/test/jdk/java/util/zip/ZipFile/EnumAfterClose.java |
I started going down that road, but felt uneasy about the amount of unrelated changes in a single PR. I'd like to make efficient use of reviewer time, so my preference was to focus on the JUnit conversion, without too many other changes. If you prefer that we get rid of input.zip and also convert the affected tests to JUnit in the same PR, then I'm happy to switch strategy. Note that |
input.zip and input.jar are pretty trivial:
So you could have the tests create the zip files on the fly or store the contents in an array within the tests. If the tests create the zip file/jar on the fly, then we just need to make sure that we create it in the same fashion as the test needs. I just think that we should take this opportunity as part of re-writing the tests to remove the need for the binary files in the workspace. I don't have a preference whether we deal with input.jar separately, but these tests are not that complex so I do not see a risk if they are all converted at once, or done piece meal |
Thanks, I'll extend the goal of this PR to remove |
…t.jar, converting affected tests to JUnit
The scope of this PR has now expanded to removing uses of the I'm marking the PR ready for review again. Before looking too closely at the code, it would be useful to discuss the following tests:
|
This could be moved into ReadZip. I do not believe we have a specific test and it is trivial
Yes CopyZipFile already exercises Zipfile.ZipInputStream so it is safe to retire CopyJar (though CopyZipFile could use a junit conversion ;-)
I believe you meant GetDirEntry.java not DirEntry.java? Having a test that specifically validates we can read META-INF is not a bad thing, but I suspect we have a test that already does that if not in the java/util/zip tests or java/util/jar tests. If not we should keep it but merge it as you suggest |
Thanks for your guidance! I moved |
Agreed, I have included that conversion in this PR :-) This test can make good use of |
Seeing that This removes the last remaining binary test vector ZIP in the |
These are on my list to review, thank you for the update. One comment, for the tests that we are removing/retiring, we probably want to include the bug numbers and/or the name of the original test class in the new home for the tests to make it easier for future maintainers to chase back the history in the unlikely event that an issue arises... |
/issue add 8322830 |
@eirbjo |
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.
Changes look fine. Probably need to change the copyright from 2023 -> 2024
// Create zip file with Zip64 end | ||
URI uri = URI.create("jar:" + zip.toUri()); | ||
Map<String, Object> env = Map.of("create", "true", "forceZIP64End", "true"); | ||
try (FileSystem fs = FileSystems.newFileSystem(uri, env)) { |
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.
No Need to use a URI here
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.
Fixed.
// ZIP64 end record | ||
if (Files.notExists(Paths.get("/usr/bin/zip"))) | ||
/** | ||
* Read a zip file created via "echo hello | zip dst.zip -", |
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 was created using info-zip so I would clarify in the comments
*/ | ||
@Test | ||
public void readZip64EndZipProcess() throws IOException, InterruptedException { | ||
if (Files.notExists(Paths.get("/usr/bin/zip"))) { |
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.
We should address this as the test won't run on Windows. It would be better to store the zip as a byte array so that it can be processed on all platforms and by removing ProcessBuilder, the test run will speed up a bit
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.
Updated comment to reference Info-ZIP. Updated the code to read the ZIP from a hex-encoded string.
@eirbjo This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 165 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
No IP was produced in 2024 for most of these files, but I've updated them anyhow. |
Thanks for your review, @LanceAndersen! You might want to take a quick look at the lastest updates addressing your review before I integrate. |
Looks good. I am running mach5 tiers1-3 internally once it completes, I will approve again |
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.
Internal mach5 tiers 1-3 completed
/integrate |
Going to push as commit 26de9e2.
Your commit was automatically rebased without conflicts. |
This PR suggests we retire the binary test vectors
ZipFile/input.zip
,ZipFile/input.jar
andZipFile/crash.jar
Binary test vectors are harder to analyze, and sharing test vectors across unrelated tests increases maintenance burden. It would be better to have each test produce its own test vectors independently.
While visiting these dusty tests, we should take the opportunity to convert them to JUnit, add more comments and perform some mild modernization and cleanups where appropriate. We should also consider whether any test are duplicated and can be retired or moved into other test files as separate methods. See comments below.
To help reviewers, here are some comments on the updated tests:
Available.java
This test currently has no jtreg
@test
header, so isn't currently active. After discussion, we decided to merge this test intoReadZip.java
. I added some checks to verify that reading from the stream reduces the number of available bytes accordingly, also checking the behavior when the stream is closed.CopyJar.java
The concern of copying entries seems to now have better coverage in the test
zip/CopyZipFile
. We decided to retire this test rather than convert it and instead convertCopyZipFile
to JUnit.EnumAfterClose.java
To prevent confusion with Java Enums, I suggest we rename this test to
EnumerateAfterClose
.FinalizeInflater.java
The code verified by this test has been updated to use cleaners instead of finalizers. Still, this test code relies on finalizers. Not sure if this is an issue, but this test will need to be updated when finalizers are finally removed.
GetDirEntry.java
We decided to merge this test into
ReadZip.readDirectoryEntries
rather than keeping it as a separate test.ReadZip.java
Nothing exciting here, the single main method was split into multiple JUnit methods, each focusing on a separate concern. A new test case
noentries()
was added, resolving JDK-8322830ReleaseInflater.java
Nothing exciting, tried to add some comment to help understanding of what is tested.
StreamZipEntriesTest.java
This test was using TestNG so was converted to JUnit for consistency. Added some comments to help understanding.
ReadAfterClose.java
This uses the binary test vector
crash.jar
. The test is converted to JUnit and moved to `ReadZip.readAfterClose´. The test is expanded to exercise more read methods.Progress
Issues
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/17038/head:pull/17038
$ git checkout pull/17038
Update a local copy of the PR:
$ git checkout pull/17038
$ git pull https://git.openjdk.org/jdk.git pull/17038/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 17038
View PR using the GUI difftool:
$ git pr show -t 17038
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/17038.diff
Webrev
Link to Webrev Comment