Java Code Examples for jdk.test.lib.Asserts#assertGT()

The following examples show how to use jdk.test.lib.Asserts#assertGT() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DisassembleCodeBlobTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void check(CompileCodeTestCase testCase) {
    System.out.println(testCase);
    // to have a clean state
    NMethod nMethod = testCase.deoptimizeAndCompile();
    if (nMethod == null) {
        throw new Error(testCase + " : method is not compiled");
    }
    InstalledCode installedCode = testCase.toInstalledCode();
    String str = CompilerToVMHelper.disassembleCodeBlob(installedCode);
    if (str != null) {
        Asserts.assertGT(str.length(), 0,
               testCase +  " : returned string has to be non-zero length");
    }
    String str2 = CompilerToVMHelper.disassembleCodeBlob(installedCode);
    Asserts.assertEQ(str, str2,
            testCase + " : 2nd invocation returned different value");
}
 
Example 2
Source File: AllocateCompileIdTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private void runSanityCorrectTest(CompileCodeTestCase testCase) {
    System.out.println(testCase);
    Executable aMethod = testCase.executable;
    // to generate ciTypeFlow
    testCase.invoke(Utils.getNullValues(aMethod.getParameterTypes()));
    int bci = testCase.bci;
    HotSpotResolvedJavaMethod method = CTVMUtilities
            .getResolvedMethod(aMethod);
    for (int i = 0; i < SOME_REPEAT_VALUE; ++i) {
        int wbCompileID = getWBCompileID(testCase);
        int id = CompilerToVMHelper.allocateCompileId(method, bci);
        Asserts.assertNE(id, 0, testCase + " : zero compile id");
        Asserts.assertGT(id, wbCompileID, testCase
                + " : allocated 'compile id' not  greater than existed");
        Asserts.assertTrue(ids.add(wbCompileID), testCase
                + " : vm compilation allocated existing id " + id);
        Asserts.assertTrue(ids.add(id), testCase
                + " : allocateCompileId returned existing id " + id);
    }
}
 
Example 3
Source File: TestJcmdOutput.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    int minHeapFreeRatio = new Integer((new DynamicVMOption("MinHeapFreeRatio")).getValue());
    int maxHeapFreeRatio = new Integer((new DynamicVMOption("MaxHeapFreeRatio")).getValue());
    PidJcmdExecutor executor = new PidJcmdExecutor();

    Asserts.assertGT(minHeapFreeRatio, 0, "MinHeapFreeRatio must be greater than 0");
    Asserts.assertLT(maxHeapFreeRatio, 100, "MaxHeapFreeRatio must be less than 100");

    /* Check out-of-range values */
    executor.execute("VM.set_flag MinHeapFreeRatio -1", true).shouldContain(JCMD_OUT_OF_RANGE_MESSAGE);
    executor.execute("VM.set_flag MaxHeapFreeRatio 101", true).shouldContain(JCMD_OUT_OF_RANGE_MESSAGE);

    /* Check values which not allowed by constraint */
    executor.execute(
            String.format("VM.set_flag MinHeapFreeRatio %d", maxHeapFreeRatio + 1), true)
            .shouldContain(JCMD_CONSTRAINT_MESSAGE);
    executor.execute(
            String.format("VM.set_flag MaxHeapFreeRatio %d", minHeapFreeRatio - 1), true)
            .shouldContain(JCMD_CONSTRAINT_MESSAGE);
}
 
Example 4
Source File: CompileModuleTest.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
    // compile only java.lang.String::length from java.base module to have reasonable compilation time
    try {
        Files.write(COMPILE_COMMAND_FILE, Arrays.asList(COMPILE_COMMAND),
                StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW);
    } catch (IOException e) {
        throw new Error("TESTBUG: can't write list file " + e, e);
    }
    OutputAnalyzer oa = JaotcTestHelper.compileLibrary("--compile-commands",
            COMPILE_COMMAND_FILE.toString(), "--module", "java.base");
    oa.shouldHaveExitValue(0);
    File compiledLibrary = new File(JaotcTestHelper.DEFAULT_LIB_PATH);
    Asserts.assertTrue(compiledLibrary.exists(), "Compiled library file missing");
    Asserts.assertGT(compiledLibrary.length(), 0L, "Unexpected compiled library size");
    JaotcTestHelper.checkLibraryUsage(TESTED_CLASS_NAME, EXPECTED, UNEXPECTED);
}
 
