Java Code Examples for jdk.test.lib.Asserts#assertNE()
The following examples show how to use
jdk.test.lib.Asserts#assertNE() .
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: IsMatureTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void test() throws Exception { SimpleClass sclass = new SimpleClass(); Executable method = SimpleClass.class.getDeclaredMethod("testMethod"); long methodData = WB.getMethodData(method); boolean isMature = CompilerToVMHelper.isMature(methodData); Asserts.assertEQ(methodData, 0L, "Never invoked method can't have method data"); Asserts.assertFalse(isMature, "Never invoked method can't be mature"); for (int i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) { sclass.testMethod(); } methodData = WB.getMethodData(method); isMature = CompilerToVMHelper.isMature(methodData); int compLevel = WB.getMethodCompilationLevel(method); // methodData doesn't necessarily exist for interpreter and compilation level 1 if (compLevel != CompilerWhiteBoxTest.COMP_LEVEL_NONE && compLevel != CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE) { Asserts.assertNE(methodData, 0L, "Multiple times invoked method should have method data"); /* a method is not mature in Xcomp mode with tiered compilation disabled, see NonTieredCompPolicy::is_mature */ Asserts.assertEQ(isMature, !(Platform.isComp() && !TIERED), "Unexpected isMature state for multiple times invoked method"); } }
Example 2
Source File: AllocateCompileIdTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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: Invalid.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String args[]) throws Exception { // Allmighty FilePermission af = new FilePermission("<<ALL FILES>>", "read"); // Normal FilePermission fp = new FilePermission("a", "read"); // Invalid FilePermission fp1 = new FilePermission("a\000", "read"); FilePermission fp2 = new FilePermission("a\000", "read"); FilePermission fp3 = new FilePermission("b\000", "read"); // Invalid equals to itself Asserts.assertEQ(fp1, fp1); // and not equals to anything else, including other invalid ones Asserts.assertNE(fp, fp1); Asserts.assertNE(fp1, fp); Asserts.assertNE(fp1, fp2); Asserts.assertNE(fp1, fp3); // Invalid implies itself Asserts.assertTrue(fp1.implies(fp1)); // <<ALL FILES>> implies invalid Asserts.assertTrue(af.implies(fp1)); // and not implies or implied by anything else, including other // invalid ones Asserts.assertFalse(fp.implies(fp1)); Asserts.assertFalse(fp1.implies(fp)); Asserts.assertFalse(fp1.implies(fp2)); Asserts.assertFalse(fp1.implies(fp3)); }
Example 4
Source File: DirectiveParserTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void nonMatchingBrackets() { String fileName = "non-matching.json"; try (JSONFile file = new JSONFile(fileName)) { file.write(JSONFile.Element.ARRAY) .write(JSONFile.Element.OBJECT) .write(JSONFile.Element.PAIR, "match") .write(JSONFile.Element.VALUE, "\"java/lang/String.*\"") .end(); // don't write matching } } OutputAnalyzer output = HugeDirectiveUtil.execute(fileName); Asserts.assertNE(output.getExitValue(), 0, ERROR_MSG + "non matching " + "brackets"); output.shouldContain(EXPECTED_ERROR_STRING); }
Example 5
Source File: MaterializeVirtualObjectTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void check(int iteration) { // Materialize virtual objects on last invocation if (iteration == COMPILE_THRESHOLD) { // get frames and check not-null HotSpotStackFrameReference materialized = CompilerToVMHelper.getNextStackFrame( /* topmost frame */ null, new ResolvedJavaMethod[]{MATERIALIZED_RESOLVED}, /* don't skip any */ 0); Asserts.assertNotNull(materialized, getName() + " : got null frame for materialized method"); HotSpotStackFrameReference notMaterialized = CompilerToVMHelper.getNextStackFrame( /* topmost frame */ null, new ResolvedJavaMethod[]{NOT_MATERIALIZED_RESOLVED}, /* don't skip any */ 0); Asserts.assertNE(materialized, notMaterialized, "Got same frame pointer for both tested frames"); Asserts.assertNotNull(notMaterialized, getName() + " : got null frame for not materialized method"); // check that frames has virtual objects before materialization stage Asserts.assertTrue(materialized.hasVirtualObjects(), getName() + ": materialized frame has no virtual object before materialization"); Asserts.assertTrue(notMaterialized.hasVirtualObjects(), getName() + ": notMaterialized frame has no virtual object before materialization"); // materialize CompilerToVMHelper.materializeVirtualObjects(materialized, INVALIDATE); // check that only not materialized frame has virtual objects Asserts.assertFalse(materialized.hasVirtualObjects(), getName() + " : materialized has virtual object after materialization"); Asserts.assertTrue(notMaterialized.hasVirtualObjects(), getName() + " : notMaterialized has no virtual object after materialization"); // check that materialized frame was deoptimized in case invalidate=true Asserts.assertEQ(WB.isMethodCompiled(MATERIALIZED_METHOD), !INVALIDATE, getName() + " : materialized method has unexpected compiled status"); // check that not materialized frame wasn't deoptimized Asserts.assertTrue(WB.isMethodCompiled(NOT_MATERIALIZED_METHOD), getName() + " : not materialized method has unexpected compiled status"); } }
Example 6
Source File: GetLocalVariableTableTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void runSanityTest(Executable aMethod, Integer expectedTableLength) { HotSpotResolvedJavaMethod method = CTVMUtilities .getResolvedMethod(aMethod); int tblLength = CompilerToVMHelper.getLocalVariableTableLength(method); Asserts.assertEQ(tblLength, expectedTableLength, aMethod + " : incorrect " + "local variable table length."); long tblStart = CompilerToVMHelper.getLocalVariableTableStart(method); if (tblLength > 0) { Asserts.assertNE(tblStart, 0L, aMethod + " : local variable table starts" + " at 0 with length " + tblLength); } }
Example 7
Source File: GetMaxCallTargetOffsetTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void runTest() { long offset1 = CompilerToVMHelper.getMaxCallTargetOffset(0L); Asserts.assertNE(offset1, 0L, "Unexpected maxCallTargetOffset for 0L"); long offset2 = CompilerToVMHelper.getMaxCallTargetOffset(100L); Asserts.assertNE(offset2, 0L, "Unexpected maxCallTargetOffset for 100L"); long offset3 = CompilerToVMHelper.getMaxCallTargetOffset(1000000L); Asserts.assertNE(offset3, 0L, "Unexpected maxCallTargetOffset for 1000000L"); // there can be 2 same offsets, but not 3 Asserts.assertFalse(offset1 == offset2 && offset2 == offset3, "All 3 offsets are unexpectedly equal: " + offset1); }
Example 8
Source File: FilePermissionCollectionMerge.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void test(String arg) { FilePermission fp1 = new FilePermission(arg, "read"); FilePermission fp2 = (FilePermission) FilePermCompat.newPermUsingAltPath(fp1); FilePermission fp3 = (FilePermission) FilePermCompat.newPermPlusAltPath(fp1); // All 3 are different Asserts.assertNE(fp1, fp2); Asserts.assertNE(fp1.hashCode(), fp2.hashCode()); Asserts.assertNE(fp1, fp3); Asserts.assertNE(fp1.hashCode(), fp3.hashCode()); Asserts.assertNE(fp2, fp3); Asserts.assertNE(fp2.hashCode(), fp3.hashCode()); // The plus one implies the other 2 Asserts.assertTrue(fp3.implies(fp1)); Asserts.assertTrue(fp3.implies(fp2)); // The using one different from original Asserts.assertFalse(fp2.implies(fp1)); Asserts.assertFalse(fp1.implies(fp2)); // FilePermssionCollection::implies always works testMerge(fp1); testMerge(fp2); testMerge(fp3); testMerge(fp1, fp2); testMerge(fp1, fp3); testMerge(fp2, fp1); testMerge(fp2, fp3); testMerge(fp3, fp1); testMerge(fp3, fp2); testMerge(fp1, fp2, fp3); testMerge(fp2, fp3, fp1); testMerge(fp3, fp1, fp2); }
Example 9
Source File: ReprofileTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void runSanityTest(Method aMethod) { System.out.println(aMethod); HotSpotResolvedJavaMethod method = CTVMUtilities .getResolvedMethod(aMethod); ProfilingInfo startProfile = method.getProfilingInfo(); Asserts.assertFalse(startProfile.isMature(), aMethod + " : profiling info is mature in the beginning"); // make interpreter to profile this method try { Object obj = aMethod.getDeclaringClass().newInstance(); for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; i++) { aMethod.invoke(obj); } } catch (ReflectiveOperationException e) { throw new Error("TEST BUG : " + e.getMessage(), e); } ProfilingInfo compProfile = method.getProfilingInfo(); Asserts.assertNE(startProfile.toString(), compProfile.toString(), String.format("%s : profiling info wasn't changed after " + "%d invocations", aMethod, CompilerWhiteBoxTest.THRESHOLD)); Asserts.assertTrue(compProfile.isMature(), String.format("%s is not mature after %d invocations", aMethod, CompilerWhiteBoxTest.THRESHOLD)); CompilerToVMHelper.reprofile(method); ProfilingInfo reprofiledProfile = method.getProfilingInfo(); Asserts.assertNE(startProfile.toString(), reprofiledProfile.toString(), aMethod + " : profiling info wasn't changed after reprofiling"); Asserts.assertNE(compProfile.toString(), reprofiledProfile.toString(), aMethod + " : profiling info didn't change after reprofile"); Asserts.assertFalse(reprofiledProfile.isMature(), aMethod + " : profiling info is mature after reprofiling"); }
Example 10
Source File: ListOptionNotExistingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) { OutputAnalyzer oa = JaotcTestHelper.compileLibrary("--compile-commands", "./notExisting.list", "--class-name", COMPILE_ITEM); int exitCode = oa.getExitValue(); Asserts.assertNE(exitCode, 0, "Unexpected compilation exit code"); File compiledLibrary = new File(JaotcTestHelper.DEFAULT_LIB_PATH); Asserts.assertFalse(compiledLibrary.exists(), "Compiler library unexpectedly exists"); }
Example 11
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 12
Source File: State.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Creates state from the string * * @param strings array of strings that represent the state * @return State instance * @see #toString() */ public static State fromString(String[] strings) { Asserts.assertNotNull(strings, "Non null array is required"); Asserts.assertNE(strings.length, 0, "Non empty array is required"); State st = new State(); for (String string : strings) { int i = string.indexOf(' '); String command = string.substring(0, i); String values = string.substring(i + 1); // skip space symbol switch (command) { case "compile" : parseArray(st.compile, values); break; case "force_inline" : parseArray(st.forceInline, values); break; case "dont_inline" : parseArray(st.dontInline, values); break; case "log" : st.log = parseElement(values); break; case "print_assembly" : st.printAssembly = parseElement(values); break; case "print_inline" : st.printInline = parseElement(values); break; default: throw new Error("TESTBUG: "); } } return st; }
Example 13
Source File: ClasspathOptionUnknownClassTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String[] args) { OutputAnalyzer oa = JaotcTestHelper.compileLibrary("--class-name", "HelloWorldOne"); Asserts.assertNE(oa.getExitValue(), 0, "Unexpected compilation exit code"); File compiledLibrary = new File(JaotcTestHelper.DEFAULT_LIB_PATH); Asserts.assertFalse(compiledLibrary.exists(), "Compiler library unexpectedly exists"); }
Example 14
Source File: DrbgParametersSpec.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public static void main(String args[]) throws Exception { byte[] p, np1, np2; // Capability Asserts.assertTrue(PR_AND_RESEED.supportsPredictionResistance()); Asserts.assertTrue(PR_AND_RESEED.supportsReseeding()); Asserts.assertFalse(RESEED_ONLY.supportsPredictionResistance()); Asserts.assertTrue(RESEED_ONLY.supportsReseeding()); Asserts.assertFalse(NONE.supportsPredictionResistance()); Asserts.assertFalse(NONE.supportsReseeding()); // Instantiation p = "Instantiation".getBytes(); DrbgParameters.Instantiation ins = DrbgParameters .instantiation(192, RESEED_ONLY, p); Asserts.assertTrue(ins.getStrength() == 192); Asserts.assertTrue(ins.getCapability() == RESEED_ONLY); np1 = ins.getPersonalizationString(); np2 = ins.getPersonalizationString(); // Getter outputs have same content but not the same object Asserts.assertTrue(Arrays.equals(np1, p)); Asserts.assertTrue(Arrays.equals(np2, p)); Asserts.assertNE(np1, np2); // Changes to original input has no affect on object p[0] = 'X'; np2 = ins.getPersonalizationString(); Asserts.assertTrue(Arrays.equals(np1, np2)); ins = DrbgParameters.instantiation(-1, NONE, null); Asserts.assertNull(ins.getPersonalizationString()); iae(() -> DrbgParameters.instantiation(-2, NONE, null)); npe(() -> DrbgParameters.instantiation(-1, null, null)); // NextBytes p = "NextBytes".getBytes(); DrbgParameters.NextBytes nb = DrbgParameters .nextBytes(192, true, p); Asserts.assertTrue(nb.getStrength() == 192); Asserts.assertTrue(nb.getPredictionResistance()); np1 = nb.getAdditionalInput(); np2 = nb.getAdditionalInput(); // Getter outputs have same content but not the same object Asserts.assertTrue(Arrays.equals(np1, p)); Asserts.assertTrue(Arrays.equals(np2, p)); Asserts.assertNE(np1, np2); // Changes to original input has no affect on object p[0] = 'X'; np2 = nb.getAdditionalInput(); Asserts.assertTrue(Arrays.equals(np1, np2)); iae(() -> DrbgParameters.nextBytes(-2, false, null)); // Reseed p = "Reseed".getBytes(); DrbgParameters.Reseed rs = DrbgParameters .reseed(true, p); Asserts.assertTrue(rs.getPredictionResistance()); np1 = rs.getAdditionalInput(); np2 = rs.getAdditionalInput(); // Getter outputs have same content but not the same object Asserts.assertTrue(Arrays.equals(np1, p)); Asserts.assertTrue(Arrays.equals(np2, p)); Asserts.assertNE(np1, np2); // Changes to original input has no affect on object p[0] = 'X'; np2 = rs.getAdditionalInput(); Asserts.assertTrue(Arrays.equals(np1, np2)); }
Example 15
Source File: CiReplayBase.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
public void negativeTest(String... additionalVmOpts) { Asserts.assertNE(startTest(additionalVmOpts), 0, "Unexpected exit code for negative case: " + Arrays.toString(additionalVmOpts)); }
Example 16
Source File: DeoptimizeFramesTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override protected void test() throws Exception { compile(); checkCompiled(); NMethod nm = NMethod.get(method, testCase.isOsr()); WHITE_BOX.deoptimizeFrames(makeNotEntrant); // #method should still be compiled, since it didn't have frames on stack checkCompiled(); NMethod nm2 = NMethod.get(method, testCase.isOsr()); Asserts.assertEQ(nm.compile_id, nm2.compile_id, "should be the same nmethod"); phaser.register(); Thread t = new Thread(() -> compile(1)); t.start(); // pass 1st phase, #method is on stack int p = phaser.arriveAndAwaitAdvance(); WHITE_BOX.deoptimizeFrames(makeNotEntrant); // pass 2nd phase, #method can exit phaser.awaitAdvance(phaser.arriveAndDeregister()); try { t.join(); } catch (InterruptedException e) { throw new Error("method '" + method + "' is still executing", e); } // invoke one more time to recompile not entrant if any compile(1); nm2 = NMethod.get(method, testCase.isOsr()); if (makeNotEntrant) { if (nm2 != null) { Asserts.assertNE(nm.compile_id, nm2.compile_id, String.format("compilation %d can't be available", nm.compile_id)); } } else { Asserts.assertEQ(nm.compile_id, nm2.compile_id, "should be the same nmethod"); } }
Example 17
Source File: GetNMethodTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@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 18
Source File: DirectiveParserTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static void directory() { OutputAnalyzer output = HugeDirectiveUtil.execute(Utils.TEST_SRC); Asserts.assertNE(output.getExitValue(), 0, ERROR_MSG + "directory as " + "a name"); }
Example 19
Source File: DirectiveParserTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static void noFile() { OutputAnalyzer output = HugeDirectiveUtil.execute("nonexistent.json"); Asserts.assertNE(output.getExitValue(), 0, ERROR_MSG + "non existing " + "file"); }
Example 20
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"); }