Skip to content
Permalink
Browse files
8213226: [TESTBUG] Reduce the usage of CDSTestUtils.executeAndLog()
Reviewed-by: iklam, minqi
  • Loading branch information
calvinccheung committed Feb 1, 2021
1 parent b6a7367 commit 55d62a53380a0583397dacd4bd1b12f0c6be46bf
Showing with 252 additions and 304 deletions.
  1. +3 −4 test/hotspot/jtreg/runtime/cds/CdsDifferentCompactStrings.java
  2. +7 −13 test/hotspot/jtreg/runtime/cds/DeterministicDump.java
  3. +12 −16 test/hotspot/jtreg/runtime/cds/DumpSharedDictionary.java
  4. +2 −4 test/hotspot/jtreg/runtime/cds/PrintSharedArchiveAndExit.java
  5. +14 −18 test/hotspot/jtreg/runtime/cds/SharedArchiveFile.java
  6. +3 −6 test/hotspot/jtreg/runtime/cds/SharedStringsDedup.java
  7. +3 −6 test/hotspot/jtreg/runtime/cds/SharedStringsRunAuto.java
  8. +3 −4 test/hotspot/jtreg/runtime/cds/SharedSymbolTableBucketSize.java
  9. +2 −3 test/hotspot/jtreg/runtime/cds/SpaceUtilizationCheck.java
  10. +2 −4 test/hotspot/jtreg/runtime/cds/appcds/BootClassPathMismatch.java
  11. +23 −20 test/hotspot/jtreg/runtime/cds/appcds/DumpClassList.java
  12. +26 −28 test/hotspot/jtreg/runtime/cds/appcds/GraalWithLimitedMetaspace.java
  13. +2 −8 test/hotspot/jtreg/runtime/cds/appcds/LambdaWithOldClass.java
  14. +2 −4 test/hotspot/jtreg/runtime/cds/appcds/LotsOfClasses.java
  15. +3 −8 test/hotspot/jtreg/runtime/cds/appcds/StaticArchiveWithLambda.java
  16. +3 −9 test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaForClassInBaseArchive.java
  17. +2 −9 test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaInBaseArchive.java
  18. +6 −9 test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/NoClassToArchive.java
  19. +13 −11 test/hotspot/jtreg/runtime/cds/appcds/jigsaw/NewModuleFinderTest.java
  20. +14 −12 test/hotspot/jtreg/runtime/cds/appcds/jvmti/ClassFileLoadHookTest.java
  21. +15 −12 test/hotspot/jtreg/runtime/cds/appcds/jvmti/InstrumentationTest.java
  22. +5 −9 test/hotspot/jtreg/runtime/cds/appcds/methodHandles/CDSMHTest_generate.sh
  23. +4 −8 test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesAsCollectorTest.java
  24. +4 −8 test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesCastFailureTest.java
  25. +4 −8 test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesGeneralTest.java
  26. +4 −8 test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesInvokersTest.java
  27. +4 −8 test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesPermuteArgumentsTest.java
  28. +4 −8 test/hotspot/jtreg/runtime/cds/appcds/methodHandles/MethodHandlesSpreadArgumentsTest.java
  29. +16 −18 test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SharedStringsBasic.java
  30. +22 −19 test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/SysDictCrash.java
  31. +12 −1 test/lib/jdk/test/lib/cds/CDSOptions.java
  32. +13 −1 test/lib/jdk/test/lib/cds/CDSTestUtils.java
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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)
String createCompactStringsArgument = "-XX:" + create + "CompactStrings";
String loadCompactStringsArgument = "-XX:" + load + "CompactStrings";

OutputAnalyzer out = CDSTestUtils.createArchive(createCompactStringsArgument);
CDSTestUtils.checkDump(out);
CDSTestUtils.createArchiveAndCheck(createCompactStringsArgument);

out = CDSTestUtils.runWithArchive(loadCompactStringsArgument);
OutputAnalyzer out = CDSTestUtils.runWithArchive(loadCompactStringsArgument);
CDSTestUtils.checkMappingFailure(out);

