Home | History | Annotate | Download | only in etc
      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 old-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
     38 JAVA_VERSION=$(java -version 2>&1 | head -n 2 | grep '[ "]1\.[678][\. "$$]')
     39 if [ "${JAVA_VERSION}" == "" ]; then
     40     echo "Wrong java version. 1.6, 1.7 or 1.8 is required."
     41     exit
     42 fi
     43 
     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 # get OS
     53 HOST=`uname`
     54 if [ "$HOST" == "Linux" ]; then
     55     OS="linux-x86"
     56 elif [ "$HOST" == "Darwin" ]; then
     57     OS="darwin-x86"
     58 else
     59     echo "Unrecognized OS"
     60     exit
     61 fi
     62 
     63 # check if in Android build env
     64 if [ ! -z "${ANDROID_BUILD_TOP}" ]; then
     65     if [ ! -z "${ANDROID_HOST_OUT}" ]; then
     66       OLD_CTS_ROOT=${ANDROID_HOST_OUT}/old-cts
     67     else
     68       OLD_CTS_ROOT=${ANDROID_BUILD_TOP}/${OUT_DIR:-out}/host/${OS}/old-cts
     69     fi
     70     if [ ! -d ${OLD_CTS_ROOT} ]; then
     71         echo "Could not find $OLD_CTS_ROOT in Android build environment. Try 'make old-cts'"
     72         exit
     73     fi;
     74 fi;
     75 
     76 if [ -z ${OLD_CTS_ROOT} ]; then
     77     # assume we're in an extracted cts install
     78     OLD_CTS_ROOT="$(dirname $0)/../.."
     79 fi;
     80 
     81 JAR_DIR=${OLD_CTS_ROOT}/old-android-cts/tools
     82 JARS="tradefed-prebuilt.jar hosttestlib.jar old-cts-tradefed.jar"
     83 
     84 for JAR in $JARS; do
     85     checkFile ${JAR_DIR}/${JAR}
     86     JAR_PATH=${JAR_PATH}:${JAR_DIR}/${JAR}
     87 done
     88 
     89 # load any shared libraries for host-side executables
     90 LIB_DIR=${OLD_CTS_ROOT}/old-android-cts/lib
     91 if [ "$HOST" == "Linux" ]; then
     92     LD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${LD_LIBRARY_PATH}
     93     export LD_LIBRARY_PATH
     94 elif [ "$HOST" == "Darwin" ]; then
     95     DYLD_LIBRARY_PATH=${LIB_DIR}:${LIB_DIR}64:${DYLD_LIBRARY_PATH}
     96     export DYLD_LIBRARY_PATH
     97 fi
     98 
     99 java $RDBG_FLAG \
    100   -cp ${JAR_PATH} -DCTS_ROOT=${OLD_CTS_ROOT} com.android.cts.tradefed.command.CtsConsole "$@"
    101 
    102