Home | History | Annotate | Download | only in utils
      1 #! /bin/bash
      2 
      3 # Copyright (C) 2009 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 if [ -z "${CTS_ROOT}" ]; then
     18 # CONFIGURATION
     19 # Set this variable to the root of unzipped CTS directory
     20 # This only needs to be changed if this script has been moved
     21 CTS_ROOT="$(dirname $0)/.."
     22 fi;
     23 
     24 # ----------------------------------------------------------------------------
     25 # END OF CONFIGURATION SECTION
     26 # ----------------------------------------------------------------------------
     27 
     28 checkDir() {
     29     if [ ! -d $1 ]; then
     30         echo "$2"
     31         exit
     32     fi;
     33 }
     34 
     35 
     36 checkFile() {
     37     if [ ! -f "$1" ]; then
     38         echo "Unable to locate $1."
     39         exit
     40     fi;
     41 }
     42 
     43 checkPath() {
     44     if ! type -P $1 &> /dev/null; then
     45         echo "Unable to find $1 in path."
     46         exit
     47     fi;
     48 }
     49 
     50 checkDir ${CTS_ROOT} "Error: Cannot locate CTS in \"${CTS_DIR}\". Please check your configuration in $0"
     51 
     52 DDM_LIB=${CTS_ROOT}/tools/ddmlib-prebuilt.jar
     53 CTS_LIB=${CTS_ROOT}/tools/cts.jar
     54 JUNIT_LIB=${CTS_ROOT}/tools/junit.jar
     55 HOSTTEST_LIB=${CTS_ROOT}/tools/hosttestlib.jar
     56 
     57 checkFile ${DDM_LIB}
     58 checkFile ${CTS_LIB}
     59 checkFile ${JUNIT_LIB}
     60 checkFile ${HOSTTEST_LIB}
     61 
     62 JARS=${CTS_LIB}:${DDM_LIB}:${JUNIT_LIB}:${HOSTTEST_LIB}
     63 
     64 # Add SDK_ROOT to the PATH for backwards compatibility with prior startcts
     65 # commands that required SDK_ROOT to find adb.
     66 if [ -n "${SDK_ROOT}" ]; then
     67   PATH=${SDK_ROOT}/platform-tools:${SDK_ROOT}/tools:${PATH}
     68 fi
     69 
     70 checkPath adb
     71 
     72 # options for the JVM
     73 JAVA_OPTS="-Xmx512M"
     74 # configuration supplied as single argument
     75 CONFIG=
     76 # configuration supplied with --config option
     77 DDCONFIG=
     78 
     79 if [ $# -eq 1 ]; then
     80     # single argument specifies configuration file
     81     :
     82 else
     83     if [ $(echo "$*" | grep -c -e --config -) -gt 0 ]; then
     84         # --config supplied on command line
     85         :
     86     else
     87         if [ $# -eq 0 ]; then
     88             # no arguments; supply config as single argument
     89             CONFIG=${CTS_ROOT}/repository/host_config.xml
     90         else
     91             # no config; append --config to existing command line
     92             DDCONFIG="--config ${CTS_ROOT}/repository/host_config.xml"
     93         fi;
     94     fi;
     95 fi;
     96 
     97 java ${JAVA_OPTS} -cp ${JARS} com.android.cts.TestHost ${CONFIG} "$@" ${DDCONFIG}
     98