8208655: use JTreg skipped status in hotspot tests

8023735: [TESTBUG][macosx] runtime/XCheckJniJsig/XCheckJSig.java fails on MacOS X
8208701: Fix for JDK-8208655 causes test failures in CI tier1
8208706: compiler/tiered/ConstantGettersTransitionsTest.java fails to compile
8186095: upgrade to jtreg 4.2 b08
8183503: Update hotspot tests to allow for unique test classes directory
8213410: UseCompressedOops requirement check fails fails on 32-bit system

Reviewed-by: stuefe, sgehwolf
Backport-of: 17b730d7edf7be91ee841180ea6a59b26c0c567a
This commit is contained in:
Andrew John Hughes 2023-11-28 03:17:41 +00:00
parent 0464401cc5
commit 3b9c787e3c
35 changed files with 273 additions and 167 deletions

View File

@ -43,7 +43,6 @@
runtime/SharedArchiveFile/SharedBaseAddress.java 8044600 solaris-sparc
runtime/6929067/Test6929067.sh 8028740 generic-all
runtime/CDSCompressedKPtrs/XShareAuto.java 8026154 generic-all
runtime/XCheckJniJsig/XCheckJSig.java 8023735 generic-all
runtime/6626217/Test6626217.sh 8028733 generic-all
runtime/jsig/Test8017498.sh 8028806 generic-all
runtime/LoadClass/LoadClassNegative.java 8028095 generic-all

View File

@ -36,7 +36,11 @@ groups=TEST.groups [closed/TEST.groups]
requires.extraPropDefns = ../../test/jtreg-ext/requires/VMProps.java
requires.properties=sun.arch.data.model \
vm.flavor \
vm.bits
vm.bits \
vm.debug
# Minimum jtreg version
requiredVersion=4.2 b13
# Path to libraries in the topmost test directory. This is needed so @library
# does not need ../../ notation to reach them

View File

