blob: 485740ed8c41ea7c0743e8c2063f5ff828b03f1f [file] [log] [blame]
Brett Chabota91ea002011-01-30 13:48:20 -08001#!/bin/bash
2
3# Copyright (C) 2011 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
17# launcher script for cts-tradefed harness
18# can be used from an Android build environment, or a standalone cts zip
19
20checkFile() {
21 if [ ! -f "$1" ]; then
22 echo "Unable to locate $1"
23 exit
24 fi;
25}
26
27checkPath() {
28 if ! type -P $1 &> /dev/null; then
29 echo "Unable to find $1 in path."
30 exit
31 fi;
32}
33
34checkPath adb
35checkPath java
36
37# check java version
Narayan Kamath68034252014-01-22 18:09:25 +000038JAVA_VERSION=$(java -version 2>&1 | head -n 1 | grep '[ "]1\.[67][\. "$$]')
Brett Chabota91ea002011-01-30 13:48:20 -080039if [ "${JAVA_VERSION}" == "" ]; then
Narayan Kamath68034252014-01-22 18:09:25 +000040 echo "Wrong java version. 1.6 or 1.7 is required."
Brett Chabota91ea002011-01-30 13:48:20 -080041 exit
42fi
43
Brett Chabot4f146a42011-10-05 18:36:42 -070044# check debug flag and set up remote debugging
45if [ -n "${TF_DEBUG}" ]; then
46 if [ -z "${TF_DEBUG_PORT}" ]; then
47 TF_DEBUG_PORT=10088
48 fi
49 RDBG_FLAG=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=${TF_DEBUG_PORT}
50fi
51
52
Brett Chabota91ea002011-01-30 13:48:20 -080053# check if in Android build env
JP Abgrall8e6d93d2013-09-25 16:52:44 -070054if [ ! -z "${ANDROID_BUILD_TOP}" ]; then
55 if [ ! -z "${ANDROID_HOST_OUT}" ]; then
56 CTS_ROOT=${ANDROID_HOST_OUT}/cts
Brett Chabota91ea002011-01-30 13:48:20 -080057 else
JP Abgrall8e6d93d2013-09-25 16:52:44 -070058 HOST=`uname`
59 if [ "$HOST" == "Linux" ]; then
60 OS="linux-x86"
61 elif [ "$HOST" == "Darwin" ]; then
62 OS="darwin-x86"
63 else
64 echo "Unrecognized OS"
65 exit
66 fi
67 CTS_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/cts
68 fi
Brett Chabota91ea002011-01-30 13:48:20 -080069 if [ ! -d ${CTS_ROOT} ]; then
70 echo "Could not find $CTS_ROOT in Android build environment. Try 'make cts'"
71 exit
72 fi;
73fi;
74
75if [ -z ${CTS_ROOT} ]; then
76 # assume we're in an extracted cts install
Brett Chabotcdb404d2011-01-28 10:34:41 -080077 CTS_ROOT="$(dirname $0)/../.."
Brett Chabota91ea002011-01-30 13:48:20 -080078fi;
79
Brett Chabotcdb404d2011-01-28 10:34:41 -080080JAR_DIR=${CTS_ROOT}/android-cts/tools
Brett Chabota91ea002011-01-30 13:48:20 -080081JARS="ddmlib-prebuilt.jar tradefed-prebuilt.jar hosttestlib.jar cts-tradefed.jar"
82
83for JAR in $JARS; do
84 checkFile ${JAR_DIR}/${JAR}
85 JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
86done
87
Brett Chabot4f146a42011-10-05 18:36:42 -070088java $RDBG_FLAG \
89 -cp ${JAR_PATH} -DCTS_ROOT=${CTS_ROOT} com.android.cts.tradefed.command.CtsConsole "$@"
Brett Chabota91ea002011-01-30 13:48:20 -080090