huangcm
2025-09-01 53d8e046ac1bf2ebe94f671983e3d3be059df91a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
#
# Copyright (C) 2017 The Android Open Source Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
 
if [[ ! -d libcore ]];  then
  echo "Script needs to be run at the root of the android tree"
  exit 1
fi
 
source build/envsetup.sh >&/dev/null # for get_build_var, setpaths
setpaths # include platform prebuilt java, javac, etc in $PATH.
 
if [[ `uname` != 'Linux' ]];  then
  echo "Script cannot be run on $(uname). It is Linux only."
  exit 2
fi
 
jdwp_path=${ANDROID_JAVA_HOME}/jre/lib/amd64/libjdwp.so
if [[ ! -f $jdwp_path ]];  then
  echo "Unable to find prebuilts libjdwp.so! Did the version change from jdk8?"
  exit 3
fi
 
args=("$@")
debug="no"
has_variant="no"
has_mode="no"
 
while true; do
  if [[ $1 == "--debug" ]]; then
    debug="yes"
    shift
  elif [[ "$1" == --mode=* ]]; then
    has_mode="yes"
    if [[ $1 != "--mode=host" ]];  then
      # Just print out an actually helpful error message.
      echo "Only host tests can be run against prebuilt libjdwp"
      exit 4
    fi
    shift
  elif [[ $1 == --variant=* ]]; then
    has_variant="yes"
    if [[ $1 != "--variant=x64" ]] && [[ $1 != "--variant=X64" ]];  then
      # Just print out an actually helpful error message.
      echo "Only 64bit runs can be tested against the prebuilt libjdwp!"
      exit 5
    fi
    shift
  elif [[ "$1" == "" ]]; then
    break
  else
    shift
  fi
done
 
if [[ "$has_mode" = "no" ]];  then
  args+=(--mode=host)
fi
 
if [[ "$has_variant" = "no" ]];  then
  args+=(--variant=X64)
fi
 
wrapper_name=""
plugin=""
if [[ "$debug" = "yes" ]];  then
  wrapper_name=libwrapagentpropertiesd
  plugin="$ANDROID_HOST_OUT/lib64/libopenjdkjvmtid.so"
else
  wrapper_name=libwrapagentproperties
  plugin="$ANDROID_HOST_OUT/lib64/libopenjdkjvmti.so"
fi
wrapper=$ANDROID_HOST_OUT/lib64/${wrapper_name}.so
 
if [[ ! -f $wrapper ]];  then
  echo "need to build $wrapper to run prebuild-libjdwp-tests!"
  echo "m -j40 ${wrapper/.so/}"
  exit 6
fi
 
if [[ ! -f $plugin ]];  then
  echo "jvmti plugin not built!"
  exit 7
fi
 
props_path=$PWD/art/tools/libjdwp-compat.props
expect_path=$PWD/art/tools/prebuilt_libjdwp_art_failures.txt
 
function verbose_run() {
  echo "$@"
  env "$@"
}
 
verbose_run LD_LIBRARY_PATH="$(dirname $jdwp_path):$LD_LIBRARY_PATH" \
            ./art/tools/run-jdwp-tests.sh                            \
            "${args[@]}"                                             \
            "-Xplugin:$plugin"                                       \
            --agent-wrapper "${wrapper}"="${props_path}"             \
            --jdwp-path "$jdwp_path"                                 \
            --expectations "$expect_path"