Java Code Examples for com.oracle.java.testlibrary.Asserts#assertLTE()

The following examples show how to use com.oracle.java.testlibrary.Asserts#assertLTE() . 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: TestCapacityUntilGCWrapAround.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    if (Platform.is32bit()) {
        WhiteBox wb = WhiteBox.getWhiteBox();

        long before = wb.metaspaceCapacityUntilGC();
        // Now force possible overflow of capacity_until_GC.
        long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT);

        Asserts.assertGTE(after, before,
                          "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before);
        Asserts.assertLTE(after, MAX_UINT,
                          "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after);
    }
}
 
Example 2
Source File: SurvivorAlignmentTestMain.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies that memory usage in a {@code heapSpace} deviates from
 * {@code expectedUsage} for no more than {@code MAX_RELATIVE_DEVIATION}.
 */
public void verifyMemoryUsage(long expectedUsage) {
    AlignmentHelper alignmentHelper = getAlignmentHelper(testedSpace);

    long actualMemoryUsage = alignmentHelper.getActualMemoryUsage();
    boolean otherThreadsAllocatedMemory = areOtherThreadsAllocatedMemory();

    long memoryUsageDiff = Math.abs(actualMemoryUsage - expectedUsage);
    long maxAllowedUsageDiff
            = alignmentHelper.getAllowedMemoryUsageDeviation(expectedUsage);

    System.out.println("Verifying memory usage in space: " + testedSpace);
    System.out.println("Allocated objects count: " + garbage.length);
    System.out.println("Desired object size: " + objectSize);
    System.out.println("Actual object size: " + actualObjectSize);
    System.out.println("Expected object size in space: "
            + alignmentHelper.getObjectSizeInThisSpace(objectSize));
    System.out.println("Expected memory usage: " + expectedUsage);
    System.out.println("Actual memory usage: " + actualMemoryUsage);
    System.out.println("Memory usage diff: " + memoryUsageDiff);
    System.out.println("Max allowed usage diff: " + maxAllowedUsageDiff);

    if (memoryUsageDiff > maxAllowedUsageDiff
            && otherThreadsAllocatedMemory) {
        System.out.println("Memory usage diff is incorrect, but it seems "
                + "like someone else allocated objects");
        return;
    }

    Asserts.assertLTE(memoryUsageDiff, maxAllowedUsageDiff,
            "Actual memory usage should not deviate from expected for " +
                    "more then " + maxAllowedUsageDiff);
}
 
Example 3
Source File: TestCapacityUntilGCWrapAround.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    if (Platform.is32bit()) {
        WhiteBox wb = WhiteBox.getWhiteBox();

        long before = wb.metaspaceCapacityUntilGC();
        // Now force possible overflow of capacity_until_GC.
        long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT);

        Asserts.assertGTE(after, before,
                          "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before);
        Asserts.assertLTE(after, MAX_UINT,
                          "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after);
    }
}
 
Example 4
Source File: SurvivorAlignmentTestMain.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies that memory usage in a {@code heapSpace} deviates from
 * {@code expectedUsage} for no more than {@code MAX_RELATIVE_DEVIATION}.
 */
public void verifyMemoryUsage(long expectedUsage) {
    AlignmentHelper alignmentHelper = getAlignmentHelper(testedSpace);

    long actualMemoryUsage = alignmentHelper.getActualMemoryUsage();
    boolean otherThreadsAllocatedMemory = areOtherThreadsAllocatedMemory();

    long memoryUsageDiff = Math.abs(actualMemoryUsage - expectedUsage);
    long maxAllowedUsageDiff
            = alignmentHelper.getAllowedMemoryUsageDeviation(expectedUsage);

    System.out.println("Verifying memory usage in space: " + testedSpace);
    System.out.println("Allocated objects count: " + garbage.length);
    System.out.println("Desired object size: " + objectSize);
    System.out.println("Actual object size: " + actualObjectSize);
    System.out.println("Expected object size in space: "
            + alignmentHelper.getObjectSizeInThisSpace(objectSize));
    System.out.println("Expected memory usage: " + expectedUsage);
    System.out.println("Actual memory usage: " + actualMemoryUsage);
    System.out.println("Memory usage diff: " + memoryUsageDiff);
    System.out.println("Max allowed usage diff: " + maxAllowedUsageDiff);

    if (memoryUsageDiff > maxAllowedUsageDiff
            && otherThreadsAllocatedMemory) {
        System.out.println("Memory usage diff is incorrect, but it seems "
                + "like someone else allocated objects");
        return;
    }

    Asserts.assertLTE(memoryUsageDiff, maxAllowedUsageDiff,
            "Actual memory usage should not deviate from expected for " +
                    "more then " + maxAllowedUsageDiff);
}
 