Example 5
Source File: CompileClassTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    OutputAnalyzer oa = JaotcTestHelper.compileLibrary("--class-name", JaotcTestHelper
            .getClassAotCompilationName(HelloWorldOne.class));
    oa.shouldHaveExitValue(0);
    File compiledLibrary = new File(JaotcTestHelper.DEFAULT_LIB_PATH);
    Asserts.assertTrue(compiledLibrary.exists(), "Compiled library file missing");
    Asserts.assertGT(compiledLibrary.length(), 0L, "Unexpected compiled library size");
    JaotcTestHelper.checkLibraryUsage(HelloWorldOne.class.getName());
}
 
Example 6
Source File: TestPrintPreciseRTMLockingStatistics.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void verifyAbortsCount(AbortType abortType) throws Throwable {
    AbortProvoker provoker = abortType.provoker();

    OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
            provoker,
            "-XX:+PrintPreciseRTMLockingStatistics",
            AbortProvoker.class.getName(),
            abortType.toString());

    outputAnalyzer.shouldHaveExitValue(0);

    List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
            provoker.getMethodWithLockName(),outputAnalyzer.getOutput());

    Asserts.assertGT(statistics.size(), 0, "VM output should contain one "
            + "rtm locking statistics entry for method "
            + provoker.getMethodWithLockName());

    RTMLockingStatistics lock = statistics.get(0);

    Asserts.assertGT(lock.getTotalAborts(), 0L,
            "RTM locking statistics should contain non zero total aborts "
            + "count");

    Asserts.assertGT(lock.getAborts(abortType), 0L, String.format(
            "RTM locking statistics should contain non zero aborts count "
            + "for abort reason %s", abortType));
}
 
Example 7
Source File: InitialAndMaxUsageTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
protected void runTest() {
    long headerSize = CodeCacheUtils.getHeaderSize(btype);
    MemoryPoolMXBean bean = btype.getMemoryPool();
    long initialUsage = btype.getMemoryPool().getUsage().getUsed();
    System.out.printf("INFO: trying to test %s of max size %d and initial"
            + " usage %d%n", bean.getName(), maxSize, initialUsage);
    Asserts.assertLT(initialUsage + headerSize + 1L, maxSize,
            "Initial usage is close to total size for " + bean.getName());
    if (lowerBoundIsZero) {
        Asserts.assertEQ(initialUsage, 0L, "Unexpected initial usage");
    }
    ArrayList<Long> blobs = new ArrayList<>();
    long minAllocationUnit = Math.max(1, CodeCacheUtils.MIN_ALLOCATION - headerSize);
    /* now filling code cache with large-sized allocation first, since
     lots of small allocations takes too much time, so, just a small
     optimization */
    try {
        for (int coef = 1000000; coef > 0; coef /= 10) {
            fillWithSize(coef * minAllocationUnit, blobs, bean);
        }
        Asserts.assertGT((double) bean.getUsage().getUsed(),
                CACHE_USAGE_COEF * maxSize, String.format("Unable to fill "
                        + "more than %f of %s. Reported usage is %d ",
                        CACHE_USAGE_COEF, bean.getName(),
                        bean.getUsage().getUsed()));
    } finally {
        for (long entry : blobs) {
            CodeCacheUtils.WB.freeCodeBlob(entry);
        }
    }
    System.out.printf("INFO: Scenario finished successfully for %s%n",
            bean.getName());
}
 
