Android O SDK.
[android_tools.git] / sdk / tools / bin / monkeyrunner
blob17464302ab6436ba6133ea7108cb9c184a11cb14
1 #!/bin/sh
2 # Copyright 2005-2007, The Android Open Source Project
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 # Set up prog to be the path of this script, including following symlinks,
17 # and set up progdir to be the fully-qualified pathname of its directory.
18 prog="$0"
19 while [ -h "${prog}" ]; do
20 newProg=`/bin/ls -ld "${prog}"`
21 newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
22 if expr "x${newProg}" : 'x/' >/dev/null; then
23 prog="${newProg}"
24 else
25 progdir=`dirname "${prog}"`
26 prog="${progdir}/${newProg}"
28 done
29 oldwd=`pwd`
30 progdir=`dirname "${prog}"`
31 cd "${progdir}/.."
32 progdir=`pwd`
33 prog="${progdir}"/bin/`basename "${prog}"`
34 cd "${oldwd}"
36 frameworkdir="$progdir"
37 libdir="$progdir"
38 jarfile=`basename "$APP_HOME/lib/monkeyrunner-25.3.2.jar"`
39 if [ ! -r "$frameworkdir/${jarfile}" ]
40 then
41 frameworkdir="$progdir"/lib
42 libdir="$progdir"/lib
44 if [ ! -r "$frameworkdir/${jarfile}" ]
45 then
46 frameworkdir=`dirname "$progdir"`/tools/lib
47 libdir=`dirname "$progdir"`/tools/lib
49 if [ ! -r "$frameworkdir/${jarfile}" ]
50 then
51 frameworkdir=`dirname "$progdir"`/framework
52 libdir=`dirname "$progdir"`/lib
54 if [ ! -r "$frameworkdir/${jarfile}" ]
55 then
56 echo `basename "$prog"`": can't find ${jarfile}"
57 exit 1
61 # Check args.
62 if [ debug = "$1" ]; then
63 # add this in for debugging
64 java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
65 shift 1
66 else
67 java_debug=
70 if [ "$OSTYPE" = "cygwin" ] ; then
71 jarpath=`cygpath -w "$frameworkdir/${jarfile}"`
72 progdir=`cygpath -w "$progdir"`
73 else
74 jarpath="$frameworkdir/${jarfile}"
77 # Figure out the path to the swt.jar for the current architecture.
78 # if ANDROID_SWT is defined, then just use this.
79 # else, if running in the Android source tree, then look for the correct swt folder in prebuilt
80 # else, look for the correct swt folder in the SDK under tools/lib/
81 swtpath=""
82 if [ -n "$ANDROID_SWT" ]; then
83 swtpath="$ANDROID_SWT"
84 else
85 vmarch=`"${progdir}"/bin/archquery`
86 if [ -n "$ANDROID_BUILD_TOP" ]; then
87 osname=`uname -s | tr A-Z a-z`
88 swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
89 elif [ -d "$frameworkdir/$vmarch" ]; then
90 swtpath="${frameworkdir}/${vmarch}"
91 else
92 swtpath="${frameworkdir}"
96 if [ ! -d "$swtpath" ]; then
97 echo "SWT folder '${swtpath}' does not exist."
98 echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
99 exit 1
102 # need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
103 # might need more memory, e.g. -Xmx128M
104 exec java -Xmx128M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir:$swtpath" -Djava.library.path="$libdir" -Dcom.android.monkeyrunner.bindir="$progdir" -jar "$jarpath" "$@"