Example 5
Source File: TestCapacityUntilGCWrapAround.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    if (Platform.is32bit()) {
        WhiteBox wb = WhiteBox.getWhiteBox();

        long before = wb.metaspaceCapacityUntilGC();
        // Now force possible overflow of capacity_until_GC.
        long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT);

        Asserts.assertGTE(after, before,
                          "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before);
        Asserts.assertLTE(after, MAX_UINT,
                          "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after);
    }
}
 
Example 6
Source File: SurvivorAlignmentTestMain.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies that memory usage in a {@code heapSpace} deviates from
 * {@code expectedUsage} for no more than {@code MAX_RELATIVE_DEVIATION}.
 */
public void verifyMemoryUsage(long expectedUsage) {
    AlignmentHelper alignmentHelper = getAlignmentHelper(testedSpace);

    long actualMemoryUsage = alignmentHelper.getActualMemoryUsage();
    boolean otherThreadsAllocatedMemory = areOtherThreadsAllocatedMemory();

    long memoryUsageDiff = Math.abs(actualMemoryUsage - expectedUsage);
    long maxAllowedUsageDiff
            = alignmentHelper.getAllowedMemoryUsageDeviation(expectedUsage);

    System.out.println("Verifying memory usage in space: " + testedSpace);
    System.out.println("Allocated objects count: " + garbage.length);
    System.out.println("Desired object size: " + objectSize);
    System.out.println("Actual object size: " + actualObjectSize);
    System.out.println("Expected object size in space: "
            + alignmentHelper.getObjectSizeInThisSpace(objectSize));
    System.out.println("Expected memory usage: " + expectedUsage);
    System.out.println("Actual memory usage: " + actualMemoryUsage);
    System.out.println("Memory usage diff: " + memoryUsageDiff);
    System.out.println("Max allowed usage diff: " + maxAllowedUsageDiff);

    if (memoryUsageDiff > maxAllowedUsageDiff
            && otherThreadsAllocatedMemory) {
        System.out.println("Memory usage diff is incorrect, but it seems "
                + "like someone else allocated objects");
        return;
    }

    Asserts.assertLTE(memoryUsageDiff, maxAllowedUsageDiff,
            "Actual memory usage should not deviate from expected for " +
                    "more then " + maxAllowedUsageDiff);
}
 
Example 7
Source File: TestCapacityUntilGCWrapAround.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    if (Platform.is32bit()) {
        WhiteBox wb = WhiteBox.getWhiteBox();

        long before = wb.metaspaceCapacityUntilGC();
        // Now force possible overflow of capacity_until_GC.
        long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT);

        Asserts.assertGTE(after, before,
                          "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before);
        Asserts.assertLTE(after, MAX_UINT,
                          "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after);
    }
}
 
Example 8
Source File: SurvivorAlignmentTestMain.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies that memory usage in a {@code heapSpace} deviates from
 * {@code expectedUsage} for no more than {@code MAX_RELATIVE_DEVIATION}.
 */
