Java Code Examples for jdk.test.lib.Asserts#assertLTE()
The following examples show how to use
jdk.test.lib.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 openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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: AllocationCodeBlobTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void test() { System.out.printf("type %s%n", type); // Measure the code cache usage after allocate/free. long start = getUsage(); long addr1 = WHITE_BOX.allocateCodeBlob(SIZE, type.id); long firstAllocation = getUsage(); WHITE_BOX.freeCodeBlob(addr1); long firstFree = getUsage(); long addr2 = WHITE_BOX.allocateCodeBlob(SIZE, type.id); long secondAllocation = getUsage(); WHITE_BOX.freeCodeBlob(addr2); // The following code may trigger resolving of invokedynamic // instructions and therefore method handle intrinsic creation // in the code cache. Make sure this is executed after measuring // the code cache usage. Asserts.assertNE(0, addr1, "first allocation failed"); Asserts.assertNE(0, addr2, "second allocation failed"); Asserts.assertLTE(start + SIZE, firstAllocation, "allocation should increase memory usage: " + start + " + " + SIZE + " <= " + firstAllocation); Asserts.assertLTE(firstFree, firstAllocation, "free shouldn't increase memory usage: " + firstFree + " <= " + firstAllocation); Asserts.assertEQ(firstAllocation, secondAllocation); System.out.println("allocating till possible..."); ArrayList<Long> blobs = new ArrayList<>(); int size = (int) (CODE_CACHE_SIZE >> 7); while ((addr1 = WHITE_BOX.allocateCodeBlob(size, type.id)) != 0) { blobs.add(addr1); } for (Long blob : blobs) { WHITE_BOX.freeCodeBlob(blob); } }
Example 4
Source File: ForceNMethodSweepTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@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 5
Source File: TestRTMSpinLoopCount.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected void runTestCases() throws Throwable { long[] aborts = new long[TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length]; for (int i = 0; i < TestRTMSpinLoopCount.SPIN_LOOP_COUNTS.length; i++) { aborts[i] = getAbortsCountOnLockBusy( TestRTMSpinLoopCount.SPIN_LOOP_COUNTS[i]); } for (int i = 1; i < aborts.length; i++) { Asserts.assertLTE(aborts[i], aborts[i - 1], "Increased spin loop " + "count should not increase retries count."); } }
Example 6
Source File: TestRTMSpinLoopCount.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private long getAbortsCountOnLockBusy(int spinLoopCount) throws Throwable { CompilableTest test = new BusyLock(); OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest( test, CommandLineOptionTest.prepareNumericFlag("RTMRetryCount", TestRTMSpinLoopCount.RTM_RETRY_COUNT), CommandLineOptionTest.prepareNumericFlag("RTMSpinLoopCount", spinLoopCount), "-XX:-UseRTMXendForLockBusy", "-XX:RTMTotalCountIncrRate=1", "-XX:+PrintPreciseRTMLockingStatistics", BusyLock.class.getName(), Boolean.toString(TestRTMSpinLoopCount.INFLATE_MONITOR), Integer.toString(TestRTMSpinLoopCount.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 entry for method " + test.getMethodWithLockName()); RTMLockingStatistics lock = statistics.get(0); Asserts.assertLTE(lock.getTotalAborts(), TestRTMSpinLoopCount.MAX_ABORTS, String.format("Total aborts " + "count (%d) should be less or equal to %d", lock.getTotalAborts(), TestRTMSpinLoopCount.MAX_ABORTS)); return lock.getTotalAborts(); }
Example 7
Source File: TestCodeCacheConfig.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
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 8
Source File: TestCodeCacheConfig.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
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 9
Source File: TestRTMAbortRatio.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private void verifyAbortRatio(int abortRatio, boolean useStackLock) throws Throwable { CompilableTest test = new Test(); OutputAnalyzer outputAnalyzer = RTMTestBase.executeRTMTest( test, CommandLineOptionTest.prepareBooleanFlag("UseRTMForStackLocks", useStackLock), "-XX:+UseRTMDeopt", "-XX:RTMTotalCountIncrRate=1", "-XX:RTMAbortThreshold=0", CommandLineOptionTest.prepareNumericFlag("RTMLockingThreshold", 10 * Test.TOTAL_ITERATIONS), CommandLineOptionTest.prepareNumericFlag("RTMAbortRatio", abortRatio), "-XX:+PrintPreciseRTMLockingStatistics", test.getClass().getName(), Boolean.toString(!useStackLock)); 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."); RTMLockingStatistics lock = statistics.get(0); int actualRatio; if (lock.getTotalAborts() == 1L) { actualRatio = 0; } else { actualRatio = (int) (lock.getTotalLocks() / (lock.getTotalAborts() - 1L)); } Asserts.assertLTE(actualRatio, abortRatio, String.format( "Actual abort ratio (%d) should lower or equal to " + "specified (%d).", actualRatio, abortRatio)); }
Example 10
Source File: CodeCacheUtils.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Verifies that 'newValue' is equal to 'oldValue' if usage of the * corresponding code heap is predictable. Checks the weaker condition * 'newValue <= oldValue' if usage is not predictable because intermediate * allocations may happen. * * @param btype BlobType of the code heap to be checked * @param newValue New value to be verified * @param oldValue Old value to be verified * @param msg Error message if verification fails */ public static void assertEQorLTE(BlobType btype, long newValue, long oldValue, String msg) { if (CodeCacheUtils.isCodeHeapPredictable(btype)) { // Usage is predictable, check strong == condition Asserts.assertEQ(newValue, oldValue, msg); } else { // Usage is not predictable, check weaker <= condition Asserts.assertLTE(newValue, oldValue, msg); } }