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