out.shouldMatch("The shared archive file's CompactStrings " +
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,10 +30,9 @@
* @run driver DeterministicDump
*/

import jdk.test.lib.cds.CDSOptions;
import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.Platform;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
@@ -79,16 +78,11 @@ public static void doTest(boolean compressed) throws Exception {
static String dump(ArrayList<String> args, String... more) throws Exception {
String logName = "SharedArchiveFile" + (id++);
String archiveName = logName + ".jsa";
args = (ArrayList<String>)args.clone();
args.add("-XX:SharedArchiveFile=" + archiveName);
args.add("-Xshare:dump");
args.add("-Xlog:cds=debug");
for (String m : more) {
args.add(m);
}
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, logName);
CDSTestUtils.checkDump(out);
CDSOptions opts = (new CDSOptions())
.addPrefix("-Xlog:cds=debug")
.setArchiveName(archiveName)
.addSuffix(more);
CDSTestUtils.createArchiveAndCheck(opts);

return archiveName;
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,6 +30,7 @@
* @run driver DumpSharedDictionary
*/

import jdk.test.lib.cds.CDSOptions;
import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
@@ -40,24 +41,19 @@
public static void main(String[] args) throws Exception {
if (args.length == 0) {
// Start this process
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
"-XX:SharedArchiveFile=./DumpSharedDictionary.jsa",
"-Xshare:dump");

OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "dump");
out.shouldHaveExitValue(0);
CDSOptions opts = (new CDSOptions())
.setArchiveName("./DumpSharedDictionary.jsa");
CDSTestUtils.createArchiveAndCheck(opts);

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

pb = ProcessTools.createJavaProcessBuilder(
"-XX:SharedArchiveFile=./DumpSharedDictionary.jsa",
"-Dtest.jdk=" + testjdkPath,
"-Xshare:on", "DumpSharedDictionary", "test");

out = CDSTestUtils.executeAndLog(pb, "exec");
if (!CDSTestUtils.isUnableToMap(out)) {
out.shouldHaveExitValue(0);
}
opts = (new CDSOptions())
.setUseVersion(false)
.addSuffix("-XX:SharedArchiveFile=./DumpSharedDictionary.jsa",
"-Dtest.jdk=" + testjdkPath,
"DumpSharedDictionary", "test");
CDSTestUtils.run(opts)
.assertNormalExit();
} else {
// Grab my own PID
String pid = Long.toString(ProcessTools.getProcessId());
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,14 +33,12 @@

import jdk.test.lib.cds.CDSOptions;
import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.OutputAnalyzer;

public class PrintSharedArchiveAndExit {
public static void main(String[] args) throws Exception {
String archiveName = "PrintSharedArchiveAndExit.jsa";
CDSOptions opts = (new CDSOptions()).setArchiveName(archiveName);
OutputAnalyzer out = CDSTestUtils.createArchive(opts);
CDSTestUtils.checkDump(out);
CDSTestUtils.createArchiveAndCheck(opts);

// (1) With a valid archive
opts = (new CDSOptions())
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -31,33 +31,29 @@
* java.management
*/

import jdk.test.lib.cds.CDSOptions;
import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;


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

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

pb = ProcessTools.createTestJvm(
"-XX:SharedArchiveFile=./SharedArchiveFile.jsa",
"-Xshare:on", "-version");
out = CDSTestUtils.executeAndLog(pb, "SharedArchiveFile");
CDSTestUtils.checkExec(out);
opts = (new CDSOptions())
.setArchiveName("./SharedArchiveFile.jsa");
CDSTestUtils.run(opts)
.assertNormalExit();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,18 +30,15 @@
*/

import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.OutputAnalyzer;
import java.io.File;

// The main purpose is to test the interaction between shared strings
// and -XX:+UseStringDeduplication. We run in -Xshare:auto mode so
// we don't need to worry about CDS archive mapping failure (which
// doesn't happen often so it won't impact coverage).
public class SharedStringsDedup {
public static void main(String[] args) throws Exception {
OutputAnalyzer out =
CDSTestUtils.createArchive();
CDSTestUtils.checkDump(out, "Shared string table stats");
CDSTestUtils.createArchiveAndCheck()
.shouldContain("Shared string table stats");
CDSTestUtils.runWithArchiveAndCheck("-XX:+UseStringDeduplication");
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -30,14 +30,11 @@
*/

import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.OutputAnalyzer;
import java.io.File;

public class SharedStringsRunAuto {
public static void main(String[] args) throws Exception {
OutputAnalyzer out =
CDSTestUtils.createArchive();
CDSTestUtils.checkDump(out, "Shared string table stats");
CDSTestUtils.createArchiveAndCheck()
.shouldContain( "Shared string table stats");
CDSTestUtils.runWithArchiveAndCheck();
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 {
int bucket_size = 8;

OutputAnalyzer output =
CDSTestUtils.createArchive("-XX:SharedSymbolTableBucketSize="
+ Integer.valueOf(bucket_size));
CDSTestUtils.checkDump(output);
CDSTestUtils.createArchiveAndCheck("-XX:SharedSymbolTableBucketSize="
+ Integer.valueOf(bucket_size));
CDSTestUtils.checkMappingFailure(output);

String s = output.firstMatch("Average bucket size : .*");
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* 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 {
static void test(String... extra_options) throws Exception {
CDSOptions opts = new CDSOptions();
opts.addSuffix(extra_options);
OutputAnalyzer output = CDSTestUtils.createArchive(opts);
CDSTestUtils.checkDump(output);
OutputAnalyzer output = CDSTestUtils.createArchiveAndCheck(opts);
Pattern pattern = Pattern.compile("(..) space: *([0-9]+).* out of *([0-9]+) bytes .* at 0x([0-9a0-f]+)");
WhiteBox wb = WhiteBox.getWhiteBox();
long reserve_alignment = wb.metaspaceReserveAlignment();
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -35,7 +35,6 @@
import jdk.test.lib.Platform;
import jdk.test.lib.cds.CDSOptions;
import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.OutputAnalyzer;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.FileAlreadyExistsException;
@@ -187,8 +186,7 @@ public void testBootClassPathMatch() throws Exception {
*/
public void testBootClassPathMatchWithAppend() throws Exception {
CDSOptions opts = new CDSOptions().setUseVersion(false);
OutputAnalyzer out = CDSTestUtils.createArchive(opts);
CDSTestUtils.checkDump(out);
CDSTestUtils.createArchiveAndCheck(opts);

String appJar = JarBuilder.getOrCreateHelloJar();
opts.addPrefix("-Xbootclasspath/a:" + appJar, "-showversion").addSuffix("Hello");
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -32,9 +32,9 @@
* @run driver DumpClassList
*/

import jdk.test.lib.cds.CDSOptions;
import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.compiler.InMemoryJavaCompiler;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;

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

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

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

0 comments on commit 55d62a5

Please sign in to comment.