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=${SDK_ROOT}/tools/lib/ddmlib.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 ADB_PATH=${SDK_ROOT}/tools 57 ADB_EXE=${ADB_PATH}/adb 58 59 checkFile ${DDM_LIB} 60 checkFile ${CTS_LIB} 61 checkFile ${JUNIT_LIB} 62 checkFile ${HOSTTEST_LIB} 63 checkFile ${ADB_EXE} 64 65 JARS=${CTS_LIB}:${DDM_LIB}:${JUNIT_LIB}:${HOSTTEST_LIB} 66 67 PATH=${ADB_PATH}:${PATH} 68 69 # options for the JVM 70 JAVA_OPTS="-Xmx512M" 71 # configuration supplied as single argument 72 CONFIG= 73 # configuration supplied with --config option 74 DDCONFIG= 75 76 if [ $# -eq 1 ]; then 77 # single argument specifies configuration file 78 : 79 else 80 if [ $(echo "$*" | grep -c -e --config -) -gt 0 ]; then 81 # --config supplied on command line 82 : 83 else 84 if [ $# -eq 0 ]; then 85 # no arguments; supply config as single argument 86 CONFIG=${CTS_ROOT}/repository/host_config.xml 87 else 88 # no config; append --config to existing command line 89 DDCONFIG="--config ${CTS_ROOT}/repository/host_config.xml" 90 fi; 91 fi; 92 fi; 93 94 java ${JAVA_OPTS} -cp ${JARS} com.android.cts.TestHost ${CONFIG} "$@" ${DDCONFIG} 95