Example 8
Source File: GetStackTraceElementTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void runSanityTest(Executable aMethod, int[] bcis) {
    HotSpotResolvedJavaMethod method = CTVMUtilities
            .getResolvedMethod(aMethod);
    String className = aMethod.getDeclaringClass().getName();
    String methodName = aMethod.getName().equals(className)
            ? "<init>"
            : aMethod.getName();
    String fileName = getFileName(className);
    Map<Integer, Integer> bciWithLineNumber = CTVMUtilities
            .getBciToLineNumber(aMethod);
    boolean isNative = Modifier.isNative(aMethod.getModifiers());
    int lineNumber = -1;
    for (int bci : bcis) {
        StackTraceElement ste = CompilerToVMHelper
                .getStackTraceElement(method, bci);
        Asserts.assertNotNull(ste, aMethod + " : got null StackTraceElement"
                + " at bci " + bci);
        Asserts.assertEQ(className, ste.getClassName(), aMethod
                + " : unexpected class name");
        Asserts.assertEQ(fileName, ste.getFileName(), aMethod
                + " : unexpected filename");
        Asserts.assertEQ(methodName, ste.getMethodName(), aMethod
                + " : unexpected method name");
        Asserts.assertEQ(isNative, ste.isNativeMethod(), aMethod
                + " : unexpected 'isNative' value");
        if (bciWithLineNumber.size() > 0) {
            if (bciWithLineNumber.containsKey(bci)) {
                lineNumber = bciWithLineNumber.get(bci);
            }
            Asserts.assertEQ(lineNumber, ste.getLineNumber(), aMethod
                    + " : unexpected line number");
        } else {
            // native and abstract function
            Asserts.assertGT(0, ste.getLineNumber(),
                    aMethod + " : unexpected line number for abstract "
                            + "or native method");
        }
    }

}
 
Example 9
Source File: ListOptionTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    try {
        Files.write(COMPILE_COMMAND_FILE, Arrays.asList(COMPILE_COMMAND),
                StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW);
    } catch (IOException e) {
        throw new Error("TESTBUG: can't write list file " + e, e);
    }
    OutputAnalyzer oa = JaotcTestHelper.compileLibrary("--compile-commands", COMPILE_COMMAND_FILE.toString(),
            "--class-name", JaotcTestHelper.getClassAotCompilationName(HelloWorldOne.class));
    oa.shouldHaveExitValue(0);
    File compiledLibrary = new File(JaotcTestHelper.DEFAULT_LIB_PATH);
    Asserts.assertTrue(compiledLibrary.exists(), "Compiled library file missing");
    Asserts.assertGT(compiledLibrary.length(), 0L, "Unexpected compiled library size");
    JaotcTestHelper.checkLibraryUsage(TESTED_CLASS_NAME, EXPECTED, UNEXPECTED);
}
 
Example 10
Source File: TestRTMLockingCalculationDelay.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void verifyLockingCalculationDelay(long delay, long testDelay,
        boolean deoptExpected) throws Throwable {
    AbortProvoker provoker = AbortType.XABORT.provoker();
    String logFileName = String.format("rtm_delay_%d_%d.xml", delay,
            testDelay);

    OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
            logFileName,
            provoker,
            "-XX:+UseRTMDeopt",
            CommandLineOptionTest.prepareNumericFlag(
                    "RTMLockingCalculationDelay", delay),
            "-XX:RTMAbortRatio=0",
            "-XX:RTMAbortThreshold=0",
            AbortProvoker.class.getName(),
            AbortType.XABORT.toString(),
            Boolean.toString(
                    TestRTMLockingCalculationDelay.INFLATE_MONITOR),
            Long.toString(AbortProvoker.DEFAULT_ITERATIONS),
            Long.toString(testDelay)
    );

    outputAnalyzer.shouldHaveExitValue(0);

    int deopts = RTMTestBase.firedRTMStateChangeTraps(logFileName);

    if (deoptExpected) {
        Asserts.assertGT(deopts, 0, "At least one deoptimization due to "
                + "rtm_state_chage is expected");
    } else {
        Asserts.assertEQ(deopts, 0, "No deoptimizations due to "
                + "rtm_state_chage are expected");
    }
}
 
Example 11
Source File: CompileDirectoryTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    OutputAnalyzer oa =JaotcTestHelper.compileLibrary("--directory", ".");
    oa.shouldHaveExitValue(0);
    File compiledLibrary = new File(JaotcTestHelper.DEFAULT_LIB_PATH);
    Asserts.assertTrue(compiledLibrary.exists(), "Compiled library file missing");
    Asserts.assertGT(compiledLibrary.length(), 0L, "Unexpected compiled library size");
    JaotcTestHelper.checkLibraryUsage(HelloWorldOne.class.getName());
    JaotcTestHelper.checkLibraryUsage(HelloWorldTwo.class.getName());
}
 
