• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
46has_jdwp_path="no"
47# The bitmap of log messages in libjdwp. See list in the help message for more
48# info on what these are. The default is 'errors | callbacks'
49verbose_level=0xC0
50
51arg_idx=0
52while true; do
53  if [[ $1 == "--debug" ]]; then
54    debug="yes"
55    shift
56  elif [[ $1 == --test-timeout-ms ]]; then
57    has_timeout="yes"
58    shift
59    arg_idx=$((arg_idx + 1))
60    shift
61  elif [[ "$1" == "--mode=jvm" ]]; then
62    has_mode="yes"
63    mode="ri"
64    shift
65  elif [[ "$1" == --mode=host ]]; then
66    has_mode="yes"
67    mode="host"
68    shift
69  elif [[ $1 == --verbose-all ]]; then
70    has_verbose="yes"
71    verbose_level=0xFFF
72    unset args[arg_idx]
73    shift
74  elif [[ $1 == --no-skips ]]; then
75    declare -a known_bad_tests=()
76    unset args[arg_idx]
77    shift
78  elif [[ $1 == --verbose ]]; then
79    has_verbose="yes"
80    shift
81  elif [[ $1 == --verbose-level ]]; then
82    shift
83    verbose_level=$1
84    # remove both the --verbose-level and the argument.
85    unset args[arg_idx]
86    arg_idx=$((arg_idx + 1))
87    unset args[arg_idx]
88    shift
89  elif [[ $1 == --variant=* ]]; then
90    has_variant="yes"
91    shift
92  elif [[ $1 == *gcstress ]]; then
93    has_gcstress="yes"
94    shift
95  elif [[ $1 == --jdwp-path* ]]; then
96    has_jdwp_path="yes"
97    shift
98  elif [[ "$1" == "" ]]; then
99    break
100  else
101    shift
102  fi
103  arg_idx=$((arg_idx + 1))
104done
105
106if [[ "$has_mode" = "no" ]];  then
107  args+=(--mode=device)
108fi
109
110if [[ "$has_variant" = "no" && "$mode" != "ri" ]];  then
111  # --mode=jvm doesn't support variant option.
112  args+=(--variant=X32)
113fi
114
115if [[ "$has_jdwp_path" = "no" ]]; then
116  if [[ "$mode" == "ri" ]]; then
117    if [ -z "$ANDROID_BUILD_TOP" ]; then
118      echo "Please set ANDROID_BUILD_TOP"
119      exit 1
120    fi
121    args+=(--jdwp-path  $ANDROID_BUILD_TOP/"prebuilts/jdk/jdk17/linux-x86/lib/libjdwp.so")
122  else
123    args+=(--jdwp-path  "libjdwp.so")
124  fi
125fi
126
127if [[ "$has_timeout" = "no" ]]; then
128  # Double the timeout to 20 seconds
129  args+=(--test-timeout-ms)
130  if [[ "$has_verbose" = "yes" || "$has_gcstress" = "yes" ]]; then
131    # Extra time if verbose or gcstress is set since those can be
132    # quite heavy.
133    args+=(300000)
134  else
135    args+=(20000)
136  fi
137fi
138
139if [[ "$has_verbose" = "yes" ]]; then
140  args+=(--vm-arg)
141  args+=(-Djpda.settings.debuggeeAgentExtraOptions=directlog=y,logfile=/proc/self/fd/2,logflags=$verbose_level)
142fi
143
144if [[ "$mode" != "ri" ]]; then
145  # We don't use full paths since it is difficult to determine them for device
146  # tests and not needed due to resolution rules of dlopen.
147  if [[ "$debug" = "yes" ]]; then
148    args+=(-Xplugin:libopenjdkjvmtid.so)
149  else
150    args+=(-Xplugin:libopenjdkjvmti.so)
151  fi
152fi
153
154expectations="--expectations $PWD/art/tools/external_oj_libjdwp_art_failures.txt"
155
156if [[ "$debug" = "yes" && "$has_gcstress" = "yes" ]]; then
157  expectations="$expectations --expectations $PWD/art/tools/external_oj_libjdwp_art_gcstress_debug_failures.txt"
158fi
159
160if [[ "${ART_USE_READ_BARRIER}" = "false" ]]; then
161  expectations="$expectations --expectations $PWD/art/tools/external_oj_libjdwp_art_no_read_barrier_failures.txt"
162fi
163
164function verbose_run() {
165  echo "$@"
166  env "$@"
167}
168
169for skip in "${known_bad_tests[@]}"; do
170  args+=("--skip-test" "$skip")
171done
172
173# Tell run-jdwp-tests.sh it was called from run-libjdwp-tests.sh
174export RUN_JDWP_TESTS_CALLED_FROM_LIBJDWP=true
175
176verbose_run ./art/tools/run-jdwp-tests.sh \
177            "${args[@]}"                  \
178            --vm-arg -Djpda.settings.debuggeeAgentExtraOptions=coredump=y \
179            --vm-arg -Djpda.settings.testSuiteType=libjdwp \
180            "$expectations"
181