1#!/bin/bash 2# 3# Copyright (C) 2017 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 17if [[ ! -d libcore ]]; then 18 echo "Script needs to be run at the root of the android tree" 19 exit 1 20fi 21 22if [[ `uname` != 'Linux' ]]; then 23 echo "Script cannot be run on $(uname). It is Linux only." 24 exit 2 25fi 26 27# See b/141907697. These tests all crash on both the RI and ART when using the libjdwp agent JDWP 28# implementation. To avoid them cluttering the log on the buildbot we explicitly skip them. This 29# list should not be added to. 30declare -a known_bad_tests=( 31 'org.apache.harmony.jpda.tests.jdwp.ClassType_NewInstanceTest#testNewInstance002' 32 'org.apache.harmony.jpda.tests.jdwp.ObjectReference_GetValues002Test#testGetValues002' 33 'org.apache.harmony.jpda.tests.jdwp.ObjectReference_SetValuesTest#testSetValues001' 34 'org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference_NameTest#testName001_NullObject' 35 'org.apache.harmony.jpda.tests.jdwp.ThreadGroupReference_ParentTest#testParent_NullObject' 36) 37 38declare -a args=("$@") 39debug="no" 40has_variant="no" 41has_mode="no" 42mode="target" 43has_gcstress="no" 44has_timeout="no" 45has_verbose="no" 46# The bitmap of log messages in libjdwp. See list in the help message for more 47# info on what these are. The default is 'errors | callbacks' 48verbose_level=0xC0 49 50arg_idx=0 51while true; do 52 if [[ $1 == "--debug" ]]; then 53 debug="yes" 54 shift 55 elif [[ $1 == --test-timeout-ms ]]; then 56 has_timeout="yes" 57 shift 58 arg_idx=$((arg_idx + 1)) 59 shift 60 elif [[ "$1" == "--mode=jvm" ]]; then 61 has_mode="yes" 62 mode="ri" 63 shift 64 elif [[ "$1" == --mode=host ]]; then 65 has_mode="yes" 66 mode="host" 67 shift 68 elif [[ $1 == --verbose-all ]]; then 69 has_verbose="yes" 70 verbose_level=0xFFF 71 unset args[arg_idx] 72 shift 73 elif [[ $1 == --no-skips ]]; then 74 declare -a known_bad_tests=() 75 unset args[arg_idx] 76 shift 77 elif [[ $1 == --verbose ]]; then 78 has_verbose="yes" 79 shift 80 elif [[ $1 == --verbose-level ]]; then 81 shift 82 verbose_level=$1 83 # remove both the --verbose-level and the argument. 84 unset args[arg_idx] 85 arg_idx=$((arg_idx + 1)) 86 unset args[arg_idx] 87 shift 88 elif [[ $1 == --variant=* ]]; then 89 has_variant="yes" 90 shift 91 elif [[ $1 == *gcstress ]]; then 92 has_gcstress="yes" 93 shift 94 elif [[ "$1" == "" ]]; then 95 break 96 else 97 shift 98 fi 99 arg_idx=$((arg_idx + 1)) 100done 101 102if [[ "$has_mode" = "no" ]]; then 103 args+=(--mode=device) 104fi 105 106if [[ "$has_variant" = "no" ]]; then 107 args+=(--variant=X32) 108fi 109 110if [[ "$has_timeout" = "no" ]]; then 111 # Double the timeout to 20 seconds 112 args+=(--test-timeout-ms) 113 if [[ "$has_verbose" = "yes" || "$has_gcstress" = "yes" ]]; then 114 # Extra time if verbose or gcstress is set since those can be 115 # quite heavy. 116 args+=(300000) 117 else 118 args+=(20000) 119 fi 120fi 121 122if [[ "$has_verbose" = "yes" ]]; then 123 args+=(--vm-arg) 124 args+=(-Djpda.settings.debuggeeAgentExtraOptions=directlog=y,logfile=/proc/self/fd/2,logflags=$verbose_level) 125fi 126 127# We don't use full paths since it is difficult to determine them for device 128# tests and not needed due to resolution rules of dlopen. 129if [[ "$debug" = "yes" ]]; then 130 args+=(-Xplugin:libopenjdkjvmtid.so) 131else 132 args+=(-Xplugin:libopenjdkjvmti.so) 133fi 134 135expect_path=$PWD/art/tools/external_oj_libjdwp_art_failures.txt 136function verbose_run() { 137 echo "$@" 138 env "$@" 139} 140 141for skip in "${known_bad_tests[@]}"; do 142 args+=("--skip-test" "$skip") 143done 144 145# Tell run-jdwp-tests.sh it was called from run-libjdwp-tests.sh 146export RUN_JDWP_TESTS_CALLED_FROM_LIBJDWP=true 147 148verbose_run ./art/tools/run-jdwp-tests.sh \ 149 "${args[@]}" \ 150 --jdwp-path "libjdwp.so" \ 151 --vm-arg -Djpda.settings.debuggeeAgentExtraOptions=coredump=y \ 152 --vm-arg -Djpda.settings.testSuiteType=libjdwp \ 153 --expectations "$expect_path" 154