Index: third_party/android_crazy_linker/src/tests/jni_lib.cpp |
diff --git a/third_party/android_crazy_linker/src/tests/jni_lib.cpp b/third_party/android_crazy_linker/src/tests/jni_lib.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..3686da0d2f8b1ae37cf3fa9bf95cec1f1bd4a66c |
--- /dev/null |
+++ b/third_party/android_crazy_linker/src/tests/jni_lib.cpp |
@@ -0,0 +1,43 @@ |
+// Copyright (c) 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// A simple library that provides JNI_OnLoad() and JNI_OnUnload() hooks. |
+// Used by test_java_vm.cpp |
+ |
+#include <jni.h> |
+#include <stdio.h> |
+#include <stdlib.h> |
+ |
+#define VARNAME "TEST_VAR" |
+ |
+extern "C" int JNI_OnLoad(JavaVM* vm, void* reserved) { |
+ printf("%s: Entering\n", __FUNCTION__); |
+ const char* env = getenv(VARNAME); |
+ if (!env || strcmp(env, "INIT")) { |
+ fprintf(stderr, |
+ "%s: Env variable %s has invalid value: %s (expected INIT)\n", |
+ __FUNCTION__, |
+ VARNAME, |
+ env); |
+ exit(1); |
+ } |
+ setenv(VARNAME, "LOADED", 1); |
+ printf("%s: Exiting\n", __FUNCTION__); |
+ return JNI_VERSION_1_4; |
+} |
+ |
+extern "C" void JNI_OnUnload(JavaVM* vm, void* reserved) { |
+ printf("%s: Entering\n", __FUNCTION__); |
+ const char* env = getenv(VARNAME); |
+ if (!env || strcmp(env, "LOADED")) { |
+ fprintf(stderr, |
+ "%s: Env variable %s has invalid value: %s (expected LOADED)\n", |
+ __FUNCTION__, |
+ VARNAME, |
+ env); |
+ exit(1); |
+ } |
+ setenv(VARNAME, "UNLOADED", 1); |
+ printf("%s: Exiting\n", __FUNCTION__); |
+} |