public void verifyMemoryUsage(long expectedUsage) {
    AlignmentHelper alignmentHelper = getAlignmentHelper(testedSpace);

    long actualMemoryUsage = alignmentHelper.getActualMemoryUsage();
    boolean otherThreadsAllocatedMemory = areOtherThreadsAllocatedMemory();

    long memoryUsageDiff = Math.abs(actualMemoryUsage - expectedUsage);
    long maxAllowedUsageDiff
            = alignmentHelper.getAllowedMemoryUsageDeviation(expectedUsage);

    System.out.println("Verifying memory usage in space: " + testedSpace);
    System.out.println("Allocated objects count: " + garbage.length);
    System.out.println("Desired object size: " + objectSize);
    System.out.println("Actual object size: " + actualObjectSize);
    System.out.println("Expected object size in space: "
            + alignmentHelper.getObjectSizeInThisSpace(objectSize));
    System.out.println("Expected memory usage: " + expectedUsage);
    System.out.println("Actual memory usage: " + actualMemoryUsage);
    System.out.println("Memory usage diff: " + memoryUsageDiff);
    System.out.println("Max allowed usage diff: " + maxAllowedUsageDiff);

    if (memoryUsageDiff > maxAllowedUsageDiff
            && otherThreadsAllocatedMemory) {
        System.out.println("Memory usage diff is incorrect, but it seems "
                + "like someone else allocated objects");
        return;
    }

    Asserts.assertLTE(memoryUsageDiff, maxAllowedUsageDiff,
            "Actual memory usage should not deviate from expected for " +
                    "more then " + maxAllowedUsageDiff);
}
 
Example 9
Source File: TestCapacityUntilGCWrapAround.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) {
    if (Platform.is32bit()) {
        WhiteBox wb = WhiteBox.getWhiteBox();

        long before = wb.metaspaceCapacityUntilGC();
        // Now force possible overflow of capacity_until_GC.
        long after = wb.incMetaspaceCapacityUntilGC(MAX_UINT);

        Asserts.assertGTE(after, before,
                          "Increasing with MAX_UINT should not cause wrap around: " + after + " < " + before);
        Asserts.assertLTE(after, MAX_UINT,
                          "Increasing with MAX_UINT should not cause value larger than MAX_UINT:" + after);
    }
}
 
Example 10
Source File: SurvivorAlignmentTestMain.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Verifies that memory usage in a {@code heapSpace} deviates from
 * {@code expectedUsage} for no more than {@code MAX_RELATIVE_DEVIATION}.
 */
public void verifyMemoryUsage(long expectedUsage) {
    AlignmentHelper alignmentHelper = getAlignmentHelper(testedSpace);

    long actualMemoryUsage = alignmentHelper.getActualMemoryUsage();
    boolean otherThreadsAllocatedMemory = areOtherThreadsAllocatedMemory();

    long memoryUsageDiff = Math.abs(actualMemoryUsage - expectedUsage);
    long maxAllowedUsageDiff
            = alignmentHelper.getAllowedMemoryUsageDeviation(expectedUsage);

    System.out.println("Verifying memory usage in space: " + testedSpace);
    System.out.println("Allocated objects count: " + garbage.length);
    System.out.println("Desired object size: " + objectSize);
    System.out.println("Actual object size: " + actualObjectSize);
    System.out.println("Expected object size in space: "
            + alignmentHelper.getObjectSizeInThisSpace(objectSize));
    System.out.println("Expected memory usage: " + expectedUsage);
    System.out.println("Actual memory usage: " + actualMemoryUsage);
    System.out.println("Memory usage diff: " + memoryUsageDiff);
    System.out.println("Max allowed usage diff: " + maxAllowedUsageDiff);

    if (memoryUsageDiff > maxAllowedUsageDiff
            && otherThreadsAllocatedMemory) {
        System.out.println("Memory usage diff is incorrect, but it seems "
                + "like someone else allocated objects");
        return;
    }

    Asserts.assertLTE(memoryUsageDiff, maxAllowedUsageDiff,
            "Actual memory usage should not deviate from expected for " +
                    "more then " + maxAllowedUsageDiff);
}