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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // A simple library that provides JNI_OnLoad() and JNI_OnUnload() hooks.
6 // Used by test_java_vm.cpp
7
8 #include <jni.h>
9 #include <stdio.h>
10 #include <stdlib.h>
11
12 #define VARNAME "TEST_VAR"
13
14 extern "C" int JNI_OnLoad(JavaVM* vm, void* reserved) {
15 printf("%s: Entering\n", __FUNCTION__);
16 const char* env = getenv(VARNAME);
17 if (!env || strcmp(env, "INIT")) {
18 fprintf(stderr,
19 "%s: Env variable %s has invalid value: %s (expected INIT)\n",
20 __FUNCTION__,
21 VARNAME,
22 env);
23 exit(1);
24 }
25 setenv(VARNAME, "LOADED", 1);
26 printf("%s: Exiting\n", __FUNCTION__);
27 return JNI_VERSION_1_4;
28 }
29
30 extern "C" void JNI_OnUnload(JavaVM* vm, void* reserved) {
31 printf("%s: Entering\n", __FUNCTION__);
32 const char* env = getenv(VARNAME);
33 if (!env || strcmp(env, "LOADED")) {
34 fprintf(stderr,
35 "%s: Env variable %s has invalid value: %s (expected LOADED)\n",
36 __FUNCTION__,
37 VARNAME,
38 env);
39 exit(1);
40 }
41 setenv(VARNAME, "UNLOADED", 1);
42 printf("%s: Exiting\n", __FUNCTION__);
43 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698