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

The following examples show how to use jdk.test.lib.Asserts#assertLT() . 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: TestEagerReclaimHumongousRegions.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 {
    ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
        "-XX:+UseG1GC",
        "-Xms128M",
        "-Xmx128M",
        "-Xmn16M",
        "-Xlog:gc",
        ReclaimRegionFast.class.getName());

    Pattern p = Pattern.compile("Full GC");

    OutputAnalyzer output = new OutputAnalyzer(pb.start());

    int found = 0;
    Matcher m = p.matcher(output.getStdout());
    while (m.find()) { found++; }
    System.out.println("Issued " + found + " Full GCs");
    Asserts.assertLT(found, 10, "Found that " + found + " Full GCs were issued. This is larger than the bound. Eager reclaim seems to not work at all");

    output.shouldHaveExitValue(0);
}
 
Example 2
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 3
Source File: ForceNMethodSweepTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void test() throws Exception {
    // prime the asserts: get their bytecodes loaded, any lazy computation
    // resolved, and executed once
    Asserts.assertGT(1, 0, "message");
    Asserts.assertLTE(0, 0, "message");
    Asserts.assertLT(-1, 0, "message");

    checkNotCompiled();
    guaranteedSweep();
    int usage = getTotalUsage();

    compile();
    checkCompiled();
    int afterCompilation = getTotalUsage();
    Asserts.assertGT(afterCompilation, usage,
            "compilation should increase usage");

    guaranteedSweep();
    int afterSweep = getTotalUsage();
    Asserts.assertLTE(afterSweep, afterCompilation,
            "sweep shouldn't increase usage");

    deoptimize();
    guaranteedSweep();
    int afterDeoptAndSweep = getTotalUsage();
    Asserts.assertLT(afterDeoptAndSweep, afterSweep,
            "sweep after deoptimization should decrease usage");
 }
 
Example 4
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());
}