2020-06-10 15:50:26 +00:00
|
|
|
/*
|
2022-07-08 15:55:14 +00:00
|
|
|
* Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved.
|
2020-06-10 15:50:26 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @test
|
|
|
|
* @summary Run the CustomFJPoolTest in dynamic CDSarchive mode.
|
|
|
|
* @requires vm.cds
|
|
|
|
* @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
|
|
|
|
* /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/test-classes
|
|
|
|
* @compile ../../../../../../jdk/java/util/stream/CustomFJPoolTest.java
|
|
|
|
* test-classes/TestStreamApp.java
|
2022-07-08 15:55:14 +00:00
|
|
|
* @build jdk.test.whitebox.WhiteBox
|
|
|
|
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
|
2020-06-10 15:50:26 +00:00
|
|
|
* @run testng/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. CDSStreamTestDriver
|
|
|
|
*/
|
|
|
|
|
|
|
|
import org.testng.annotations.Test;
|
|
|
|
import java.io.File;
|
2022-08-18 23:29:39 +00:00
|
|
|
import java.nio.file.Path;
|
2020-06-10 15:50:26 +00:00
|
|
|
import jtreg.SkippedException;
|
2022-07-11 13:07:03 +00:00
|
|
|
import jdk.test.whitebox.gc.GC;
|
2020-06-10 15:50:26 +00:00
|
|
|
|
|
|
|
@Test
|
|
|
|
public class CDSStreamTestDriver extends DynamicArchiveTestBase {
|
|
|
|
@Test
|
|
|
|
public void testMain() throws Exception {
|
|
|
|
runTest(CDSStreamTestDriver::doTest);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static final String classDir = System.getProperty("test.classes");
|
|
|
|
private static final String mainClass = "TestStreamApp";
|
|
|
|
private static final String ps = System.getProperty("path.separator");
|
|
|
|
private static final String skippedException = "jtreg.SkippedException: Unable to map shared archive: test did not complete";
|
|
|
|
|
|
|
|
static void doTest() throws Exception {
|
|
|
|
String topArchiveName = getNewArchiveName();
|
2020-08-10 03:56:04 +00:00
|
|
|
String appJar = JarBuilder.build("streamapp", new File(classDir), null);
|
2020-06-10 15:50:26 +00:00
|
|
|
|
2022-08-18 17:26:14 +00:00
|
|
|
String testngJar = Path.of(Test.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toString();
|
2020-06-10 15:50:26 +00:00
|
|
|
|
|
|
|
String[] testClassNames = { "CustomFJPoolTest" };
|
|
|
|
|
|
|
|
for (String className : testClassNames) {
|
|
|
|
try {
|
|
|
|
dumpAndRun(topArchiveName, "-Xlog:cds,cds+dynamic=debug,class+load=trace",
|
|
|
|
"-cp", appJar + ps + testngJar,
|
|
|
|
mainClass, className);
|
|
|
|
} catch (SkippedException s) {
|
|
|
|
if (GC.Z.isSelected() && s.toString().equals(skippedException)) {
|
|
|
|
System.out.println("Got " + s.toString() + " as expected.");
|
|
|
|
System.out.println("Because the test was run with ZGC with UseCompressedOops and UseCompressedClassPointers disabled,");
|
|
|
|
System.out.println("but the base archive was created with the options enabled");
|
|
|
|
} else {
|
|
|
|
throw new RuntimeException("Archive mapping should always succeed after JDK-8231610 (did the machine run out of memory?)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|