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_timeout="no" 44has_verbose="no" 45# The bitmap of log messages in libjdwp. See list in the help message for more 46# info on what these are. The default is 'errors | callbacks' 47verbose_level=0xC0 48 49arg_idx=0 50while true; do 51 if [[ $1 == "--debug" ]]; then 52 debug="yes" 53 shift 54 elif [[ $1 == --test-timeout-ms ]]; then 55 has_timeout="yes" 56 shift 57 arg_idx=$((arg_idx + 1)) 58 shift 59 elif [[ "$1" == "--mode=jvm" ]]; then 60 has_mode="yes" 61 mode="ri" 62 shift 63 elif [[ "$1" == --mode=host ]]; then 64 has_mode="yes" 65 mode="host" 66 shift 67 elif [[ $1 == --verbose-all ]]; then 68 has_verbose="yes" 69 verbose_level=0xFFF 70 unset args[arg_idx] 71 shift 72 elif [[ $1 == --no-skips ]]; then 73 declare -a known_bad_tests=() 74 unset args[arg_idx] 75 shift 76 elif [[ $1 == --verbose ]]; then 77 has_verbose="yes" 78 shift 79 elif [[ $1 == --verbose-level ]]; then 80 shift 81 verbose_level=$1 82 # remove both the --verbose-level and the argument. 83 unset args[arg_idx] 84 arg_idx=$((arg_idx + 1)) 85 unset args[arg_idx] 86 shift 87 elif [[ $1 == --variant=* ]]; then 88 has_variant="yes" 89 shift 90 elif [[ "$1" == "" ]]; then 91 break 92 else 93 shift 94 fi 95 arg_idx=$((arg_idx + 1)) 96done 97 98if [[ "$has_mode" = "no" ]]; then 99 args+=(--mode=device) 100fi 101 102if [[ "$has_variant" = "no" ]]; then 103 args+=(--variant=X32) 104fi 105 106if [[ "$has_timeout" = "no" ]]; then 107 # Double the timeout to 20 seconds 108 args+=(--test-timeout-ms) 109 if [[ "$has_verbose" = "no" ]]; then 110 args+=(20000) 111 else 112 # Even more time if verbose is set since those can be quite heavy. 113 args+=(200000) 114 fi 115fi 116 117if [[ "$has_verbose" = "yes" ]]; then 118 args+=(--vm-arg) 119 args+=(-Djpda.settings.debuggeeAgentExtraOptions=directlog=y,logfile=/proc/self/fd/2,logflags=$verbose_level) 120fi 121 122# We don't use full paths since it is difficult to determine them for device 123# tests and not needed due to resolution rules of dlopen. 124if [[ "$debug" = "yes" ]]; then 125 args+=(-Xplugin:libopenjdkjvmtid.so) 126else 127 args+=(-Xplugin:libopenjdkjvmti.so) 128fi 129 130expect_path=$PWD/art/tools/external_oj_libjdwp_art_failures.txt 131function verbose_run() { 132 echo "$@" 133 env "$@" 134} 135 136for skip in "${known_bad_tests[@]}"; do 137 args+=("--skip-test" "$skip") 138done 139 140# Tell run-jdwp-tests.sh it was called from run-libjdwp-tests.sh 141export RUN_JDWP_TESTS_CALLED_FROM_LIBJDWP=true 142 143verbose_run ./art/tools/run-jdwp-tests.sh \ 144 "${args[@]}" \ 145 --jdwp-path "libjdwp.so" \ 146 --vm-arg -Djpda.settings.debuggeeAgentExtraOptions=coredump=y \ 147 --vm-arg -Djpda.settings.testSuiteType=libjdwp \ 148 --expectations "$expect_path" 149