Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(561)

Unified Diff: third_party/android_crazy_linker/src/tests/jni_lib.cpp

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8fd12d622ba89d90a9946a66607d62960259ef5a
--- /dev/null
+++ b/third_party/android_crazy_linker/src/tests/jni_lib.cpp
@@ -0,0 +1,43 @@
+// Copyright 2014 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__);
+}

Powered by Google App Engine
This is Rietveld 408576698