1#!/bin/bash 2# 3# Copyright 2016 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17plugin=libopenjdkjvmtid.so 18agent=libtiagentd.so 19if [[ "$@" == *"-O"* ]]; then 20 agent=libtiagent.so 21 plugin=libopenjdkjvmti.so 22fi 23 24if [[ "$@" == *"--interpreter"* ]]; then 25 # On interpreter we are fully capable of providing the full jvmti api so we 26 # have a slightly different expected output. 27 # TODO We should really be changing this in the 'check' script. 28 patch -s expected.txt <interpreter-expected.patch 29fi 30 31# Provide additional runtime options when running on device. 32extra_runtime_options= 33if [[ "$@" != *"--host"* ]]; then 34 if [[ -z "$ANDROID_BUILD_TOP" ]]; then 35 echo 'ANDROID_BUILD_TOP environment variable is empty; did you forget to run `lunch`?' 36 exit 1 37 fi 38 39 bitness_flag=--32 40 if [[ "$@" == *"--64"* ]]; then 41 bitness_flag=--64 42 fi 43 44 # Path to native libraries installed on the device for testing purposes. 45 test_native_lib_path=$("$ANDROID_BUILD_TOP/art/test/utils/get-device-test-native-lib-path" \ 46 "$bitness_flag") 47 48 # The linker configuration used for dalvikvm(64) in the ART APEX requires us 49 # to pass the full path to the agent to the runtime when running on device. 50 agent=${test_native_lib_path}/${agent} 51 52 # The above agent path is an absolute one; append the root directory to the 53 # library path so that the agent can be found via the `java.library.path` 54 # system property (see method `Main.find` in 55 # test/909-attach-agent/src-art/Main.java). 56 extra_runtime_options="--runtime-option -Djava.library.path=${test_native_lib_path}:/" 57fi 58 59export ANDROID_LOG_TAGS='*:f' 60./default-run "$@" --android-runtime-option -Xplugin:${plugin} \ 61 --android-runtime-option -Xcompiler-option \ 62 --android-runtime-option --debuggable \ 63 $extra_runtime_options \ 64 --args agent:${agent}=909-attach-agent 65return_status1=$? 66 67./default-run "$@" --android-runtime-option -Xcompiler-option \ 68 --android-runtime-option --debuggable \ 69 $extra_runtime_options \ 70 --args agent:${agent}=909-attach-agent 71return_status2=$? 72 73./default-run "$@" $extra_runtime_options \ 74 --args agent:${agent}=909-attach-agent \ 75 --external-log-tags 76return_status3=$? 77 78./default-run "$@" $extra_runtime_options \ 79 --args agent:${agent}=909-attach-agent \ 80 --args disallow-debugging \ 81 --external-log-tags 82return_status4=$? 83 84# Make sure we don't silently ignore an early failure. 85(exit $return_status1) && \ 86 (exit $return_status2) && \ 87 (exit $return_status3) && \ 88 (exit $return_status4) 89