summaryrefslogtreecommitdiff
path: root/test/SignalTest/SignalTest.java
diff options
context:
space:
mode:
author Dave Allison <dallison@google.com> 2014-05-29 19:54:27 +0000
committer Android Git Automerger <android-git-automerger@android.com> 2014-05-29 19:54:27 +0000
commitac835c68fc3e59144f3aa080ad0dbdd2cbe96968 (patch)
treec9a62a2d842b26f28679c9f2e8a44e86692dd710 /test/SignalTest/SignalTest.java
parentf10e5b162d618e5e6bf78919ebd2d4bc0e2e9f83 (diff)
parent8adc1d9d1dd3fabdde6f1ec1b0c735ea8bcbf8e8 (diff)
am 8adc1d9d: Merge "Make use of sigchainlib for signal chaining for implicit checks"
* commit '8adc1d9d1dd3fabdde6f1ec1b0c735ea8bcbf8e8': Make use of sigchainlib for signal chaining for implicit checks
Diffstat (limited to 'test/SignalTest/SignalTest.java')
-rw-r--r--test/SignalTest/SignalTest.java60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/SignalTest/SignalTest.java b/test/SignalTest/SignalTest.java
new file mode 100644
index 0000000000..7f15aeae76
--- /dev/null
+++ b/test/SignalTest/SignalTest.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+class SignalTest {
+ private static native void initSignalTest();
+ private static native void terminateSignalTest();
+ private static native int testSignal();
+
+ private static void stackOverflow() {
+ stackOverflow();
+ }
+
+ public static void main(String[] args) {
+ System.loadLibrary("arttest");
+
+ System.out.println("init signal test");
+ initSignalTest();
+ try {
+ Object o = null;
+ int hash = o.hashCode();
+
+ // Should never get here.
+ System.out.println("hash: " + hash);
+ throw new AssertionError();
+ } catch (NullPointerException e) {
+ System.out.println("Caught NullPointerException");
+ }
+ try {
+ stackOverflow();
+
+ // Should never get here.
+ throw new AssertionError();
+ } catch (StackOverflowError e) {
+ System.out.println("Caught StackOverflowError");
+ }
+
+ // Test that a signal in native code works. This will return
+ // the value 1234 if the signal is caught.
+ int x = testSignal();
+ if (x != 1234) {
+ throw new AssertionError();
+ }
+
+ terminateSignalTest();
+ System.out.println("Signal test OK");
+ }
+}