RFR: 8321812: Update GC tests to use execute[Limited]TestJava [v6]
Stefan Karlsson
stefank at openjdk.org
Wed Jan 3 13:32:18 UTC 2024
> A lot of our tests use a multi-step recipe to spawn and wait for a process. Here's an example
>
> ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(
> "-XX:-UseTLAB",
> "-XX:+UnlockDiagnosticVMOptions",
> "-XX:+VerifyDuringStartup",
> "-Xlog:gc+verify=debug",
> "-version");
> OutputAnalyzer output = new OutputAnalyzer(pb.start());
> ... do something with output and wait for the process to complete ...
>
>
> These are the steps involved:
>
> 1) Create a `ProcessBuilder`
> 2) Call `ProcessBuilder::start`
> 3) Create an `OutputAnalyzer`
> 4) Perform an operation that finally waits for the process to, at least partially, complete (OutputAnalyzer::getOutput, OutputAnalyzer::shouldHaveExitValue(), and more).
>
> Almost all our tests could be converted to use a single call to `ProcessTools.executeTestJava` (or `executeLimitedTestJava`), which spawns the process, makes sure that it has fully completed, and then returns a filled-in OutputAnalyzer to the caller. The above example would become:
>
>
> OutputAnalyzer output = ProcessTools.executeTestJava(
> "-XX:-UseTLAB",
> "-XX:+UnlockDiagnosticVMOptions",
> "-XX:+VerifyDuringStartup",
> "-Xlog:gc+verify=debug",
> "-version");
>
>
> I propose that we make this change in the GC tests, to make our code simpler and hopefully easier to read.
>
> Note: There's a few changes to the throws statements because some ProcessTools APIs throws IOException while others throw Exception.
>
> Testing: I've done testing on a similar set of changes, but I'm going to run the appropriate, final tests while this is being considered/reviewed.
Stefan Karlsson has updated the pull request incrementally with two additional commits since the last revision:
- Update Shenandoah test
- Remove import from old version of the code
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/17067/files
- new: https://git.openjdk.org/jdk/pull/17067/files/8f026a7a..fe7ef8e4
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=17067&range=05
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=17067&range=04-05
Stats: 3 lines in 2 files changed: 0 ins; 1 del; 2 mod
Patch: https://git.openjdk.org/jdk/pull/17067.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/17067/head:pull/17067
PR: https://git.openjdk.org/jdk/pull/17067
More information about the shenandoah-dev
mailing list