Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 55d62a5

Browse files
committedFeb 1, 2021
8213226: [TESTBUG] Reduce the usage of CDSTestUtils.executeAndLog()
Reviewed-by: iklam, minqi
1 parent b6a7367 commit 55d62a5

32 files changed

+252
-304
lines changed
 

‎test/hotspot/jtreg/runtime/cds/CdsDifferentCompactStrings.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -46,10 +46,9 @@ private static void createAndLoadSharedArchive(String create, String load)
4646
String createCompactStringsArgument = "-XX:" + create + "CompactStrings";
4747
String loadCompactStringsArgument = "-XX:" + load + "CompactStrings";
4848

49-
OutputAnalyzer out = CDSTestUtils.createArchive(createCompactStringsArgument);
50-
CDSTestUtils.checkDump(out);
49+
CDSTestUtils.createArchiveAndCheck(createCompactStringsArgument);
5150

52-
out = CDSTestUtils.runWithArchive(loadCompactStringsArgument);
51+
OutputAnalyzer out = CDSTestUtils.runWithArchive(loadCompactStringsArgument);
5352
CDSTestUtils.checkMappingFailure(out);
5453

5554
out.shouldMatch("The shared archive file's CompactStrings " +

‎test/hotspot/jtreg/runtime/cds/DeterministicDump.java

+7-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,10 +30,9 @@
3030
* @run driver DeterministicDump
3131
*/
3232

33+
import jdk.test.lib.cds.CDSOptions;
3334
import jdk.test.lib.cds.CDSTestUtils;
3435
import jdk.test.lib.Platform;
35-
import jdk.test.lib.process.ProcessTools;
36-
import jdk.test.lib.process.OutputAnalyzer;
3736
import java.io.FileInputStream;
3837
import java.io.IOException;
3938
import java.util.ArrayList;
@@ -79,16 +78,11 @@ public static void doTest(boolean compressed) throws Exception {
7978
static String dump(ArrayList<String> args, String... more) throws Exception {
8079
String logName = "SharedArchiveFile" + (id++);
8180
String archiveName = logName + ".jsa";
82-
args = (ArrayList<String>)args.clone();
83-
args.add("-XX:SharedArchiveFile=" + archiveName);
84-
args.add("-Xshare:dump");
85-
args.add("-Xlog:cds=debug");
86-
for (String m : more) {
87-
args.add(m);
88-
}
89-
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
90-
OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, logName);
91-
CDSTestUtils.checkDump(out);
81+
CDSOptions opts = (new CDSOptions())
82+
.addPrefix("-Xlog:cds=debug")
83+
.setArchiveName(archiveName)
84+
.addSuffix(more);
85+
CDSTestUtils.createArchiveAndCheck(opts);
9286

9387
return archiveName;
9488
}

‎test/hotspot/jtreg/runtime/cds/DumpSharedDictionary.java

+12-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
3030
* @run driver DumpSharedDictionary
3131
*/
3232

33+
import jdk.test.lib.cds.CDSOptions;
3334
import jdk.test.lib.cds.CDSTestUtils;
3435
import jdk.test.lib.process.ProcessTools;
3536
import jdk.test.lib.process.OutputAnalyzer;
@@ -40,24 +41,19 @@ public class DumpSharedDictionary {
4041
public static void main(String[] args) throws Exception {
4142
if (args.length == 0) {
4243
// Start this process
43-
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
44-
"-XX:SharedArchiveFile=./DumpSharedDictionary.jsa",
45-
"-Xshare:dump");
46-
47-
OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "dump");
48-
out.shouldHaveExitValue(0);
44+
CDSOptions opts = (new CDSOptions())
45+
.setArchiveName("./DumpSharedDictionary.jsa");
46+
CDSTestUtils.createArchiveAndCheck(opts);
4947

5048
String testjdkPath = System.getProperty("test.jdk");
5149

52-
pb = ProcessTools.createJavaProcessBuilder(
53-
"-XX:SharedArchiveFile=./DumpSharedDictionary.jsa",
54-
"-Dtest.jdk=" + testjdkPath,
55-
"-Xshare:on", "DumpSharedDictionary", "test");
56-
57-
out = CDSTestUtils.executeAndLog(pb, "exec");
58-
if (!CDSTestUtils.isUnableToMap(out)) {
59-
out.shouldHaveExitValue(0);
60-
}
50+
opts = (new CDSOptions())
51+
.setUseVersion(false)
52+
.addSuffix("-XX:SharedArchiveFile=./DumpSharedDictionary.jsa",
53+
"-Dtest.jdk=" + testjdkPath,
54+
"DumpSharedDictionary", "test");
55+
CDSTestUtils.run(opts)
56+
.assertNormalExit();
6157
} else {
6258
// Grab my own PID
6359
String pid = Long.toString(ProcessTools.getProcessId());

‎test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -33,14 +33,12 @@
3333

3434
import jdk.test.lib.cds.CDSOptions;
3535
import jdk.test.lib.cds.CDSTestUtils;
36-
import jdk.test.lib.process.OutputAnalyzer;
3736

3837
public class PrintSharedArchiveAndExit {
3938
public static void main(String[] args) throws Exception {
4039
String archiveName = "PrintSharedArchiveAndExit.jsa";
4140
CDSOptions opts = (new CDSOptions()).setArchiveName(archiveName);
42-
OutputAnalyzer out = CDSTestUtils.createArchive(opts);
43-
CDSTestUtils.checkDump(out);
41+
CDSTestUtils.createArchiveAndCheck(opts);
4442

4543
// (1) With a valid archive
4644
opts = (new CDSOptions())

‎test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java

+14-18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -31,33 +31,29 @@
3131
* java.management
3232
*/
3333

34+
import jdk.test.lib.cds.CDSOptions;
3435
import jdk.test.lib.cds.CDSTestUtils;
35-
import jdk.test.lib.process.ProcessTools;
36-
import jdk.test.lib.process.OutputAnalyzer;
3736

3837

3938
// NOTE: This test serves as a sanity test and also as an example for simple
4039
// use of SharedArchiveFile argument. For this reason it DOES NOT use the utility
4140
// methods to form command line to create/use shared archive.
4241
public class SharedArchiveFile {
4342
public static void main(String[] args) throws Exception {
44-
ProcessBuilder pb = ProcessTools.createTestJvm(
45-
"-XX:SharedArchiveFile=./SharedArchiveFile.jsa",
46-
"-Xshare:dump", "-Xlog:cds");
47-
OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile");
48-
CDSTestUtils.checkDump(out);
43+
CDSOptions opts = (new CDSOptions())
44+
.addPrefix("-Xlog:cds")
45+
.setArchiveName("./SharedArchiveFile.jsa");
46+
CDSTestUtils.createArchiveAndCheck(opts);
4947

5048
// -XX:+DumpSharedSpaces should behave the same as -Xshare:dump
51-
pb = ProcessTools.createTestJvm(
52-
"-XX:SharedArchiveFile=./SharedArchiveFile.jsa",
53-
"-XX:+DumpSharedSpaces", "-Xlog:cds");
54-
out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile");
55-
CDSTestUtils.checkDump(out);
49+
opts = (new CDSOptions())
50+
.addPrefix("-XX:+DumpSharedSpaces", "-Xlog:cds")
51+
.setArchiveName("./SharedArchiveFile.jsa");
52+
CDSTestUtils.createArchiveAndCheck(opts);
5653

57-
pb = ProcessTools.createTestJvm(
58-
"-XX:SharedArchiveFile=./SharedArchiveFile.jsa",
59-
"-Xshare:on", "-version");
60-
out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile");
61-
CDSTestUtils.checkExec(out);
54+
opts = (new CDSOptions())
55+
.setArchiveName("./SharedArchiveFile.jsa");
56+
CDSTestUtils.run(opts)
57+
.assertNormalExit();
6258
}
6359
}

‎test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,18 +30,15 @@
3030
*/
3131

3232
import jdk.test.lib.cds.CDSTestUtils;
33-
import jdk.test.lib.process.OutputAnalyzer;
34-
import java.io.File;
3533

3634
// The main purpose is to test the interaction between shared strings
3735
// and -XX:+UseStringDeduplication. We run in -Xshare:auto mode so
3836
// we don't need to worry about CDS archive mapping failure (which
3937
// doesn't happen often so it won't impact coverage).
4038
public class SharedStringsDedup {
4139
public static void main(String[] args) throws Exception {
42-
OutputAnalyzer out =
43-
CDSTestUtils.createArchive();
44-
CDSTestUtils.checkDump(out, "Shared string table stats");
40+
CDSTestUtils.createArchiveAndCheck()
41+
.shouldContain("Shared string table stats");
4542
CDSTestUtils.runWithArchiveAndCheck("-XX:+UseStringDeduplication");
4643
}
4744
}

‎test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -30,14 +30,11 @@
3030
*/
3131

3232
import jdk.test.lib.cds.CDSTestUtils;
33-
import jdk.test.lib.process.OutputAnalyzer;
34-
import java.io.File;
3533

3634
public class SharedStringsRunAuto {
3735
public static void main(String[] args) throws Exception {
38-
OutputAnalyzer out =
39-
CDSTestUtils.createArchive();
40-
CDSTestUtils.checkDump(out, "Shared string table stats");
36+
CDSTestUtils.createArchiveAndCheck()
37+
.shouldContain( "Shared string table stats");
4138
CDSTestUtils.runWithArchiveAndCheck();
4239
}
4340
}

‎test/hotspot/jtreg/runtime/cds/SharedSymbolTableBucketSize.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -39,9 +39,8 @@ public static void main(String[] args) throws Exception {
3939
int bucket_size = 8;
4040

4141
OutputAnalyzer output =
42-
CDSTestUtils.createArchive("-XX:SharedSymbolTableBucketSize="
43-
+ Integer.valueOf(bucket_size));
44-
CDSTestUtils.checkDump(output);
42+
CDSTestUtils.createArchiveAndCheck("-XX:SharedSymbolTableBucketSize="
43+
+ Integer.valueOf(bucket_size));
4544
CDSTestUtils.checkMappingFailure(output);
4645

4746
String s = output.firstMatch("Average bucket size : .*");

‎test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -55,8 +55,7 @@ public static void main(String[] args) throws Exception {
5555
static void test(String... extra_options) throws Exception {
5656
CDSOptions opts = new CDSOptions();
5757
opts.addSuffix(extra_options);
58-
OutputAnalyzer output = CDSTestUtils.createArchive(opts);
59-
CDSTestUtils.checkDump(output);
58+
OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts);
6059
Pattern pattern = Pattern.compile("(..) space: *([0-9]+).* out of *([0-9]+) bytes .* at 0x([0-9a0-f]+)");
6160
WhiteBox wb = WhiteBox.getWhiteBox();
6261
long reserve_alignment = wb.metaspaceReserveAlignment();

‎test/hotspot/jtreg/runtime/cds/appcds/BootClassPathMismatch.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
3535
import jdk.test.lib.Platform;
3636
import jdk.test.lib.cds.CDSOptions;
3737
import jdk.test.lib.cds.CDSTestUtils;
38-
import jdk.test.lib.process.OutputAnalyzer;
3938
import java.io.File;
4039
import java.nio.file.Files;
4140
import java.nio.file.FileAlreadyExistsException;
@@ -187,8 +186,7 @@ public void testBootClassPathMatch() throws Exception {
187186
*/
188187
public void testBootClassPathMatchWithAppend() throws Exception {
189188
CDSOptions opts = new CDSOptions().setUseVersion(false);
190-
OutputAnalyzer out = CDSTestUtils.createArchive(opts);
191-
CDSTestUtils.checkDump(out);
189+
CDSTestUtils.createArchiveAndCheck(opts);
192190

193191
String appJar = JarBuilder.getOrCreateHelloJar();
194192
opts.addPrefix("-Xbootclasspath/a:" + appJar, "-showversion").addSuffix("Hello");

‎test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java

+23-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -32,9 +32,9 @@
3232
* @run driver DumpClassList
3333
*/
3434

35+
import jdk.test.lib.cds.CDSOptions;
36+
import jdk.test.lib.cds.CDSTestUtils;
3537
import jdk.test.lib.compiler.InMemoryJavaCompiler;
36-
import jdk.test.lib.process.OutputAnalyzer;
37-
import jdk.test.lib.process.ProcessTools;
3838

3939
public class DumpClassList {
4040
public static void main(String[] args) throws Exception {
@@ -74,24 +74,27 @@ public static void main(String[] args) throws Exception {
7474
String appendJar = JarBuilder.build("bootappend", "boot/append/Foo");
7575

7676
// dump class list
77-
ProcessBuilder pb = ProcessTools.createTestJvm(
78-
"-XX:DumpLoadedClassList=" + classList,
79-
"--patch-module=java.base=" + patchJar,
80-
"-Xbootclasspath/a:" + appendJar,
81-
"-cp",
82-
appJar,
83-
appClass[0]);
84-
OutputAnalyzer output = TestCommon.executeAndLog(pb, "dumpClassList");
85-
TestCommon.checkExecReturn(output, 0, true,
86-
"hello world",
87-
"skip writing class java/lang/NewClass") // skip classes outside of jrt image
88-
.shouldNotContain("skip writing class boot/append/Foo"); // but classes on -Xbootclasspath/a should not be skipped
77+
CDSTestUtils.dumpClassList(classList,
78+
"--patch-module=java.base=" + patchJar,
79+
"-Xbootclasspath/a:" + appendJar,
80+
"-cp",
81+
appJar,
82+
appClass[0])
83+
.assertNormalExit(output -> {
84+
output.shouldContain("hello world");
85+
// skip classes outside of jrt image
86+
output.shouldContain("skip writing class java/lang/NewClass");
87+
// but classes on -Xbootclasspath/a should not be skipped
88+
output.shouldNotContain("skip writing class boot/append/Foo");
89+
});
8990

90-
output = TestCommon.createArchive(appJar, appClass,
91-
"-Xbootclasspath/a:" + appendJar,
92-
"-Xlog:class+load",
93-
"-XX:SharedClassListFile=" + classList);
94-
TestCommon.checkDump(output)
91+
CDSOptions opts = (new CDSOptions())
92+
.setClassList(appClass)
93+
.addPrefix("-cp", appJar,
94+
"-Xbootclasspath/a:" + appendJar,
95+
"-Xlog:class+load",
96+
"-XX:SharedClassListFile=" + classList);
97+
CDSTestUtils.createArchiveAndCheck(opts)
9598
.shouldNotContain("Preload Warning: Cannot find java/lang/invoke/LambdaForm")
9699
.shouldNotContain("Preload Warning: Cannot find boot/append/Foo")
97100
.shouldContain("[info][class,load] boot.append.Foo");

0 commit comments

Comments
 (0)
This repository has been archived.