blob: 425cf4863fc9399cf540ab7da8ebb0f7223f2e8c [file] [log] [blame]
Alex Light9dcc4572014-08-14 14:16:26 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17public class Main {
18 public static void main(String[] args) {
Mathieu Chartier031768a2015-08-27 10:25:02 -070019 System.loadLibrary(args[0]);
20
Alex Light22cbec42015-09-18 17:09:43 -070021 // With a relocationDelta of 0, the runtime has no way to determine if the oat file in
22 // ANDROID_DATA has been relocated, since a non-relocated oat file always has a 0 delta.
23 // Hitting this condition should be rare and ideally we would prevent it from happening but
24 // there is no way to do so without major changes to the run-test framework.
Igor Murashkin96e83932014-10-29 19:45:42 -070025 boolean executable_correct = (isPic() ?
Alex Light22cbec42015-09-18 17:09:43 -070026 hasExecutableOat() == true :
27 hasExecutableOat() == (isDex2OatEnabled() || isRelocationDeltaZero()));
Igor Murashkin96e83932014-10-29 19:45:42 -070028
Alex Light9dcc4572014-08-14 14:16:26 -070029 System.out.println(
30 "dex2oat & patchoat are " + ((isDex2OatEnabled()) ? "enabled" : "disabled") +
Andreas Gampe0b15f672015-09-30 17:25:15 -070031 ", has oat is " + hasOatFile() + ", has executable oat is " + (
Igor Murashkin96e83932014-10-29 19:45:42 -070032 executable_correct ? "expected" : "not expected") + ".");
Alex Light9dcc4572014-08-14 14:16:26 -070033
Andreas Gampe0b15f672015-09-30 17:25:15 -070034 if (!hasOatFile() && isDex2OatEnabled()) {
Alex Light9dcc4572014-08-14 14:16:26 -070035 throw new Error("Application with dex2oat enabled runs without an oat file");
36 }
37
38 System.out.println(functionCall());
39 }
40
41 public static String functionCall() {
42 String arr[] = {"This", "is", "a", "function", "call"};
43 String ret = "";
44 for (int i = 0; i < arr.length; i++) {
45 ret = ret + arr[i] + " ";
46 }
47 return ret.substring(0, ret.length() - 1);
48 }
49
Alex Light9dcc4572014-08-14 14:16:26 -070050 private native static boolean isDex2OatEnabled();
51
Igor Murashkin96e83932014-10-29 19:45:42 -070052 private native static boolean isPic();
53
Andreas Gampe0b15f672015-09-30 17:25:15 -070054 private native static boolean hasOatFile();
Alex Light9dcc4572014-08-14 14:16:26 -070055
56 private native static boolean hasExecutableOat();
Alex Light22cbec42015-09-18 17:09:43 -070057
58 private native static boolean isRelocationDeltaZero();
Alex Light9dcc4572014-08-14 14:16:26 -070059}