@ -107,7 +107,8 @@ public class TestAnonymousClassUnloading {
*/
static public void main(String[] args) throws Exception {
// (1) Load an anonymous version of this class using the corresponding Unsafe method
URL classUrl = TestAnonymousClassUnloading.class.getResource("TestAnonymousClassUnloading.class");
String rn = TestAnonymousClassUnloading.class.getSimpleName() + ".class";
URL classUrl = TestAnonymousClassUnloading.class.getResource(rn);
URLConnection connection = classUrl.openConnection();
int length = connection.getContentLength();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 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
@ -21,12 +21,14 @@
* questions.
*/
import jtreg.SkippedException;
import java.lang.reflect.Executable;
import java.util.concurrent.Callable;
/**
* @test ConstantGettersTransitionsTest
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox /test/lib
* @build TransitionsTestExecutor ConstantGettersTransitionsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@ -37,7 +39,9 @@ import java.util.concurrent.Callable;
*/
public class ConstantGettersTransitionsTest extends LevelTransitionTest {
public static void main(String[] args) {
assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false));
if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
throw new SkippedException("Test isn't applicable for non-tiered mode");
}
// run test cases
for (TestCase testCase : ConstantGettersTestCase.values()) {

View File

@ -21,6 +21,8 @@
* questions.
*/
import jtreg.SkippedException;
import java.lang.reflect.Executable;
import java.lang.reflect.Method;
import java.util.Objects;
@ -28,7 +30,7 @@ import java.util.concurrent.Callable;
/**
* @test LevelTransitionTest
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox /test/lib
* @build TransitionsTestExecutor LevelTransitionTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
* @run main/othervm/timeout=240 -Xmixed -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions
@ -44,7 +46,9 @@ public class LevelTransitionTest extends TieredLevelsTest {
private int transitionCount;
public static void main(String[] args) throws Throwable {
assert (!CompilerWhiteBoxTest.skipOnTieredCompilation(false));
if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
throw new SkippedException("Test isn't applicable for non-tiered mode");
}
CompilerWhiteBoxTest.main(LevelTransitionTest::new, args);
// run extended test cases

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@ -22,10 +22,11 @@
*/
import java.util.function.IntPredicate;
import jtreg.SkippedException;
/**
* @test NonTieredLevelsTest
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox /test/lib
* @build NonTieredLevelsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:-TieredCompilation
@ -54,7 +55,7 @@ public class NonTieredLevelsTest extends CompLevelsTest {
}
public static void main(String[] args) throws Exception {
if (CompilerWhiteBoxTest.skipOnTieredCompilation(true)) {
return;
throw new SkippedException("Test isn't applicable for tiered mode");
}
CompilerWhiteBoxTest.main(NonTieredLevelsTest::new, args);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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,7 +23,7 @@
/**
* @test TieredLevelsTest
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox
* @library /testlibrary /testlibrary/whitebox /compiler/whitebox /test/lib
* @build TieredLevelsTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+TieredCompilation
@ -33,10 +33,13 @@
* @summary Verify that all levels < 'TieredStopAtLevel' can be used
* @author igor.ignatyev@oracle.com
*/
import jtreg.SkippedException;
public class TieredLevelsTest extends CompLevelsTest {
public static void main(String[] args) throws Exception, Throwable {
if (CompilerWhiteBoxTest.skipOnTieredCompilation(false)) {
return;
throw new SkippedException("Test isn't applicable for non-tiered mode");
}
CompilerWhiteBoxTest.main(TieredLevelsTest::new, args);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
@ -26,7 +26,7 @@
* @key gc
* @bug 8179084
* @summary Test argument processing for -XX:+AggressiveHeap.
* @library /testlibrary
* @library /testlibrary /test/lib
* @run driver TestAggressiveHeap
*/
@ -36,6 +36,7 @@ import javax.management.ObjectName;
import com.oracle.java.testlibrary.OutputAnalyzer;
import com.oracle.java.testlibrary.ProcessTools;
import jtreg.SkippedException;
public class TestAggressiveHeap {
@ -86,9 +87,7 @@ public class TestAggressiveHeap {
private static boolean canUseAggressiveHeapOption() throws Exception {
if (!haveRequiredMemory()) {
System.out.println(
"Skipping test of " + option + " : insufficient memory");
return false;
throw new SkippedException("Skipping test of " + option + " : insufficient memory");
}
return true;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 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
@ -27,7 +27,7 @@
* @requires vm.gc=="G1" | vm.gc=="null"
* @summary Verify that heap shrinks after GC in the presence of fragmentation
* due to humongous objects
* @library /testlibrary
* @library /testlibrary /test/lib
* @run main/othervm -XX:-ExplicitGCInvokesConcurrent -XX:MinHeapFreeRatio=10
* -XX:MaxHeapFreeRatio=12 -XX:+UseG1GC -XX:G1HeapRegionSize=1M -verbose:gc
* TestHumongousShrinkHeap
@ -39,6 +39,7 @@ import java.util.ArrayList;
import java.util.List;
import sun.management.ManagementFactoryHelper;
import static com.oracle.java.testlibrary.Asserts.*;
import jtreg.SkippedException;
public class TestHumongousShrinkHeap {
@ -57,13 +58,11 @@ public class TestHumongousShrinkHeap {
public static void main(String[] args) {
if (HUMON_COUNT == 0) {
System.out.println("Skipped. Heap is too small");
return;
throw new SkippedException("Heap is too small");
}
if (TOTAL_MEMORY + REGION_SIZE * HUMON_COUNT > MAX_MEMORY) {
System.out.println("Skipped. Initial heap size is to close to max heap size.");
return;
throw new SkippedException("Initial heap size is to close to max heap size.");
}
System.out.format("Running with %s initial heap size of %s maximum heap size. "

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 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
@ -25,8 +25,8 @@
* @test TestLargePageUseForAuxMemory.java
* @bug 8058354
* @key gc
* @library /testlibrary /testlibrary/whitebox
* @requires (vm.gc=="G1" | vm.gc=="null")
* @library /testlibrary /testlibrary/whitebox /test/lib
* @requires (vm.gc=="G1" | vm.gc=="null") & vm.debug
* @build TestLargePageUseForAuxMemory
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* sun.hotspot.WhiteBox$WhiteBoxPermission
@ -35,6 +35,7 @@
*/
import com.oracle.java.testlibrary.*;
import jtreg.SkippedException;
import sun.hotspot.WhiteBox;
public class TestLargePageUseForAuxMemory {
@ -88,18 +89,12 @@ public class TestLargePageUseForAuxMemory {
}
public static void main(String[] args) throws Exception {
if (!Platform.isDebugBuild()) {
System.out.println("Skip tests on non-debug builds because the required option TracePageSizes is a debug-only option.");
return;
}
WhiteBox wb = WhiteBox.getWhiteBox();
smallPageSize = wb.getVMPageSize();
largePageSize = wb.getVMLargePageSize();
if (largePageSize == 0) {
System.out.println("Skip tests because large page support does not seem to be available on this platform.");
return;
throw new SkippedException("Large page support does not seem to be available on this platform.");
}
// To get large pages for the card table etc. we need at least a 1G heap (with 4k page size).

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 2015, 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
@ -26,6 +26,8 @@ import com.oracle.java.testlibrary.OutputAnalyzer;
import com.oracle.java.testlibrary.Platform;
import com.oracle.java.testlibrary.ProcessTools;
import com.oracle.java.testlibrary.Utils;
import jtreg.SkippedException;
import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.MemoryUsage;
@ -67,10 +69,9 @@ public class TestShrinkAuxiliaryData {
int maxCacheSize = Math.max(0, Math.min(31, getMaxCacheSize()));
if (maxCacheSize < hotCardTableSize) {
System.out.format("Skiping test for %d cache size due max cache size %d",
hotCardTableSize, maxCacheSize
);
return;
throw new SkippedException(String.format(
"Skiping test for %d cache size due max cache size %d",
hotCardTableSize, maxCacheSize));
}
printTestInfo(maxCacheSize);

View File

@ -27,7 +27,7 @@
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /testlibrary/whitebox
* @library /testlibrary /testlibrary/whitebox /test/lib
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* TestShrinkAuxiliaryData TestShrinkAuxiliaryData00
* @run main ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -27,7 +27,7 @@
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /testlibrary/whitebox
* @library /testlibrary /testlibrary/whitebox /test/lib
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* TestShrinkAuxiliaryData TestShrinkAuxiliaryData05
* @run main ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -27,7 +27,7 @@
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /testlibrary/whitebox
* @library /testlibrary /testlibrary/whitebox /test/lib
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData10
* @run main ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -27,7 +27,7 @@
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /testlibrary/whitebox
* @library /testlibrary /testlibrary/whitebox /test/lib
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData15
* @run main ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -27,7 +27,7 @@
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /testlibrary/whitebox
* @library /testlibrary /testlibrary/whitebox /test/lib
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData20
* @run main ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -27,7 +27,7 @@
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /testlibrary/whitebox
* @library /testlibrary /testlibrary/whitebox /test/lib
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData25
* @run main ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -27,7 +27,7 @@
* @summary Checks that decommitment occurs for JVM with different
* G1ConcRSLogCacheSize and ObjectAlignmentInBytes options values
* @requires vm.gc=="G1" | vm.gc=="null"
* @library /testlibrary /testlibrary/whitebox
* @library /testlibrary /testlibrary/whitebox /test/lib
* @build com.oracle.java.testlibrary.* sun.hotspot.WhiteBox
* @build TestShrinkAuxiliaryData TestShrinkAuxiliaryData30
* @run main ClassFileInstaller sun.hotspot.WhiteBox

View File

@ -25,6 +25,7 @@
* @test CompressedClassSpaceSizeInJmapHeap
* @bug 8004924
* @summary Checks that jmap -heap contains the flag CompressedClassSpaceSize
* @requires vm.bits == 64
* @library /testlibrary
* @run main/othervm -XX:CompressedClassSpaceSize=50m CompressedClassSpaceSizeInJmapHeap
*/

View File

@ -30,6 +30,7 @@ import static com.oracle.java.testlibrary.Asserts.*;
* @bug 8000754
* @summary Tests that a MemoryPoolMXBeans is created for metaspace and that a
* MemoryManagerMXBean is created.
* @requires vm.bits == 64
* @library /testlibrary
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops TestMetaspaceMemoryPool
* @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseCompressedOops -XX:MaxMetaspaceSize=60m TestMetaspaceMemoryPool

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 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
@ -24,10 +24,12 @@
/*
* @test TestBootNativeLibraryPath.java
* @bug 6819213
* @compile -XDignore.symbol.file TestBootNativeLibraryPath.java
* @summary verify sun.boot.native.library.path is expandable on 32 bit systems
* @run main TestBootNativeLibraryPath
* @author ksrini
* @library /test/lib
* @requires vm.bits == 32
* @compile -XDignore.symbol.file TestBootNativeLibraryPath.java
* @run main TestBootNativeLibraryPath
*/
import java.io.BufferedReader;
@ -107,10 +109,6 @@ public class TestBootNativeLibraryPath {
public static void main(String[] args) {
try {
if (!System.getProperty("sun.arch.data.model").equals("32")) {
System.out.println("Warning: test skipped for 64-bit systems\n");
return;
}
String osname = System.getProperty("os.name");
if (osname.startsWith("Windows")) {
osname = "Windows";

View File

@ -25,10 +25,13 @@
* @test
* @bug 8024927
* @summary Testing address of compressed class pointer space as best as possible.
* @library /testlibrary
* @requires vm.bits == 64
* @library /testlibrary /test/lib
* @run main CompressedClassPointers
*/
import com.oracle.java.testlibrary.*;
import jtreg.SkippedException;
public class CompressedClassPointers {
@ -114,17 +117,10 @@ public class CompressedClassPointers {
}
public static void main(String[] args) throws Exception {
if (!Platform.is64bit()) {
// Can't test this on 32 bit, just pass
System.out.println("Skipping test on 32bit");
return;
}
// Solaris 10 can't mmap compressed oops space without a base
if (Platform.isSolaris()) {
String name = System.getProperty("os.version");
if (name.equals("5.10")) {
System.out.println("Skipping test on Solaris 10");
return;
throw new SkippedException("Solaris 10 can't mmap compressed oops space without a base");
}
}
smallHeapTest();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@ -27,6 +27,8 @@
* @key regression
* @summary NPG: UseCompressedClassPointers asserts with ObjectAlignmentInBytes=32
* @library /testlibrary
* @requires vm.bits == 64
* @run main CompressedKlassPointerAndOops
*/
import com.oracle.java.testlibrary.*;
@ -34,13 +36,6 @@ import com.oracle.java.testlibrary.*;
public class CompressedKlassPointerAndOops {
public static void main(String[] args) throws Exception {
if (!Platform.is64bit()) {
// Can't test this on 32 bit, just pass
System.out.println("Skipping test on 32bit");
return;
}
runWithAlignment(16);
runWithAlignment(32);
runWithAlignment(64);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 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
@ -23,11 +23,12 @@
/*
* @test TestOnError
* @bug 8078470
* @summary Test using -XX:OnError=<cmd>
* @library /testlibrary
* @requires vm.debug
* @build TestOnError com.oracle.java.testlibrary.*
* @run main TestOnError
* @bug 8078470
*/
import com.oracle.java.testlibrary.*;
@ -35,11 +36,6 @@ import com.oracle.java.testlibrary.*;
public class TestOnError {
public static void main(String[] args) throws Exception {
if (!Platform.isDebugBuild()) {
System.out.println("Test requires a non-product build - skipping");
return;
}
String msg = "Test Succeeded";
// Execute the VM so that a

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2017, 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
@ -21,14 +21,19 @@
* questions.
*/
// ClassFileInstaller is needed to place test.Empty into well-known place
/**
* @test
* @library /runtime/testlibrary
* @library classes
* @build test.Empty ClassUnloadCommon
* @library /test/lib classes
* @build test.Empty
* @run driver ClassFileInstaller test.Empty
* @run main/othervm/timeout=200 FragmentMetaspaceSimple
*/
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
/**
@ -47,8 +52,14 @@ public class FragmentMetaspaceSimple {
private static void runSimple(long time) {
long startTime = System.currentTimeMillis();
ArrayList<ClassLoader> cls = new ArrayList<>();
for (int i = 0; System.currentTimeMillis() < startTime + time; ++i) {
ClassLoader ldr = ClassUnloadCommon.newClassLoader();
char sep = File.separatorChar;
String fileName = "test" + sep + "Empty.class";
File file = new File(fileName);
byte buff[] = read(file);
int i = 0;
for (i = 0; System.currentTimeMillis() < startTime + time; ++i) {
ClassLoader ldr = new MyClassLoader(buff);
if (i % 1000 == 0) {
cls.clear();
}
@ -59,11 +70,43 @@ public class FragmentMetaspaceSimple {
Class<?> c = null;
try {
c = ldr.loadClass("test.Empty");
c.getClass().getClassLoader(); // make sure we have a valid class.
} catch (ClassNotFoundException ex) {
System.out.println("i=" + i + ", len" + buff.length);
throw new RuntimeException(ex);
}
c = null;
}
cls = null;
System.out.println("Finished " + i + " iterations in " +
(System.currentTimeMillis() - startTime) + " ms");
}
private static byte[] read(File file) {
byte buff[] = new byte[(int)(file.length())];
try {
DataInputStream din = new DataInputStream(new FileInputStream(file));
din.readFully(buff);
din.close();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
return buff;
}
static class MyClassLoader extends ClassLoader {
byte buff[];
MyClassLoader(byte buff[]) {
this.buff = buff;
}
public Class<?> loadClass() throws ClassNotFoundException {
String name = "test.Empty";
try {
return defineClass(name, buff, 0, buff.length);
} catch (Throwable e) {
throw new ClassNotFoundException(name, e);
}
}
}
}

View File

@ -26,7 +26,7 @@ import com.oracle.java.testlibrary.OutputAnalyzer;
/*
* @test MaxMetaspaceSizeTest
* @requires vm.bits == "64"
* @requires vm.bits == 64
* @bug 8087291
* @library /testlibrary
* @run main/othervm MaxMetaspaceSizeTest

View File

@ -28,26 +28,20 @@
* This is a negative test; using object alignment for loading that
* is different from object alignment for creating a CDS file
* should fail when loading.
* @requires vm.bits == 64
* @library /testlibrary
* @bug 8025642
* @run main CdsDifferentObjectAlignment
*/
import com.oracle.java.testlibrary.*;
public class CdsDifferentObjectAlignment {
public static void main(String[] args) throws Exception {
String nativeWordSize = System.getProperty("sun.arch.data.model");
if (!Platform.is64bit()) {
System.out.println("ObjectAlignmentInBytes for CDS is only " +
"supported on 64bit platforms; this plaform is " +
nativeWordSize);
System.out.println("Skipping the test");
} else {
createAndLoadSharedArchive(16, 64);
createAndLoadSharedArchive(64, 32);
}
}
// Parameters are object alignment expressed in bytes
private static void

View File

@ -25,26 +25,20 @@
* @test CdsSameObjectAlignment
* @summary Testing CDS (class data sharing) using varying object alignment.
* Using same object alignment for each dump/load pair
* @requires vm.bits == 64
* @library /testlibrary
* @run main CdsSameObjectAlignment
*/
import com.oracle.java.testlibrary.*;
public class CdsSameObjectAlignment {
public static void main(String[] args) throws Exception {
String nativeWordSize = System.getProperty("sun.arch.data.model");
if (!Platform.is64bit()) {
System.out.println("ObjectAlignmentInBytes for CDS is only " +
"supported on 64bit platforms; this plaform is " +
nativeWordSize);
System.out.println("Skipping the test");
} else {
dumpAndLoadSharedArchive(8);
dumpAndLoadSharedArchive(16);
dumpAndLoadSharedArchive(32);
dumpAndLoadSharedArchive(64);
}
}
private static void
dumpAndLoadSharedArchive(int objectAlignmentInBytes) throws Exception {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@ -25,54 +25,55 @@
* @test
* @bug 7051189 8023393
* @summary Need to suppress info message if -Xcheck:jni is used with libjsig.so
* @library /testlibrary
* @library /testlibrary /test/lib
* @requires os.family == "solaris" | os.family == "linux" | os.family == "mac"
* @run main XCheckJSig
*/
import java.util.*;
import java.io.File;
import java.util.Map;
import com.oracle.java.testlibrary.*;
import jtreg.SkippedException;
public class XCheckJSig {
public static void main(String args[]) throws Throwable {
System.out.println("Regression test for bugs 7051189 and 8023393");
if (!Platform.isSolaris() && !Platform.isLinux() && !Platform.isOSX()) {
System.out.println("Test only applicable on Solaris, Linux, and Mac OSX, skipping");
return;
}
String jdk_path = System.getProperty("test.jdk");
String os_arch = Platform.getOsArch();
String libjsig;
String env_var;
if (Platform.isOSX()) {
libjsig = jdk_path + "/jre/lib/server/libjsig.dylib";
env_var = "DYLD_INSERT_LIBRARIES";
} else {
libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so";
env_var = "LD_PRELOAD";
libjsig = jdk_path + "/jre/lib/libjsig.dylib"; // jdk location
if (!(new File(libjsig).exists())) {
libjsig = jdk_path + "/lib/libjsig.dylib"; // jre location
}
String java_program;
if (Platform.isSolaris()) {
// On Solaris, need to call the 64-bit Java directly in order for
// LD_PRELOAD to work because libjsig.so is 64-bit.
java_program = jdk_path + "/jre/bin/" + os_arch + "/java";
} else {
java_program = JDKToolFinder.getJDKTool("java");
env_var = "LD_PRELOAD";
libjsig = jdk_path + "/jre/lib/" + os_arch + "/libjsig.so"; // jdk location
if (!(new File(libjsig).exists())) {
libjsig = jdk_path + "/lib/" + os_arch + "/libjsig.so"; // jre location
}
}
// If this test fails, these might be useful to know.
System.out.println("libjsig: " + libjsig);
System.out.println("osArch: " + os_arch);
System.out.println("java_program: " + java_program);
ProcessBuilder pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-version");
// Make sure the libjsig file exists.
if (!(new File(libjsig).exists())) {
throw new jtreg.SkippedException("File " + libjsig + " not found");
}
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-version");
Map<String, String> env = pb.environment();
env.put(env_var, libjsig);
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldNotContain("libjsig is activated");
output.shouldHaveExitValue(0);
pb = new ProcessBuilder(java_program, "-Xcheck:jni", "-verbose:jni", "-version");
pb = ProcessTools.createJavaProcessBuilder("-Xcheck:jni", "-verbose:jni", "-version");
env = pb.environment();
env.put(env_var, libjsig);
output = new OutputAnalyzer(pb.start());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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 @@
/* @test TestLargePagesFlags
* @summary Tests how large pages are choosen depending on the given large pages flag combinations.
* @requires os.family == "linux"
* @library /testlibrary
* @run main TestLargePagesFlags
*/
@ -30,16 +31,12 @@
import com.oracle.java.testlibrary.OutputAnalyzer;
import com.oracle.java.testlibrary.Platform;
import com.oracle.java.testlibrary.ProcessTools;
import java.util.ArrayList;
public class TestLargePagesFlags {
public static void main(String [] args) throws Exception {
if (!Platform.isLinux()) {
System.out.println("Skipping. TestLargePagesFlags has only been implemented for Linux.");
return;
}
testUseTransparentHugePages();
testUseHugeTLBFS();
testUseSHM();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 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
@ -20,20 +20,24 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.File;
import com.oracle.java.testlibrary.ProcessTools;
import com.oracle.java.testlibrary.OutputAnalyzer;
import java.util.ArrayList;
/*
* @test
* @bug 6515172
* @summary Check that availableProcessors reports the correct value when running in a cpuset on linux
* @requires os.family == "linux"
* @library /testlibrary
* @library /testlibrary /test/lib
* @build com.oracle.java.testlibrary.*
* @run driver AvailableProcessors
*/
import com.oracle.java.testlibrary.ProcessTools;
import com.oracle.java.testlibrary.OutputAnalyzer;
import jtreg.SkippedException;
import java.util.ArrayList;
import java.io.File;
public class AvailableProcessors {
static final String SUCCESS_STRING = "Found expected processors: ";
@ -47,20 +51,18 @@ public class AvailableProcessors {
String taskset;
final String taskset1 = "/bin/taskset";
final String taskset2 = "/usr/bin/taskset";
if (new File(taskset1).exists())
if (new File(taskset1).exists()) {
taskset = taskset1;
else if (new File(taskset2).exists())
} else if (new File(taskset2).exists()) {
taskset = taskset2;
else {
System.out.println("Skipping test: could not find taskset command");
return;
} else {
throw new SkippedException("Could not find taskset command");
}
int available = Runtime.getRuntime().availableProcessors();
if (available == 1) {
System.out.println("Skipping test: only one processor available");
return;
throw new SkippedException("only one processor available");
}
// Get the java command we want to execute

View File

@ -25,8 +25,10 @@ import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.stream.Stream;
public class ClassUnloadCommon {
public static class TestFailure extends RuntimeException {
@ -55,14 +57,45 @@ public class ClassUnloadCommon {
System.gc();
}
/**
* Creates a class loader that loads classes from {@code ${test.class.path}}
* before delegating to the system class loader.
*/
public static ClassLoader newClassLoader() {
String cp = System.getProperty("test.class.path", ".");
URL[] urls = Stream.of(cp.split(File.pathSeparator))
.map(Paths::get)
.map(ClassUnloadCommon::toURL)
.toArray(URL[]::new);
return new URLClassLoader(urls) {
@Override
public Class<?> loadClass(String cn, boolean resolve)
throws ClassNotFoundException
{
synchronized (getClassLoadingLock(cn)) {
Class<?> c = findLoadedClass(cn);
if (c == null) {
try {
return new URLClassLoader(new URL[] {
Paths.get(System.getProperty("test.classes",".") + File.separatorChar + "classes").toUri().toURL(),
}, null);
} catch (MalformedURLException e){
throw new RuntimeException("Unexpected URL conversion failure", e);
}
c = findClass(cn);
} catch (ClassNotFoundException e) {
c = getParent().loadClass(cn);
}
}
if (resolve) {
resolveClass(c);
}
return c;
}
}
};
}
static URL toURL(Path path) {
try {
return path.toUri().toURL();
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014, 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
@ -20,27 +20,27 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import java.io.PrintWriter;
import com.oracle.java.testlibrary.*;
/*
* Test to verify GetObjectSize does not overflow on a 600M element int[]
*
* @test
* @bug 8027230
* @library /testlibrary
* @library /testlibrary /test/lib
* @requires vm.bits == 64
* @build ClassFileInstaller com.oracle.java.testlibrary.* GetObjectSizeOverflowAgent
* @run main ClassFileInstaller GetObjectSizeOverflowAgent
* @run main GetObjectSizeOverflow
*/
import java.io.PrintWriter;
import com.oracle.java.testlibrary.*;
import jtreg.SkippedException;
public class GetObjectSizeOverflow {
public static void main(String[] args) throws Exception {
if (!Platform.is64bit()) {
System.out.println("Test needs a 4GB heap and can only be run as a 64bit process, skipping.");
return;
}
PrintWriter pw = new PrintWriter("MANIFEST.MF");
pw.println("Premain-Class: GetObjectSizeOverflowAgent");
pw.close();
@ -55,8 +55,7 @@ public class GetObjectSizeOverflow {
if (output.getStdout().contains("Could not reserve enough space") || output.getStderr().contains("java.lang.OutOfMemoryError")) {
System.out.println("stdout: " + output.getStdout());
System.out.println("stderr: " + output.getStderr());
System.out.println("Test could not reserve or allocate enough space, skipping");
return;
throw new SkippedException("Test could not reserve or allocate enough space");
}
output.stdoutShouldContain("GetObjectSizeOverflow passed");

View File

@ -52,6 +52,7 @@ public class VMProps implements Callable<Map<String, String>> {
map.put("vm.flavor", vmFlavor());
map.put("vm.compMode", vmCompMode());
map.put("vm.bits", vmBits());
map.put("vm.debug", vmDebug());
dump(map);
return map;
}
@ -103,6 +104,13 @@ public class VMProps implements Callable<Map<String, String>> {
return System.getProperty("sun.arch.data.model");
}
/**
* @return debug level value extracted from the "java.vm.version" property.
*/
protected String vmDebug() {
return "" + System.getProperty("java.vm.version").toLowerCase().contains("debug");
}
/**
* Dumps the map to the file if the file name is given as the property.
* This functionality could be helpful to know context in the real

View File

@ -0,0 +1,38 @@
/*
* Copyright (c) 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
* 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.
*/
package jtreg;
/**
* {@code SkippedException} is an exception treaded by jtreg as an indication
* of skipped status.
*/
public final class SkippedException extends RuntimeException {
public SkippedException(String s, Throwable t) {
super(s, t);
}
public SkippedException(String s) {
super(s);
}
}