Brett Chabot | a91ea00 | 2011-01-30 13:48:20 -0800 | [diff] [blame] | 1 | #!/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 | |
| 20 | checkFile() { |
| 21 | if [ ! -f "$1" ]; then |
| 22 | echo "Unable to locate $1" |
| 23 | exit |
| 24 | fi; |
| 25 | } |
| 26 | |
| 27 | checkPath() { |
| 28 | if ! type -P $1 &> /dev/null; then |
| 29 | echo "Unable to find $1 in path." |
| 30 | exit |
| 31 | fi; |
| 32 | } |
| 33 | |
| 34 | checkPath adb |
| 35 | checkPath java |
| 36 | |
| 37 | # check java version |
Narayan Kamath | 6803425 | 2014-01-22 18:09:25 +0000 | [diff] [blame] | 38 | JAVA_VERSION=$(java -version 2>&1 | head -n 1 | grep '[ "]1\.[67][\. "$$]') |
Brett Chabot | a91ea00 | 2011-01-30 13:48:20 -0800 | [diff] [blame] | 39 | if [ "${JAVA_VERSION}" == "" ]; then |
Narayan Kamath | 6803425 | 2014-01-22 18:09:25 +0000 | [diff] [blame] | 40 | echo "Wrong java version. 1.6 or 1.7 is required." |
Brett Chabot | a91ea00 | 2011-01-30 13:48:20 -0800 | [diff] [blame] | 41 | exit |
| 42 | fi |
| 43 | |
Brett Chabot | 4f146a4 | 2011-10-05 18:36:42 -0700 | [diff] [blame] | 44 | # check debug flag and set up remote debugging |
| 45 | if [ -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} |
| 50 | fi |
| 51 | |
| 52 | |
Brett Chabot | a91ea00 | 2011-01-30 13:48:20 -0800 | [diff] [blame] | 53 | # check if in Android build env |
| 54 | if [ ! -z ${ANDROID_BUILD_TOP} ]; then |
| 55 | HOST=`uname` |
| 56 | if [ "$HOST" == "Linux" ]; then |
| 57 | OS="linux-x86" |
| 58 | elif [ "$HOST" == "Darwin" ]; then |
| 59 | OS="darwin-x86" |
| 60 | else |
| 61 | echo "Unrecognized OS" |
| 62 | exit |
| 63 | fi; |
Brett Chabot | cdb404d | 2011-01-28 10:34:41 -0800 | [diff] [blame] | 64 | CTS_ROOT=${ANDROID_BUILD_TOP}/out/host/${OS}/cts |
Brett Chabot | a91ea00 | 2011-01-30 13:48:20 -0800 | [diff] [blame] | 65 | if [ ! -d ${CTS_ROOT} ]; then |
| 66 | echo "Could not find $CTS_ROOT in Android build environment. Try 'make cts'" |
| 67 | exit |
| 68 | fi; |
| 69 | fi; |
| 70 | |
| 71 | if [ -z ${CTS_ROOT} ]; then |
| 72 | # assume we're in an extracted cts install |
Brett Chabot | cdb404d | 2011-01-28 10:34:41 -0800 | [diff] [blame] | 73 | CTS_ROOT="$(dirname $0)/../.." |
Brett Chabot | a91ea00 | 2011-01-30 13:48:20 -0800 | [diff] [blame] | 74 | fi; |
| 75 | |
Brett Chabot | cdb404d | 2011-01-28 10:34:41 -0800 | [diff] [blame] | 76 | JAR_DIR=${CTS_ROOT}/android-cts/tools |
Brett Chabot | a91ea00 | 2011-01-30 13:48:20 -0800 | [diff] [blame] | 77 | JARS="ddmlib-prebuilt.jar tradefed-prebuilt.jar hosttestlib.jar cts-tradefed.jar" |
| 78 | |
| 79 | for JAR in $JARS; do |
| 80 | checkFile ${JAR_DIR}/${JAR} |
| 81 | JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR} |
| 82 | done |
| 83 | |
Brett Chabot | 4f146a4 | 2011-10-05 18:36:42 -0700 | [diff] [blame] | 84 | java $RDBG_FLAG \ |
| 85 | -cp ${JAR_PATH} -DCTS_ROOT=${CTS_ROOT} com.android.cts.tradefed.command.CtsConsole "$@" |
Brett Chabot | a91ea00 | 2011-01-30 13:48:20 -0800 | [diff] [blame] | 86 | |