8193664: AppCDS tests should use -XX:+UnlockCommercialFeatures when running with commercial JDK

Reviewed-by: jiangli, mseledtsov, dholmes
This commit is contained in:
Ioi Lam 2018-01-11 16:40:10 -08:00
parent f811ca50b3
commit 36c68615bc
4 changed files with 37 additions and 19 deletions
test/hotspot/jtreg/runtime/appcds

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2018, 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
@ -23,6 +23,7 @@
*/
import jdk.test.lib.Utils;
import jdk.test.lib.BuildHelper;
import jdk.test.lib.JDKToolFinder;
import jdk.test.lib.Platform;
import jdk.test.lib.cds.CDSOptions;
@ -107,6 +108,19 @@ public class TestCommon extends CDSTestUtils {
return createArchive(opts);
}
// If you use -XX:+UseAppCDS or -XX:-UseAppCDS in your JVM command-line, call this method
// to wrap the arguments. On commercial builds, -XX:+UnlockCommercialFeatures will be
// prepended to the command-line. See JDK-8193664.
public static String[] makeCommandLineForAppCDS(String... args) throws Exception {
if (BuildHelper.isCommercialBuild()) {
String[] newArgs = new String[args.length + 1];
newArgs[0] = "-XX:+UnlockCommercialFeatures";
System.arraycopy(args, 0, newArgs, 1, args.length);
return newArgs;
} else {
return args;
}
}
// Create AppCDS archive using appcds options
public static OutputAnalyzer createArchive(AppCDSOptions opts)
@ -139,7 +153,7 @@ public class TestCommon extends CDSTestUtils {
for (String s : opts.suffix) cmd.add(s);
String[] cmdLine = cmd.toArray(new String[cmd.size()]);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine));
return executeAndLog(pb, "dump");
}
@ -166,7 +180,7 @@ public class TestCommon extends CDSTestUtils {
for (String s : opts.suffix) cmd.add(s);
String[] cmdLine = cmd.toArray(new String[cmd.size()]);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine));
return executeAndLog(pb, "exec");
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2014, 2018, 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
@ -122,14 +122,14 @@ public class UseAppCDS {
static void dumpLoadedClasses(boolean useAppCDS, String[] expectedClasses,
String[] unexpectedClasses) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
true,
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
TestCommon.makeCommandLineForAppCDS(
"-XX:DumpLoadedClassList=" + CLASSLIST_FILE,
"-cp",
TESTJAR,
useAppCDS ? "-XX:+UseAppCDS" : "-XX:-UseAppCDS",
TESTNAME,
TEST_OUT);
TEST_OUT));
OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-loaded-classes")
.shouldHaveExitValue(0).shouldContain(TEST_OUT);
@ -152,8 +152,8 @@ public class UseAppCDS {
static void dumpArchive(boolean useAppCDS, String[] expectedClasses,
String[] unexpectedClasses) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
true,
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
TestCommon.makeCommandLineForAppCDS(
useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
"-XX:+UnlockDiagnosticVMOptions",
"-cp",
@ -162,7 +162,7 @@ public class UseAppCDS {
"-XX:SharedClassListFile=" + CLASSLIST_FILE,
"-XX:SharedArchiveFile=" + ARCHIVE_FILE,
"-Xlog:cds",
"-Xshare:dump");
"-Xshare:dump"));
OutputAnalyzer output = TestCommon.executeAndLog(pb, "dump-archive")
.shouldHaveExitValue(0);
@ -179,8 +179,8 @@ public class UseAppCDS {
static void useArchive(boolean useAppCDS, String[] expectedClasses,
String[] unexpectedClasses) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
true,
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
TestCommon.makeCommandLineForAppCDS(
useAppCDS ? "-XX:-UnlockDiagnosticVMOptions" :
"-XX:+UnlockDiagnosticVMOptions",
"-cp",
@ -190,7 +190,7 @@ public class UseAppCDS {
"-verbose:class",
"-Xshare:on",
TESTNAME,
TEST_OUT );
TEST_OUT));
OutputAnalyzer output = TestCommon.executeAndLog(pb, "use-archive");
if (CDSTestUtils.isUnableToMap(output))

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2018, 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
@ -50,6 +50,7 @@ public class SharedStringsBasic {
TestCommon.getSourceFile("SharedStringsBasic.txt").toString();
ProcessBuilder dumpPb = ProcessTools.createJavaProcessBuilder(true,
TestCommon.makeCommandLineForAppCDS(
"-XX:+UseAppCDS",
"-XX:+UseCompressedOops",
"-XX:+UseG1GC",
@ -57,13 +58,14 @@ public class SharedStringsBasic {
"-XX:SharedArchiveConfigFile=" + sharedArchiveConfigFile,
"-XX:SharedArchiveFile=./SharedStringsBasic.jsa",
"-Xshare:dump",
"-Xlog:cds,cds+hashtables");
"-Xlog:cds,cds+hashtables"));
TestCommon.executeAndLog(dumpPb, "dump")
.shouldContain("Shared string table stats")
.shouldHaveExitValue(0);
ProcessBuilder runPb = ProcessTools.createJavaProcessBuilder(true,
TestCommon.makeCommandLineForAppCDS(
"-XX:+UseAppCDS",
"-XX:+UseCompressedOops",
"-XX:+UseG1GC",
@ -71,7 +73,7 @@ public class SharedStringsBasic {
"-XX:SharedArchiveFile=./SharedStringsBasic.jsa",
"-Xshare:auto",
"-showversion",
"HelloString");
"HelloString"));
TestCommon.executeAndLog(runPb, "run").shouldHaveExitValue(0);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2018, 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
@ -42,21 +42,23 @@ public class SysDictCrash {
// SharedBaseAddress=0 puts the archive at a very high address on solaris,
// which provokes the crash.
ProcessBuilder dumpPb = ProcessTools.createJavaProcessBuilder(true,
TestCommon.makeCommandLineForAppCDS(
"-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5",
"-XX:+UseAppCDS",
"-cp", ".",
"-XX:SharedBaseAddress=0", "-XX:SharedArchiveFile=./SysDictCrash.jsa",
"-Xshare:dump",
"-showversion", "-Xlog:cds,cds+hashtables");
"-showversion", "-Xlog:cds,cds+hashtables"));
TestCommon.checkDump(TestCommon.executeAndLog(dumpPb, "dump"));
ProcessBuilder runPb = ProcessTools.createJavaProcessBuilder(true,
TestCommon.makeCommandLineForAppCDS(
"-XX:+UseG1GC", "-XX:MaxRAMPercentage=12.5",
"-XX:+UseAppCDS",
"-XX:SharedArchiveFile=./SysDictCrash.jsa",
"-Xshare:on",
"-version");
"-version"));
TestCommon.checkExec(TestCommon.executeAndLog(runPb, "exec"));
}