/* *Entrypointandteststhatareexpectedtosucceed.
*/ publicclass Main { /** *Drivestests.
*/ publicstaticvoid main(String[] args) throws Exception {
System.loadLibrary(args[0]); if (!hasOatFile() || runtimeIsSoftFail() || isInterpreted()) { // Some tests ensure that the verifier was able to guarantee balanced locking by // asserting that the test function is running as compiled code. But skip this now, // as this seems to be a non-compiled code test configuration.
disableStackFrameAsserts();
}
// Smali testing code. privatestaticvoid runSmaliTests() {
runTest("OK", new Object[] { new Object(), new Object() }, null);
runTest("TooDeep", new Object[] { new Object() }, null);
runTest("NotStructuredOverUnlock", new Object[] { new Object() },
IllegalMonitorStateException.class);
runTest("NotStructuredUnderUnlock", new Object[] { new Object() },
IllegalMonitorStateException.class);
runTest("UnbalancedJoin", new Object[] { new Object(), new Object() }, null);
runTest("UnbalancedStraight", new Object[] { new Object(), new Object() }, null);
runTest("NullLocks", new Object[] { false }, null);
runTest("NullLocks", new Object[] { true }, NullPointerException.class);
}
// For simplicity we assume that test methods are not overloaded. So searching by name // will give us the method we need to run.
Method method = null; for (Method m : methods) { if (m.getName().equals("run")) {
method = m; break;
}
}
if (method == null) {
System.out.println("Could not find test method for " + className);
} elseif (!Modifier.isStatic(method.getModifiers())) {
System.out.println("Test method for " + className + " is not static.");
} else {
method.invoke(null, parameters); if (excType != null) {
System.out.println("Expected an exception in " + className);
}
}
} catch (Throwable exc) { if (excType == null) {
System.out.println("Did not expect exception " + exc + " for " + className);
exc.printStackTrace(System.out);
} elseif (exc instanceof InvocationTargetException && exc.getCause() != null &&
exc.getCause().getClass().equals(excType)) { // Expected exception is wrapped in InvocationTargetException.
} elseif (!excType.equals(exc.getClass())) {
System.out.println("Expected " + excType.getName() + ", but got " + exc.getClass());
} else { // Expected exception, do nothing.
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.