Example 12
Source File: TestUseRTMXendForLockBusy.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private void verifyXendForLockBusy(boolean inflateMonitor,
        boolean useXend) throws Throwable {
    CompilableTest test = new BusyLock();

    OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest(
            test,
            CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks",
                    inflateMonitor),
            CommandLineOptionTest.prepareBooleanFlag(
                    "UseRTMXendForLockBusy",
                    useXend),
            "-XX:RTMRetryCount=0",
            "-XX:RTMTotalCountIncrRate=1",
            "-XX:+PrintPreciseRTMLockingStatistics",
            BusyLock.class.getName(),
            Boolean.toString(inflateMonitor),
            Integer.toString(TestUseRTMXendForLockBusy.LOCKING_TIME)
    );

    outputAnalyzer.shouldHaveExitValue(0);

    List<RTMLockingStatistics> statistics = RTMLockingStatistics.fromString(
            test.getMethodWithLockName(), outputAnalyzer.getOutput());

    Asserts.assertEQ(statistics.size(), 1, "VM output should contain "
            + "exactly one rtm locking statistics entry for method "
            + test.getMethodWithLockName());

    long aborts = statistics.get(0).getAborts(AbortType.XABORT);

    if (useXend) {
        Asserts.assertEQ(aborts, 0L,
                "Expected to get no aborts on busy lock");
    } else {
        Asserts.assertGT(aborts, 0L,
                "Expected to get at least one abort on busy lock");
    }
}
 
Example 13
Source File: TestMetaspaceSizeFlags.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static void testMaxMetaspaceSizeGTMetaspaceSize(long maxMetaspaceSize, long metaspaceSize) throws Exception {
  MetaspaceFlags mf = runAndGetValue(maxMetaspaceSize, metaspaceSize);
  Asserts.assertGT(maxMetaspaceSize, metaspaceSize);
  Asserts.assertGT(mf.maxMetaspaceSize, mf.metaspaceSize);
  Asserts.assertEQ(mf.maxMetaspaceSize, maxMetaspaceSize);
  Asserts.assertEQ(mf.metaspaceSize, metaspaceSize);
}
 
