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

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

Issue 322433006: Fork of the Android NDK crazy linker. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a required license header to a cpp module, missing in the original. Created 6 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..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__);
+}

Powered by Google App Engine
This is Rietveld 408576698