Example 14
Source File: TestCodeCacheConfig.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Recording recording = new Recording();
    recording.enable(EVENT_NAME);
    recording.start();
    recording.stop();

    List<RecordedEvent> events = Events.fromRecording(recording);
    Events.hasEvents(events);
    RecordedEvent event = events.get(0);
    long initialSize = (long) event.getValue("initialSize");
    long reservedSize = (long) event.getValue("reservedSize");
    long nonNMethodSize = (long) event.getValue("nonNMethodSize");
    long profiledSize = (long) event.getValue("profiledSize");
    long nonProfiledSize = (long) event.getValue("nonProfiledSize");
    long expansionSize = (long) event.getValue("expansionSize");
    long minBlockLength = (long) event.getValue("minBlockLength");
    long startAddress = (long) event.getValue("startAddress");
    long reservedTopAddress = (long) event.getValue("reservedTopAddress");

    Asserts.assertGT(initialSize, 1024L,
        "initialSize less than 1024 byte, got " + initialSize);

    Asserts.assertEQ(reservedSize, CodeCacheExpectedSize,
        String.format("Unexpected reservedSize value. Expected %d but " + "got %d", CodeCacheExpectedSize, reservedSize));

    Asserts.assertLTE(nonNMethodSize, CodeCacheExpectedSize,
        String.format("Unexpected nonNMethodSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, nonNMethodSize));

    Asserts.assertLTE(profiledSize, CodeCacheExpectedSize,
        String.format("Unexpected profiledSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, profiledSize));

    Asserts.assertLTE(nonProfiledSize, CodeCacheExpectedSize,
        String.format("Unexpected nonProfiledSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, nonProfiledSize));

    Asserts.assertGTE(expansionSize, 1024L,
        "expansionSize less than 1024 " + "bytes, got " + expansionSize);

    Asserts.assertGTE(minBlockLength, 1L,
        "minBlockLength less than 1 byte, got " + minBlockLength);

    Asserts.assertNE(startAddress, 0L,
        "startAddress null");

    Asserts.assertNE(reservedTopAddress, 0L,
        "codeCacheReservedTopAddr null");
}
 
Example 15
Source File: CiReplayBase.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public boolean generateReplay(boolean needCoreDump, String... vmopts) {
    OutputAnalyzer crashOut;
    String crashOutputString;
    try {
        List<String> options = new ArrayList<>();
        options.addAll(Arrays.asList(REPLAY_GENERATION_OPTIONS));
        options.addAll(Arrays.asList(vmopts));
        options.add(needCoreDump ? ENABLE_COREDUMP_ON_CRASH : DISABLE_COREDUMP_ON_CRASH);
        options.add(VERSION_OPTION);
        if (needCoreDump) {
            crashOut = ProcessTools.executeProcess(getTestJavaCommandlineWithPrefix(
                    RUN_SHELL_NO_LIMIT, options.toArray(new String[0])));
        } else {
            crashOut = ProcessTools.executeProcess(ProcessTools.createJavaProcessBuilder(true,
                    options.toArray(new String[0])));
        }
        crashOutputString = crashOut.getOutput();
        Asserts.assertNotEquals(crashOut.getExitValue(), 0, "Crash JVM exits gracefully");
        Files.write(Paths.get("crash.out"), crashOutputString.getBytes(),
                StandardOpenOption.CREATE, StandardOpenOption.WRITE,
                StandardOpenOption.TRUNCATE_EXISTING);
    } catch (Throwable t) {
        throw new Error("Can't create replay: " + t, t);
    }
    if (needCoreDump) {
        String coreFileLocation = getCoreFileLocation(crashOutputString);
        if (coreFileLocation == null) {
            if (Platform.isOSX()) {
                File coresDir = new File("/cores");
                if (!coresDir.isDirectory() || !coresDir.canWrite()) {
                    return false;
                }
            }
            throw new Error("Couldn't find core file location in: '" + crashOutputString + "'");
        }
        try {
            Asserts.assertGT(new File(coreFileLocation).length(), 0L, "Unexpected core size");
            Files.move(Paths.get(coreFileLocation), Paths.get(TEST_CORE_FILE_NAME));
        } catch (IOException ioe) {
            throw new Error("Can't move core file: " + ioe, ioe);
        }
    }
    removeFromCurrentDirectoryStartingWith(HS_ERR_NAME);
    return true;
}
 
Example 16
Source File: GetNMethodTest.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void test() throws Exception {
    checkNotCompiled();

    compile();
    checkCompiled();

    NMethod nmethod = NMethod.get(method, testCase.isOsr());
    if (IS_VERBOSE) {
        System.out.println("nmethod = " + nmethod);
    }
    Asserts.assertNotNull(nmethod,
            "nmethod of compiled method is null");
    Asserts.assertNotNull(nmethod.insts,
            "nmethod.insts of compiled method is null");
    Asserts.assertGT(nmethod.insts.length, 0,
            "compiled method's instructions is empty");
    Asserts.assertNotNull(nmethod.code_blob_type, "blob type is null");
    if (WHITE_BOX.getBooleanVMFlag("SegmentedCodeCache")) {
        Asserts.assertNE(nmethod.code_blob_type, BlobType.All);
        switch (nmethod.comp_level) {
        case 1:
        case 4:
            checkBlockType(nmethod, BlobType.MethodNonProfiled);
            break;
        case 2:
        case 3:
            checkBlockType(nmethod, BlobType.MethodProfiled);
            break;
        default:
            throw new Error("unexpected comp level " + nmethod);
        }
    } else {
        Asserts.assertEQ(nmethod.code_blob_type, BlobType.All);
    }

    deoptimize();
    checkNotCompiled();
    nmethod = NMethod.get(method, testCase.isOsr());
    Asserts.assertNull(nmethod,
            "nmethod of non-compiled method isn't null");
}
 
Example 17
Source File: TestOptionsWithRangesDynamic.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    int failedTests;
    List<JVMOption> allWriteableOptions;

    /* Get only writeable options */
    allWriteableOptions = JVMOptionsUtils.getOptionsWithRange(origin -> (origin.contains("manageable") || origin.contains("rw")));

    Asserts.assertGT(allWriteableOptions.size(), 0, "Options with ranges not found!");

    System.out.println("Test " + allWriteableOptions.size() + " writeable options with ranges. Start test!");

    failedTests = JVMOptionsUtils.runDynamicTests(allWriteableOptions);

    failedTests += JVMOptionsUtils.runJcmdTests(allWriteableOptions);

    failedTests += JVMOptionsUtils.runAttachTests(allWriteableOptions);

    Asserts.assertEQ(failedTests, 0,
            String.format("%d tests failed! %s", failedTests, JVMOptionsUtils.getMessageWithFailures()));
}
 
Example 18
Source File: TestOptionsWithRanges.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    int failedTests;
    List<JVMOption> allOptions;

    allOptionsAsMap = JVMOptionsUtils.getOptionsWithRangeAsMap(origin -> (!(origin.contains("develop") || origin.contains("notproduct"))));

    /* Shared flags can cause JVM to exit with error code 2 */
    setAllowedExitCodes("SharedReadWriteSize", 2);
    setAllowedExitCodes("SharedReadOnlySize", 2);
    setAllowedExitCodes("SharedMiscDataSize", 2);
    setAllowedExitCodes("SharedMiscCodeSize", 2);

    /*
     * Remove CICompilerCount from testing because currently it can hang system
     */
    excludeTestMaxRange("CICompilerCount");

    /*
     * Exclude MallocMaxTestWords as it is expected to exit VM at small values (>=0)
     */
    excludeTestMinRange("MallocMaxTestWords");

    /*
     * Exclude below options as their maximum value would consume too much memory
     * and would affect other tests that run in parallel.
     */
    excludeTestMaxRange("ConcGCThreads");
    excludeTestMaxRange("G1ConcRefinementThreads");
    excludeTestMaxRange("G1RSetRegionEntries");
    excludeTestMaxRange("G1RSetSparseRegionEntries");
    excludeTestMaxRange("G1UpdateBufferSize");
    excludeTestMaxRange("InitialBootClassLoaderMetaspaceSize");
    excludeTestMaxRange("InitialHeapSize");
    excludeTestMaxRange("MaxHeapSize");
    excludeTestMaxRange("MaxRAM");
    excludeTestMaxRange("NewSize");
    excludeTestMaxRange("OldSize");
    excludeTestMaxRange("ParallelGCThreads");

    /*
     * Remove parameters controlling the code cache. As these
     * parameters have implications on the physical memory
     * reserved by the VM, setting them to large values may hang
     * the system and/or may cause concurrently executed tests to
     * fail. These parameters are rigorously checked when the code
     * cache is initialized (see
     * hotspot/src/shared/vm/code/codeCache.cpp), therefore
     * omitting testing for them does not pose a problem.
     */
    excludeTestMaxRange("InitialCodeCacheSize");
    excludeTestMaxRange("CodeCacheMinimumUseSpace");
    excludeTestMaxRange("ReservedCodeCacheSize");
    excludeTestMaxRange("NonProfiledCodeHeapSize");
    excludeTestMaxRange("ProfiledCodeHeapSize");
    excludeTestMaxRange("NonNMethodCodeHeapSize");
    excludeTestMaxRange("CodeCacheExpansionSize");

    allOptions = new ArrayList<>(allOptionsAsMap.values());

    Asserts.assertGT(allOptions.size(), 0, "Options with ranges not found!");

    System.out.println("Parsed " + allOptions.size() + " options with ranges. Start test!");

    failedTests = JVMOptionsUtils.runCommandLineTests(allOptions);

    Asserts.assertEQ(failedTests, 0,
            String.format("%d tests failed! %s", failedTests, JVMOptionsUtils.getMessageWithFailures()));
}
 
Example 19
Source File: TestLargePageUseForAuxMemory.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    // Size that a single card covers.
    final int cardSize = 512;
    WhiteBox wb = WhiteBox.getWhiteBox();
    smallPageSize = wb.getVMPageSize();
    largePageSize = wb.getVMLargePageSize();
    allocGranularity = wb.getVMAllocationGranularity();
    final long heapAlignment = lcm(cardSize * smallPageSize, largePageSize);

    if (largePageSize == 0) {
        System.out.println("Skip tests because large page support does not seem to be available on this platform.");
        return;
    }
    if (largePageSize == smallPageSize) {
        System.out.println("Skip tests because large page support does not seem to be available on this platform." +
                           "Small and large page size are the same.");
        return;
    }

    // To get large pages for the card table etc. we need at least a 1G heap (with 4k page size).
    // 32 bit systems will have problems reserving such an amount of contiguous space, so skip the
    // test there.
    if (!Platform.is32bit()) {
        final long heapSizeForCardTableUsingLargePages = largePageSize * cardSize;
        final long heapSizeDiffForCardTable = Math.max(Math.max(allocGranularity * cardSize, HEAP_REGION_SIZE), largePageSize);

        Asserts.assertGT(heapSizeForCardTableUsingLargePages, heapSizeDiffForCardTable,
                         "To test we would require to use an invalid heap size");
        testVM("case1: card table and bitmap use large pages (barely)", heapSizeForCardTableUsingLargePages, true, true);
        testVM("case2: card table and bitmap use large pages (extra slack)", heapSizeForCardTableUsingLargePages + heapSizeDiffForCardTable, true, true);
        testVM("case3: only bitmap uses large pages (barely not)", heapSizeForCardTableUsingLargePages - heapSizeDiffForCardTable, false, true);
    }

    // Minimum heap requirement to get large pages for bitmaps is 128M heap. This seems okay to test
    // everywhere.
    final int bitmapTranslationFactor = 8 * 8; // ObjectAlignmentInBytes * BitsPerByte
    final long heapSizeForBitmapUsingLargePages = largePageSize * bitmapTranslationFactor;
    final long heapSizeDiffForBitmap = Math.max(Math.max(allocGranularity * bitmapTranslationFactor, HEAP_REGION_SIZE),
                                                Math.max(largePageSize, heapAlignment));

    Asserts.assertGT(heapSizeForBitmapUsingLargePages, heapSizeDiffForBitmap,
                     "To test we would require to use an invalid heap size");

    testVM("case4: only bitmap uses large pages (barely)", heapSizeForBitmapUsingLargePages, false, true);
    testVM("case5: only bitmap uses large pages (extra slack)", heapSizeForBitmapUsingLargePages + heapSizeDiffForBitmap, false, true);
    testVM("case6: nothing uses large pages (barely not)", heapSizeForBitmapUsingLargePages - heapSizeDiffForBitmap, false, false);
}
 
Example 20
Source File: TestCodeCacheConfig.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
    Recording recording = new Recording();
    recording.enable(EVENT_NAME);
    recording.start();
    recording.stop();

    List<RecordedEvent> events = Events.fromRecording(recording);
    Events.hasEvents(events);
    RecordedEvent event = events.get(0);
    long initialSize = (long) event.getValue("initialSize");
    long reservedSize = (long) event.getValue("reservedSize");
    long nonNMethodSize = (long) event.getValue("nonNMethodSize");
    long profiledSize = (long) event.getValue("profiledSize");
    long nonProfiledSize = (long) event.getValue("nonProfiledSize");
    long expansionSize = (long) event.getValue("expansionSize");
    long minBlockLength = (long) event.getValue("minBlockLength");
    long startAddress = (long) event.getValue("startAddress");
    long reservedTopAddress = (long) event.getValue("reservedTopAddress");

    Asserts.assertGT(initialSize, 1024L,
        "initialSize less than 1024 byte, got " + initialSize);

    Asserts.assertEQ(reservedSize, CodeCacheExpectedSize,
        String.format("Unexpected reservedSize value. Expected %d but " + "got %d", CodeCacheExpectedSize, reservedSize));

    Asserts.assertLTE(nonNMethodSize, CodeCacheExpectedSize,
        String.format("Unexpected nonNMethodSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, nonNMethodSize));

    Asserts.assertLTE(profiledSize, CodeCacheExpectedSize,
        String.format("Unexpected profiledSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, profiledSize));

    Asserts.assertLTE(nonProfiledSize, CodeCacheExpectedSize,
        String.format("Unexpected nonProfiledSize value. Expected <= %d but " + "got %d", CodeCacheExpectedSize, nonProfiledSize));

    Asserts.assertGTE(expansionSize, 1024L,
        "expansionSize less than 1024 " + "bytes, got " + expansionSize);

    Asserts.assertGTE(minBlockLength, 1L,
        "minBlockLength less than 1 byte, got " + minBlockLength);

    Asserts.assertNE(startAddress, 0L,
        "startAddress null");

    Asserts.assertNE(reservedTopAddress, 0L,
        "codeCacheReservedTopAddr null");
}